{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs }}
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: kongconsumers.configuration.konghq.com
  annotations:
    "helm.sh/hook": crd-install
    {{- if .Values.ingressController.customResourceDeletePolicy }}
    "helm.sh/hook-delete-policy": {{ .Values.ingressController.customResourceDeletePolicy }}
    {{- end }}
spec:
  group: configuration.konghq.com
  version: v1
  scope: Namespaced
  names:
    kind: KongConsumer
    plural: kongconsumers
    shortNames:
    - kc
  additionalPrinterColumns:
  - name: Username
    type: string
    description: Username of a Kong Consumer
    JSONPath: .username
  - name: Age
    type: date
    description: Age
    JSONPath: .metadata.creationTimestamp
  validation:
    openAPIV3Schema:
      properties:
        username:
          type: string
        custom_id:
          type: string
        credentials:
          type: array
          items:
            type: string
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: kongcredentials.configuration.konghq.com
  annotations:
    "helm.sh/hook": crd-install
    {{- if .Values.ingressController.customResourceDeletePolicy }}
    "helm.sh/hook-delete-policy": {{ .Values.ingressController.customResourceDeletePolicy }}
    {{- end }}
spec:
  group: configuration.konghq.com
  version: v1
  scope: Namespaced
  names:
    kind: KongCredential
    plural: kongcredentials
  additionalPrinterColumns:
  - name: Credential-type
    type: string
    description: Type of credential
    JSONPath: .type
  - name: Age
    type: date
    description: Age
    JSONPath: .metadata.creationTimestamp
  - name: Consumer-Ref
    type: string
    description: Owner of the credential
    JSONPath: .consumerRef
  validation:
    openAPIV3Schema:
      required:
      - consumerRef
      - type
      properties:
        consumerRef:
          type: string
        type:
          type: string
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: kongplugins.configuration.konghq.com
  annotations:
    "helm.sh/hook": crd-install
    {{- if .Values.ingressController.customResourceDeletePolicy }}
    "helm.sh/hook-delete-policy": {{ .Values.ingressController.customResourceDeletePolicy }}
    {{- end }}
spec:
  group: configuration.konghq.com
  version: v1
  scope: Namespaced
  names:
    kind: KongPlugin
    plural: kongplugins
    shortNames:
    - kp
  additionalPrinterColumns:
  - name: Plugin-Type
    type: string
    description: Name of the plugin
    JSONPath: .plugin
  - name: Age
    type: date
    description: Age
    JSONPath: .metadata.creationTimestamp
  - name: Disabled
    type: boolean
    description: Indicates if the plugin is disabled
    JSONPath: .disabled
    priority: 1
  - name: Config
    type: string
    description: Configuration of the plugin
    JSONPath: .config
    priority: 1
  validation:
    openAPIV3Schema:
      required:
      - plugin
      properties:
        plugin:
          type: string
        disabled:
          type: boolean
        config:
          type: object
        run_on:
          type: string
          enum:
          - first
          - second
          - all
        protocols:
          type: array
          items:
            type: string
            enum:
            - http
            - https
            - grpc
            - grpcs
            - tcp
            - tls
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: kongclusterplugins.configuration.konghq.com
  annotations:
    "helm.sh/hook": crd-install
    {{- if .Values.ingressController.customResourceDeletePolicy }}
    "helm.sh/hook-delete-policy": {{ .Values.ingressController.customResourceDeletePolicy }}
    {{- end }}
spec:
  group: configuration.konghq.com
  version: v1
  scope: Cluster
  names:
    kind: KongClusterPlugin
    plural: kongclusterplugins
    shortNames:
    - kcp
  additionalPrinterColumns:
  - name: Plugin-Type
    type: string
    description: Name of the plugin
    JSONPath: .plugin
  - name: Age
    type: date
    description: Age
    JSONPath: .metadata.creationTimestamp
  - name: Disabled
    type: boolean
    description: Indicates if the plugin is disabled
    JSONPath: .disabled
    priority: 1
  - name: Config
    type: string
    description: Configuration of the plugin
    JSONPath: .config
    priority: 1
  validation:
    openAPIV3Schema:
      required:
      - plugin
      properties:
        plugin:
          type: string
        disabled:
          type: boolean
        config:
          type: object
        run_on:
          type: string
          enum:
          - first
          - second
          - all
        protocols:
          type: array
          items:
            type: string
            enum:
            - http
            - https
            - grpc
            - grpcs
            - tcp
            - tls
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: kongingresses.configuration.konghq.com
  annotations:
    "helm.sh/hook": crd-install
    {{- if .Values.ingressController.customResourceDeletePolicy }}
    "helm.sh/hook-delete-policy": {{ .Values.ingressController.customResourceDeletePolicy }}
    {{- end }}
spec:
  group: configuration.konghq.com
  version: v1
  scope: Namespaced
  names:
    kind: KongIngress
    plural: kongingresses
    shortNames:
    - ki
  validation:
    openAPIV3Schema:
      properties:
        route:
          properties:
            methods:
              type: array
              items:
                type: string
            headers:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
            regex_priority:
              type: integer
            strip_path:
              type: boolean
            preserve_host:
              type: boolean
            path_handling:
              type: string
              enum:
              - "v0"
              - "v1"
            protocols:
              type: array
              items:
                type: string
                enum:
                - http
                - https
                - grpc
                - grpcs
                - tcp
                - tls
            https_redirect_status_code:
              type: integer
        proxy:
          type: object
          properties:
            protocol:
              type: string
              enum:
              - http
              - https
              - grpc
              - grpcs
              - tcp
              - tls
            path:
              type: string
              pattern: ^/.*$
            retries:
              type: integer
              minimum: 0
            connect_timeout:
              type: integer
              minimum: 0
            read_timeout:
              type: integer
              minimum: 0
            write_timeout:
              type: integer
              minimum: 0
        upstream:
          type: object
          properties:
            algorithm:
              type: string
              enum:
              - "round-robin"
              - "consistent-hashing"
              - "least-connections"
            host_header:
              type: string
            hash_on:
              type: string
            hash_on_cookie:
              type: string
            hash_on_cookie_path:
              type: string
            hash_on_header:
              type: string
            hash_fallback_header:
              type: string
            hash_fallback:
              type: string
            slots:
              type: integer
              minimum: 10
            healthchecks:
              type: object
              properties:
                threshold:
                  type: integer
                active:
                  type: object
                  properties:
                    concurrency:
                      type: integer
                      minimum: 1
                    timeout:
                      type: integer
                      minimum: 0
                    http_path:
                      type: string
                      pattern: ^/.*$
                    healthy: &healthy
                      type: object
                      properties:
                        http_statuses:
                          type: array
                          items:
                            type: integer
                        interval:
                          type: integer
                          minimum: 0
                        successes:
                          type: integer
                          minimum: 0
                    unhealthy: &unhealthy
                      type: object
                      properties:
                        http_failures:
                          type: integer
                          minimum: 0
                        http_statuses:
                          type: array
                          items:
                            type: integer
                        interval:
                          type: integer
                          minimum: 0
                        tcp_failures:
                          type: integer
                          minimum: 0
                        timeout:
                          type: integer
                          minimum: 0
                passive:
                  type: object
                  properties:
                    healthy: *healthy
                    unhealthy: *unhealthy
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: tcpingresses.configuration.konghq.com
  annotations:
    "helm.sh/hook": crd-install
    {{- if .Values.ingressController.customResourceDeletePolicy }}
    "helm.sh/hook-delete-policy": {{ .Values.ingressController.customResourceDeletePolicy }}
    {{- end }}
spec:
  group: configuration.konghq.com
  version: v1beta1
  scope: Namespaced
  names:
    kind: TCPIngress
    plural: tcpingresses
  additionalPrinterColumns:
  - name: Address
    type: string
    description: Address of the load balancer
    JSONPath: .status.loadBalancer.ingress[*].ip
  - name: Age
    type: date
    description: Age
    JSONPath: .metadata.creationTimestamp
  subresources:
    status: {}
  validation:
    openAPIV3Schema:
      properties:
        apiVersion:
          type: string
        kind:
          type: string
        metadata:
          type: object
        spec:
          type: object
          properties:
            tls:
              type: array
              items:
                type: object
                properties:
                  hosts:
                    type: array
                    items:
                      type: string
                  secretName:
                    type: string
            rules:
              type: array
              items:
                type: object
                properties:
                  host:
                    type: string
                  port:
                    type: integer
                    format: int32
                  backend:
                    type: object
                    properties:
                      serviceName:
                        type: string
                      servicePort:
                        format: int32
                        type: integer
        status:
          type: object
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []
{{- end }}
