# Copyright (c)  WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: integrations.wso2.com
spec:
  group: wso2.com
  names:
    kind: Integration
    listKind: IntegrationList
    plural: integrations
    singular: integration
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.readiness
      name: Status
      type: string
    - jsonPath: .status.serviceName
      name: Service-Name
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    name: v1alpha2
    schema:
      openAPIV3Schema:
        description: Integration is the Schema for the integrations API
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: IntegrationSpec defines the desired state of Integration
            properties:
              autoScale:
                description: Auto scale spec
                properties:
                  enabled:
                    description: Defines if auto scaling needs to be enabled Default
                      value "<empty>".
                    type: string
                  maxReplicas:
                    description: Defines maximum number of replicas of the Integration
                      deployment Default value "<empty>".
                    format: int32
                    type: integer
                type: object
              deploySpec:
                description: Specification related to deployment
                properties:
                  cpuLimit:
                    description: CPU limit of containers in the pod Default value
                      "<empty>".
                    type: string
                  livenessProbe:
                    description: LivenessProbe for containers in the pod Default value
                      "<empty>".
                    properties:
                      exec:
                        description: One and only one of the following should be specified.
                          Exec specifies the action to take.
                        properties:
                          command:
                            description: Command is the command line to execute inside
                              the container, the working directory for the command  is
                              root ('/') in the container's filesystem. The command
                              is simply exec'd, it is not run inside a shell, so traditional
                              shell instructions ('|', etc) won't work. To use a shell,
                              you need to explicitly call out to that shell. Exit
                              status of 0 is treated as live/healthy and non-zero
                              is unhealthy.
                            items:
                              type: string
                            type: array
                        type: object
                      failureThreshold:
                        description: Minimum consecutive failures for the probe to
                          be considered failed after having succeeded. Defaults to
                          3. Minimum value is 1.
                        format: int32
                        type: integer
                      httpGet:
                        description: HTTPGet specifies the http request to perform.
                        properties:
                          host:
                            description: Host name to connect to, defaults to the
                              pod IP. You probably want to set "Host" in httpHeaders
                              instead.
                            type: string
                          httpHeaders:
                            description: Custom headers to set in the request. HTTP
                              allows repeated headers.
                            items:
                              description: HTTPHeader describes a custom header to
                                be used in HTTP probes
                              properties:
                                name:
                                  description: The header field name
                                  type: string
                                value:
                                  description: The header field value
                                  type: string
                              required:
                              - name
                              - value
                              type: object
                            type: array
                          path:
                            description: Path to access on the HTTP server.
                            type: string
                          port:
                            anyOf:
                            - type: integer
                            - type: string
                            description: Name or number of the port to access on the
                              container. Number must be in the range 1 to 65535. Name
                              must be an IANA_SVC_NAME.
                            x-kubernetes-int-or-string: true
                          scheme:
                            description: Scheme to use for connecting to the host.
                              Defaults to HTTP.
                            type: string
                        required:
                        - port
                        type: object
                      initialDelaySeconds:
                        description: 'Number of seconds after the container has started
                          before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes'
                        format: int32
                        type: integer
                      periodSeconds:
                        description: How often (in seconds) to perform the probe.
                          Default to 10 seconds. Minimum value is 1.
                        format: int32
                        type: integer
                      successThreshold:
                        description: Minimum consecutive successes for the probe to
                          be considered successful after having failed. Defaults to
                          1. Must be 1 for liveness and startup. Minimum value is
                          1.
                        format: int32
                        type: integer
                      tcpSocket:
                        description: 'TCPSocket specifies an action involving a TCP
                          port. TCP hooks not yet supported TODO: implement a realistic
                          TCP lifecycle hook'
                        properties:
                          host:
                            description: 'Optional: Host name to connect to, defaults
                              to the pod IP.'
                            type: string
                          port:
                            anyOf:
                            - type: integer
                            - type: string
                            description: Number or name of the port to access on the
                              container. Number must be in the range 1 to 65535. Name
                              must be an IANA_SVC_NAME.
                            x-kubernetes-int-or-string: true
                        required:
                        - port
                        type: object
                      timeoutSeconds:
                        description: 'Number of seconds after which the probe times
                          out. Defaults to 1 second. Minimum value is 1. More info:
                          https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes'
                        format: int32
                        type: integer
                    type: object
                  memoryLimit:
                    description: Memory limit of containers in the pod Default value
                      "<empty>".
                    type: string
                  minReplicas:
                    description: Initial minimum number of replicas in Integration
                      Default value "<empty>".
                    format: int32
                    type: integer
                  readinessProbe:
                    description: ReadinessProbe for containers in the pod Default
                      value "<empty>".
                    properties:
                      exec:
                        description: One and only one of the following should be specified.
                          Exec specifies the action to take.
                        properties:
                          command:
                            description: Command is the command line to execute inside
                              the container, the working directory for the command  is
                              root ('/') in the container's filesystem. The command
                              is simply exec'd, it is not run inside a shell, so traditional
                              shell instructions ('|', etc) won't work. To use a shell,
                              you need to explicitly call out to that shell. Exit
                              status of 0 is treated as live/healthy and non-zero
                              is unhealthy.
                            items:
                              type: string
                            type: array
                        type: object
                      failureThreshold:
                        description: Minimum consecutive failures for the probe to
                          be considered failed after having succeeded. Defaults to
                          3. Minimum value is 1.
                        format: int32
                        type: integer
                      httpGet:
                        description: HTTPGet specifies the http request to perform.
                        properties:
                          host:
                            description: Host name to connect to, defaults to the
                              pod IP. You probably want to set "Host" in httpHeaders
                              instead.
                            type: string
                          httpHeaders:
                            description: Custom headers to set in the request. HTTP
                              allows repeated headers.
                            items:
                              description: HTTPHeader describes a custom header to
                                be used in HTTP probes
                              properties:
                                name:
                                  description: The header field name
                                  type: string
                                value:
                                  description: The header field value
                                  type: string
                              required:
                              - name
                              - value
                              type: object
                            type: array
                          path:
                            description: Path to access on the HTTP server.
                            type: string
                          port:
                            anyOf:
                            - type: integer
                            - type: string
                            description: Name or number of the port to access on the
                              container. Number must be in the range 1 to 65535. Name
                              must be an IANA_SVC_NAME.
                            x-kubernetes-int-or-string: true
                          scheme:
                            description: Scheme to use for connecting to the host.
                              Defaults to HTTP.
                            type: string
                        required:
                        - port
                        type: object
                      initialDelaySeconds:
                        description: 'Number of seconds after the container has started
                          before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes'
                        format: int32
                        type: integer
                      periodSeconds:
                        description: How often (in seconds) to perform the probe.
                          Default to 10 seconds. Minimum value is 1.
                        format: int32
                        type: integer
                      successThreshold:
                        description: Minimum consecutive successes for the probe to
                          be considered successful after having failed. Defaults to
                          1. Must be 1 for liveness and startup. Minimum value is
                          1.
                        format: int32
                        type: integer
                      tcpSocket:
                        description: 'TCPSocket specifies an action involving a TCP
                          port. TCP hooks not yet supported TODO: implement a realistic
                          TCP lifecycle hook'
                        properties:
                          host:
                            description: 'Optional: Host name to connect to, defaults
                              to the pod IP.'
                            type: string
                          port:
                            anyOf:
                            - type: integer
                            - type: string
                            description: Number or name of the port to access on the
                              container. Number must be in the range 1 to 65535. Name
                              must be an IANA_SVC_NAME.
                            x-kubernetes-int-or-string: true
                        required:
                        - port
                        type: object
                      timeoutSeconds:
                        description: 'Number of seconds after which the probe times
                          out. Defaults to 1 second. Minimum value is 1. More info:
                          https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes'
                        format: int32
                        type: integer
                    type: object
                  reqMemory:
                    description: Memory request of containers in the pod Default value
                      "<empty>".
                    type: string
                  requestCPU:
                    description: Cpu request of containers in the pod Default value
                      "<empty>".
                    type: string
                type: object
              env:
                description: List of environment variables to set for the integration.
                items:
                  description: EnvVar represents an environment variable present in
                    a Container.
                  properties:
                    name:
                      description: Name of the environment variable. Must be a C_IDENTIFIER.
                      type: string
                    value:
                      description: 'Variable references $(VAR_NAME) are expanded using
                        the previous defined environment variables in the container
                        and any service environment variables. If a variable cannot
                        be resolved, the reference in the input string will be unchanged.
                        The $(VAR_NAME) syntax can be escaped with a double $$, ie:
                        $$(VAR_NAME). Escaped references will never be expanded, regardless
                        of whether the variable exists or not. Defaults to "".'
                      type: string
                    valueFrom:
                      description: Source for the environment variable's value. Cannot
                        be used if value is not empty.
                      properties:
                        configMapKeyRef:
                          description: Selects a key of a ConfigMap.
                          properties:
                            key:
                              description: The key to select.
                              type: string
                            name:
                              description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
                                TODO: Add other useful fields. apiVersion, kind, uid?'
                              type: string
                            optional:
                              description: Specify whether the ConfigMap or its key
                                must be defined
                              type: boolean
                          required:
                          - key
                          type: object
                        fieldRef:
                          description: 'Selects a field of the pod: supports metadata.name,
                            metadata.namespace, metadata.labels, metadata.annotations,
                            spec.nodeName, spec.serviceAccountName, status.hostIP,
                            status.podIP, status.podIPs.'
                          properties:
                            apiVersion:
                              description: Version of the schema the FieldPath is
                                written in terms of, defaults to "v1".
                              type: string
                            fieldPath:
                              description: Path of the field to select in the specified
                                API version.
                              type: string
                          required:
                          - fieldPath
                          type: object
                        resourceFieldRef:
                          description: 'Selects a resource of the container: only
                            resources limits and requests (limits.cpu, limits.memory,
                            limits.ephemeral-storage, requests.cpu, requests.memory
                            and requests.ephemeral-storage) are currently supported.'
                          properties:
                            containerName:
                              description: 'Container name: required for volumes,
                                optional for env vars'
                              type: string
                            divisor:
                              anyOf:
                              - type: integer
                              - type: string
                              description: Specifies the output format of the exposed
                                resources, defaults to "1"
                              pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
                              x-kubernetes-int-or-string: true
                            resource:
                              description: 'Required: resource to select'
                              type: string
                          required:
                          - resource
                          type: object
                        secretKeyRef:
                          description: Selects a key of a secret in the pod's namespace
                          properties:
                            key:
                              description: The key of the secret to select from.  Must
                                be a valid secret key.
                              type: string
                            name:
                              description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
                                TODO: Add other useful fields. apiVersion, kind, uid?'
                              type: string
                            optional:
                              description: Specify whether the Secret or its key must
                                be defined
                              type: boolean
                          required:
                          - key
                          type: object
                      type: object
                  required:
                  - name
                  type: object
                type: array
              envFrom:
                description: List of environment variable references set for the integration.
                items:
                  description: EnvFromSource represents the source of a set of ConfigMaps
                  properties:
                    configMapRef:
                      description: The ConfigMap to select from
                      properties:
                        name:
                          description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
                            TODO: Add other useful fields. apiVersion, kind, uid?'
                          type: string
                        optional:
                          description: Specify whether the ConfigMap must be defined
                          type: boolean
                      type: object
                    prefix:
                      description: An optional identifier to prepend to each key in
                        the ConfigMap. Must be a C_IDENTIFIER.
                      type: string
                    secretRef:
                      description: The Secret to select from
                      properties:
                        name:
                          description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
                            TODO: Add other useful fields. apiVersion, kind, uid?'
                          type: string
                        optional:
                          description: Specify whether the Secret must be defined
                          type: boolean
                      type: object
                  type: object
                type: array
              expose:
                description: Ports to expose
                properties:
                  inboundPorts:
                    description: InboundPorts any traffic serving port that needs
                      to be exposed
                    items:
                      format: int32
                      type: integer
                    type: array
                  passthroPort:
                    description: PassthroPort HTTP/HTTPs traffic serving ports
                    format: int32
                    type: integer
                type: object
              image:
                description: Docker image consist of micro integrator runtime and
                  synapse configs
                type: string
              imagePullSecret:
                description: Docker image credentials if the Image is in private registry
                type: string
            required:
            - image
            type: object
          status:
            description: IntegrationStatus defines the observed state of Integration
            properties:
              readiness:
                description: Status of the Integration deployment
                type: string
              serviceName:
                description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
                  of cluster Important: Run "operator-sdk generate k8s" to regenerate
                  code after modifying this file Add custom validation using kubebuilder
                  tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html
                  Name of the created service in the Integration deployment'
                type: string
            required:
            - readiness
            - serviceName
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
