Skip to content

generate CRD schema json #482

Description

@nvtkaszpir

Is your feature request related to a problem? Please describe.
when running kubeconformon the k8s-cleaner crd objects it will error out saying they are unknown spec for it.

Describe the solution you'd like
generate crd schema json files in the repo so they can be included in kubeconform.

Describe alternatives you've considered
schemas could be later added as PR to https://github.com/datreeio/CRDs-catalog

Additional context
https://github.com/yannh/kubeconform

kubeconform version:

kubeconform -v                                                                                                            1 ↵
v0.7.0

command to test the objects:

        kubeconform \
          -strict \
          -verbose \
          -kubernetes-version 1.34.2 \
          -ignore-filename-pattern ".*customresourcedefinition.*" \
          -schema-location default \
          -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
          -output pretty \
          -summary \
          apps.projectsveltos.io_v1alpha1_cleaner_pods-completed.yaml

input save as apps.projectsveltos.io_v1alpha1_cleaner_pods-completed.yaml:

apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
  name: pods-completed
  namespace: k8s-cleaner
spec:
  action: Delete
  notifications:
  - name: event
    type: Event
  resourcePolicySet:
    resourceSelectors:
    - evaluate: |
        function evaluate()
          hs = {}
          hs.matching = false
          if obj.status.conditions ~= nil then
            for _, condition in ipairs(obj.status.conditions) do
              if condition.reason == "PodCompleted" and condition.status == "True" then
                hs.matching = true
              end
            end
          end
          return hs
        end
      group: ""
      kind: Pod
      version: v1
  schedule: '*/15 * * * *'

output:

✖ apps.projectsveltos.io_v1alpha1_cleaner_pods-completed.yaml: Cleaner failed validation: pods-completed could not find schema for Cleaner

I could use CRD yaml files to generate schemas, but I have not tried it yet, maybe on Friday.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions