Skip to content

Dealing with lower/upper case strings in -schema-location #338

Description

@julianofischer

Title: Schema filename casing mismatch between openapi2json.py output and -schema-location template

Body:
Context
The README suggests using a template for custom schemas like:

# If the resource Kind is not found in default, also lookup in the schemas/ folder for a matching file
kubeconform -schema-location default -schema-location 'schemas/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/custom-resource.yaml

Problem

  • The helper script openapi2json.py writes schema files in lowercase.
  • .ResourceKind is typically PascalCase (e.g., MyCustomResource), so the template above looks for schemas/MyCustomResource.json, while the generated file is schemas/mycustomresource.json.
  • As a result, kubeconform doesn’t find the schema unless users manually rename files or avoid the documented template.

Questions

  • What is the recommended approach to reconcile this casing mismatch?

What would help
Any of the following would resolve the mismatch:

  • Documented guidance on the expected casing for user-provided schemas.
  • Support for a lowercase variant in templates (e.g., {{ .ResourceKindLower }}), or exposing common template functions (e.g., | lower).
  • Update the README example to use a pattern consistent with the generator’s output (e.g., suggest schemas/{{ .ResourceKind }}.json only if generator matches that casing, otherwise provide a lowercase example).

Request

  • Is there an officially recommended pattern here?
  • If template functions aren’t supported, could you consider adding a lowercase variable or documenting a canonical casing for schema filenames?

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