# Copyright 2020 Google LLC
#
# Licensed 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
#
#     https://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: managedcertificates.networking.gke.io
spec:
  group: networking.gke.io
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          status:
            type: object
            properties:
              certificateStatus:
              # The status of the managed certificate.
                type: string
              domainStatus:
              # The status of certificate provisioning for domains
              # selected by the user.
                type: array
                items:
                  type: object
                  required:
                  - domain
                  - status
                  properties:
                    domain:
                      type: string
                    status:
                      type: string
              certificateName:
              # The name of the provisioned managed certificate.
                type: string
              expireTime:
              # The expire time of the provisioned managed certificate.
              # The certificate will be renewed automatically unless
              # the DNS configuration changes and prevents that.
                type: string
                format: date-time
          spec:
            type: object
            properties:
              domains:
              # Up to 100 non-wildcard domain names, each up to 63 characters long.
                type: array
                maxItems: 100
                items:
                  type: string
                  maxLength: 63
                  pattern: '^(([a-z0-9]+|[a-z0-9][-a-z0-9]*[a-z0-9])\.)+[a-z][-a-z0-9]*[a-z0-9]$'
    additionalPrinterColumns:
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
    - name: Status
      type: string
      description: Status of the managed certificate
      jsonPath: .status.certificateStatus
  scope: Namespaced
  names:
    plural: managedcertificates
    singular: managedcertificate
    kind: ManagedCertificate
    shortNames:
    - mcrt
