{{- if not (contains "test" .Values.namespace) }}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: templates.container.mom
  labels:
    app.kubernetes.io/managed-by: container-mom-operator
spec:
  group: container.mom
  names:
    kind: Template
    listKind: TemplateList
    plural: templates
    singular: template
    shortNames:
      - tpl
  scope: Namespaced
  versions:
    - name: v1alpha1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                description:
                  type: string
                parameters:
                  type: array
                  items:
                    type: object
                    required: ["name"]
                    properties:
                      name:
                        type: string
                      description:
                        type: string
                      required:
                        type: boolean
                      displayName:
                        type: string
                      defaultValue:
                        type: string
                      generate:
                        type: string
                components:
                  type: array
                  items:
                    type: object
                    required: ["type", "name", "properties"]
                    properties:
                      type:
                        type: string
                        enum:
                          - deployment
                          - statefulset
                          - service
                          - configmap
                          - secret
                          - ingress
                          - volume
                      name:
                        type: string
                      properties:
                        type: object
                        properties:
                          image:
                            type: string
                          gitUrl:
                            type: string
                          builderImage:
                            type: string
                          env:
                            type: array
                            items:
                              type: object
                              required: ["name"]
                              properties:
                                name:
                                  type: string
                                value:
                                  type: string
                                valueFrom:
                                  type: object
                                  properties:
                                    secretKeyRef:
                                      type: object
                                      required: ["name", "key"]
                                      properties:
                                        name:
                                          type: string
                                        key:
                                          type: string
                          resources:
                            type: object
                            properties:
                              cpu:
                                type: string
                              memory:
                                type: string
                          configData:
                            type: object
                            additionalProperties:
                              type: string
                          secretData:
                            type: object
                            additionalProperties:
                              type: string
                          ports:
                            type: array
                            items:
                              type: object
                              properties:
                                name:
                                  type: string
                                port:
                                  type: integer
                                targetPort:
                                  type: integer
                                protocol:
                                  type: string
                          volumes:
                            type: array
                            items:
                              type: object
                              properties:
                                name:
                                  type: string
                                type:
                                  type: string
                                mountPath:
                                  type: string
                                size:
                                  type: string
                                storageClass:
                                  type: string
                                sourceName:
                                  type: string
                          dependencies:
                            type: array
                            items:
                              type: string
                          targetComponent:
                            type: string
                            description: "Specifies which deployment component this resource is associated with. For services, determines which deployment the service will route to."
                networkConfig:
                  type: object
                  properties:
                    domain:
                      type: object
                      properties:
                        domainName:
                          type: string
                        prefix:
                          type: string
                        useWildcard:
                          type: boolean
                        tls:
                          type: object
                          properties:
                            autoCert:
                              type: boolean
                            secretName:
                              type: string
                            email:
                              type: string
                        dnsProvider:
                          type: object
                          properties:
                            provider:
                              type: string
                            secretName:
                              type: string
                    ingressRules:
                      type: array
                      items:
                        type: object
                        properties:
                          host:
                            type: string
                          path:
                            type: string
                          serviceName:
                            type: string
                          servicePort:
                            type: integer
            status:
              type: object
              properties:
                lastUpdated:
                  type: string
                  format: date-time
                usageCount:
                  type: integer
      additionalPrinterColumns:
      - name: Description
        type: string
        jsonPath: .spec.description
      - name: Usage Count
        type: integer
        jsonPath: .status.usageCount
      - name: Age
        type: date
        jsonPath: .metadata.creationTimestamp
      subresources:
        status: {}
{{- end }}
