krateo icon indicating copy to clipboard operation
krateo copied to clipboard

bug: CRD schema does not match with defined value.schema.json

Open alfredo-milani-kiratech opened this issue 9 months ago • 2 comments

Describe the bug Once the CompositionDefinition is installed on the cluster, the CRD schema generated does not match with the one defined in value.schema.json.

To Reproduce Steps to reproduce the behavior:

  1. Install Krateo v2.0.0 cluster with kind
  2. Apply the following CompositionDefinition
apiVersion: core.krateo.io/v1alpha1
kind: CompositionDefinition
metadata:
  annotations:
    krateo.io/connector-verbose: "true"
    meta.helm.sh/release-namespace: krateo-system
  labels:
    app.kubernetes.io/managed-by: Helm
  name: x
  namespace: demo-system
spec:
  chart:
    url: https://github.com/alfredo-milani-kiratech/krateo-v2-template-fireworksapp/releases/download/0.0.10/x-app-0.0.10.tgz
  deletionPolicy: Delete
  1. The CRD on the cluster shows:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.14.0
  creationTimestamp: "2024-05-10T10:40:13Z"
  generation: 1
  name: xapps.composition.krateo.io
  resourceVersion: "738"
  uid: 53b8c5a2-85e6-4878-9e3a-1fbb1f6e9ff7
spec:
  conversion:
    strategy: None
  group: composition.krateo.io
  names:
    categories:
    - compositions
    - comps
    kind: Xapp
    listKind: XappList
    plural: xapps
    singular: xapp
  scope: Namespaced
  versions:
  - name: v0-0-10
    schema:
      openAPIV3Schema:
        properties:
          apiVersion:
            description: |-
              APIVersion defines the versioned schema of this representation of an object.
              Servers should convert recognized schemas to the latest internal value, and
              may reject unrecognized values.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
            type: string
          kind:
            description: |-
              Kind is a string value representing the REST resource this object represents.
              Servers may infer this from the endpoint the client submits requests to.
              Cannot be updated.
              In CamelCase.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
            type: string
          spec:
            properties:
              app:
                properties:
                  env:
                    default: dev
                    type: string
                  svc:
                    default: false
                    type: boolean
                required:
                - env
                - svc
                type: object
              deletionPolicy:
                default: Delete
                description: |-
                  DeletionPolicy specifies what will happen to the underlying external
                  when this managed resource is deleted - either "Delete" or "Orphan" the
                  external resource.
                enum:
                - Orphan
                - Delete
                type: string
              infra:
                properties:
                  env:
                    default: dev
                    type: string
                  svc:
                    default: false
                    type: boolean
                required:
                - env
                - svc
                type: object
            required:
            - app
            - infra
            type: object
        type: object
    served: true
    storage: true
status:
  acceptedNames:
    categories:
    - compositions
    - comps
    kind: Xapp
    listKind: XappList
    plural: xapps
    singular: xapp
  conditions:
  - lastTransitionTime: "2024-05-10T10:40:13Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: "2024-05-10T10:40:13Z"
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  storedVersions:
  - v0-0-10

while the value.schema.json defined is:

{
  "type": "object",
  "$schema": "http://json-schema.org/draft-07/schema",
  "required": [
    "infra",
    "app"
  ],
  "properties": {
    "infra": {
      "type": "object",
      "title": "Helm Chart parameters section",
      "required": [
        "env",
        "svc"
      ],
      "properties": {
        "env": {
          "type": [
            "string"
          ],
          "title": "Helm Chart service parameters section",
          "default": "dev"
        },
        "svc": {
          "type": [
            "boolean"
          ],
          "title": "Helm Chart service parameters section",
          "default": false
        }
      }
    },
    "app": {
      "type": "object",
      "title": "Helm Chart parameters section",
      "required": [
        "service"
      ],
      "properties": {
        "service": {
          "type": "object",
          "title": "Helm Chart service parameters section",
          "required": [
            "type",
            "port"
          ],
          "properties": {
            "type": {
              "type": [
                "string",
                "boolean",
                "number",
                "object",
                "array"
              ],
              "enum": [
                "NodePort",
                "LoadBalancer"
              ],
              "title": "Helm Chart service type",
              "default": "NodePort"
            },
            "port": {
              "type": "integer",
              "minimum": 30000,
              "maximum": 32767,
              "title": "Helm Chart service port",
              "default": "31180"
            }
          }
        }
      }
    }
  }
}

alfredo-milani-kiratech avatar May 10 '24 11:05 alfredo-milani-kiratech