---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: azurekeyvaultsecrets.spv.no
spec:
  group: spv.no
  names:
    kind: AzureKeyVaultSecret
    listKind: AzureKeyVaultSecretList
    plural: azurekeyvaultsecrets
    singular: azurekeyvaultsecret
    shortNames:
    - akvs
    categories:
    - all
  scope: Namespaced
  versions: 
    - name: v1alpha1
      served: true
      storage: false
      subresources:
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required: ['vault']
              properties:
                vault:
                  type: object
                  required: ['name', 'object']
                  properties:
                    name:
                      type: string
                      description: Name of the Azure Key Vault
                    object:
                      type: object
                      required: ['name', 'type']
                      properties:
                        name:
                          type: string
                          description: The object name in Azure Key Vault
                        type:
                          type: string
                          description: The type of object in Azure Key Vault
                          enum:
                          - secret
                          - certificate
                          - key
                          - multi-key-value-secret 
                        version:
                          type: string
                          description: The object version in Azure Key Vault
                        contentType:
                          type: string
                          description: Only used when type is multi-key-value-secret. 
                          enum:
                          - application/x-json
                          - application/x-yaml
                output:
                  type: object
                  properties:
                    transform:
                      type: array
                      items:
                        type: string
                    secret:
                      type: object
                      required: ['name']
                      properties:
                        name:
                          type: string
                          description: Name for Kubernetes secret
                        type:
                          type: string
                          description: Type of Secret in Kubernetes
                        dataKey:
                          type: string
                          description: The key to use in Kubernetes secret when setting the value from Azure Keyv Vault object data
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true

      additionalPrinterColumns:
        - name: Vault
          type: string
          description: Which Azure Key Vault this resource is asosiated with
          jsonPath: .spec.vault.name
        - name: Vault Object
          type: string
          description: Which Azure Key Vault object this resource is asosiated with
          jsonPath: .spec.vault.object.name
        - name: Output Object
          type: string
          description: Which Kubernetes Secret or ConfigMap this resource is synched with, if any
          jsonPath: .status.secretName
        - name: Synched
          type: string
          description: When this resource was last synched with Azure Key Vault
          jsonPath: .status.lastAzureUpdate

    - name: v1
      served: true
      storage: false
      subresources:
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required: ['vault']
              properties:
                vault:
                  type: object
                  required: ['name', 'object']
                  properties:
                    name:
                      type: string
                      description: Name of the Azure Key Vault
                    object:
                      type: object
                      required: ['name', 'type']
                      properties:
                        name:
                          type: string
                          description: The object name in Azure Key Vault
                        type:
                          type: string
                          description: The type of object in Azure Key Vault
                          enum:
                          - secret
                          - certificate
                          - key
                          - multi-key-value-secret 
                        version:
                          type: string
                          description: The object version in Azure Key Vault
                        contentType:
                          type: string
                          description: Only used when type is multi-key-value-secret. 
                          enum:
                          - application/x-json
                          - application/x-yaml
                output:
                  type: object
                  properties:
                    transform:
                      type: array
                      items:
                        type: string
                    secret:
                      type: object
                      required: ['name']
                      properties:
                        name:
                          type: string
                          description: Name for Kubernetes secret
                        type:
                          type: string
                          description: Type of Secret in Kubernetes
                        dataKey:
                          type: string
                          description: The key to use in Kubernetes secret when setting the value from Azure Keyv Vault object data
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true

      additionalPrinterColumns:
        - name: Vault
          type: string
          description: Which Azure Key Vault this resource is asosiated with
          jsonPath: .spec.vault.name
        - name: Vault Object
          type: string
          description: Which Azure Key Vault object this resource is asosiated with
          jsonPath: .spec.vault.object.name
        - name: Secret Name
          type: string
          description: Which Kubernetes Secret this resource is synched with, if any
          jsonPath: .status.secretName
        - name: Synched
          type: string
          description: When this resource was last synched with Azure Key Vault
          jsonPath: .status.lastAzureUpdate

    - name: v2alpha1
      served: true
      storage: false
      subresources:
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required: ['vault']
              properties:
                vault:
                  type: object
                  required: ['name', 'object']
                  properties:
                    name:
                      type: string
                      description: Name of the Azure Key Vault
                    object:
                      type: object
                      required: ['name', 'type']
                      properties:
                        name:
                          type: string
                          description: The object name in Azure Key Vault
                        type:
                          type: string
                          description: The type of object in Azure Key Vault
                          enum:
                          - secret
                          - certificate
                          - key
                          - multi-key-value-secret 
                        version:
                          type: string
                          description: The object version in Azure Key Vault
                        contentType:
                          type: string
                          description: Only used when type is multi-key-value-secret. 
                          enum:
                          - application/x-json
                          - application/x-yaml
                    azureIdentity:
                      type: object
                      properties:
                        name: 
                          type: string
                          description: Name of the azureIdentity to use for Azure Key Vault authentication
                output:
                  type: object
                  properties:
                    transform:
                      type: array
                      items:
                        type: string
                    secret:
                      type: object
                      required: ['name']
                      properties:
                        name:
                          type: string
                          description: Name for Kubernetes secret
                        type:
                          type: string
                          description: Type of Secret in Kubernetes
                        dataKey:
                          type: string
                          description: The key to use in Kubernetes secret when setting the value from Azure Keyv Vault object data
                    configMap:
                      type: object
                      required: ['name']
                      properties:
                        name:
                          type: string
                          description: Name for Kubernetes ConfigMap
                        dataKey:
                          type: string
                          description: The key to use in Kubernetes ConfigMap when setting the value from Azure Keyv Vault object data
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true

      additionalPrinterColumns:
        - name: Vault
          type: string
          description: Which Azure Key Vault this resource is asosiated with
          jsonPath: .spec.vault.name
        - name: Vault Object
          type: string
          description: Which Azure Key Vault object this resource is asosiated with
          jsonPath: .spec.vault.object.name
        - name: Secret Name
          type: string
          description: Which Kubernetes Secret this resource is synched with, if any
          jsonPath: .status.secretName
        - name: ConfigMap Name
          type: string
          description: Which Kubernetes ConfigMap this resource is synched with, if any
          jsonPath: .status.configMapName
        - name: Last Synched
          type: date
          description: When this resource was last synched with Azure Key Vault
          jsonPath: .status.lastAzureUpdate

    - name: v2beta1
      served: true
      storage: true
      subresources:
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required: ['vault']
              properties:
                vault:
                  type: object
                  required: ['name', 'object']
                  properties:
                    name:
                      type: string
                      description: Name of the Azure Key Vault
                    object:
                      type: object
                      required: ['name', 'type']
                      properties:
                        name:
                          type: string
                          description: The object name in Azure Key Vault
                        type:
                          type: string
                          description: The type of object in Azure Key Vault
                          enum:
                          - secret
                          - certificate
                          - key
                          - multi-key-value-secret 
                        version:
                          type: string
                          description: The object version in Azure Key Vault
                        contentType:
                          type: string
                          description: Only used when type is multi-key-value-secret. 
                          enum:
                          - application/x-json
                          - application/x-yaml
                    azureIdentity:
                      type: object
                      properties:
                        name: 
                          type: string
                          description: Name of the azureIdentity to use for Azure Key Vault authentication
                output:
                  type: object
                  properties:
                    transform:
                      type: array
                      items:
                        type: string
                    secret:
                      type: object
                      required: ['name']
                      properties:
                        name:
                          type: string
                          description: Name for Kubernetes secret
                        type:
                          type: string
                          description: Type of Secret in Kubernetes
                        dataKey:
                          type: string
                          description: The key to use in Kubernetes secret when setting the value from Azure Keyv Vault object data
                    configMap:
                      type: object
                      required: ['name']
                      properties:
                        name:
                          type: string
                          description: Name for Kubernetes ConfigMap
                        dataKey:
                          type: string
                          description: The key to use in Kubernetes ConfigMap when setting the value from Azure Keyv Vault object data
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true

      additionalPrinterColumns:
        - name: Vault
          type: string
          description: Which Azure Key Vault this resource is asosiated with
          jsonPath: .spec.vault.name
        - name: Vault Object
          type: string
          description: Which Azure Key Vault object this resource is asosiated with
          jsonPath: .spec.vault.object.name
        - name: Secret Name
          type: string
          description: Which Kubernetes Secret this resource is synched with, if any
          jsonPath: .status.secretName
        - name: ConfigMap Name
          type: string
          description: Which Kubernetes ConfigMap this resource is synched with, if any
          jsonPath: .status.configMapName
        - name: Last Synched
          type: date
          description: When this resource was last synched with Azure Key Vault
          jsonPath: .status.lastAzureUpdate
