---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crawljobs.btrix.cloud
spec:
  scope: Namespaced
  group: btrix.cloud
  names:
    kind: CrawlJob
    plural: crawljobs
    singular: crawlob
    shortNames:
      - cjs

  versions:
    - name: v1
      served: true
      storage: true
      subresources:
        status: {}
        scale:
          specReplicasPath: .spec.scale
          statusReplicasPath: .status.scale

      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              x-kubernetes-preserve-unknown-fields: true

            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true

      additionalPrinterColumns:
        - name: State
          type: string
          jsonPath: .status.state
          description: Crawl State

        - name: Pages Done
          type: integer
          jsonPath: .status.pagesDone
          description: Pages Done

        - name: Pages Found
          type: integer
          jsonPath: .status.pagesFound
          description: Pages Found

        - name: Size
          type: string
          jsonPath: .status.size
          description: Crawl Size

        - name: Time Started
          type: date
          jsonPath: .metadata.creationTimestamp
          description: "time crawl started"

        - name: Time Finished
          type: date
          jsonPath: .status.finished
          description: "if set, time crawl has finished"

        - name: Stopping
          type: boolean
          jsonPath: .spec.stopping
          description: "if set, crawl is being stopped"

        - name: Files Added
          type: integer
          jsonPath: .status.filesAdded
          description: "number of WACZ files uploaded so far from this crawl"

        - name: Scale
          type: integer
          jsonPath: .status.scale
          description: Crawl Scale
