Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use the CRD example schema #211

Closed
Wazbat opened this issue Jun 9, 2023 · 7 comments
Closed

Unable to use the CRD example schema #211

Wazbat opened this issue Jun 9, 2023 · 7 comments

Comments

@Wazbat
Copy link

Wazbat commented Jun 9, 2023

I'm trying to validate my kubernetes templates using kubeconform in a github actions workflow, however I get an error in my CI

Here is the step in my build process

- uses: docker://ghcr.io/yannh/kubeconform:master
  with:
    entrypoint: '/kubeconform'
    args: >
      -summary -output text
      -schema-location default
      -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{ .Group }}/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json'
      manifest-${{ matrix.name }}.yaml"

I have copied the url from the README, however I get the following error:
failed initialising schema location registry: template: tpl:1:64: executing "tpl" at <.Group>: can't evaluate field Group in type struct { NormalizedKubernetesVersion string; StrictSuffix string; ResourceKind string; ResourceAPIVersion string; KindSuffix string }

It appears that {{.Group}} is not valid as part of the template string? What should I be using there instead?

@eyarz
Copy link
Contributor

eyarz commented Jun 11, 2023

try without the spaces before and after each variable.

-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'

it's a weird bug in GH workflow

@Wazbat
Copy link
Author

Wazbat commented Jun 11, 2023

Ah apologies, I modified that line to make it clearer for the issue. In my workflow it's a one liner, with no spaces in the template

args: "-summary -output text -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' manifest-${{ matrix.name }}.yaml"

@eyarz
Copy link
Contributor

eyarz commented Jun 12, 2023

are you able to reproduce this issue when running kubeconform locally?
the error that you're getting is related to an older version of kubeconform but it looks like you're using the latest version 🤷

@Wazbat
Copy link
Author

Wazbat commented Jun 15, 2023

I was really struggling to figure out the syntax locally, however I want to add that after pinning the version in the yaml to the latest release v0.6.2, it seems to work fine

Perhaps master is not the correct tag? I checked with docker inpsect and it seems to be from 2021? Wouldn't the newest one be latest?

@yannh
Copy link
Owner

yannh commented Jun 21, 2023

Ohhh very nice catch on the incorrect tag, apologies ❤️

@yannh
Copy link
Owner

yannh commented Jul 16, 2023

Closing, the Readme has been updated 🙇 thanks for the report ❤️

@yannh yannh closed this as completed Jul 16, 2023
@CyDickey-msr
Copy link

I ran into a similar issue and the fix for me was dropping the '' around the schema links:

- name: Scan files with kube-conform
  if: inputs.kube_conform_checks == 'true'
  id: kube_conform_scan
  uses: docker://ghcr.io/yannh/kubeconform:v0.6.4
  with:
    entrypoint: '/kubeconform'
    args: >
      -summary 
      -strict
      -kubernetes-version ${{ inputs.kubernetes_version }}
      -schema-location default
      -schema-location https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json
      -schema-location https://json.schemastore.org/kustomization.json
      -output ${{ inputs.kube_conform_format }}
      ${{ inputs.directory }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants