Skip to content

Validation for metadata.labels #21

@gitkent

Description

@gitkent

Hi all,

We are trying to put some validation in place for our Kubernetes manifests YAML files and we noticed that it is not validating the labels mapping value as per its requirements:

❯ kubernetes-validate  /tmp/test-ns.yaml
INFO /tmp/test-ns.yaml passed for resource namespace/test1 against version 1.26

❯ oc apply -f /tmp/test-ns.yaml --dry-run=server --validate=true
The Namespace "test1" is invalid: metadata.labels: Invalid value: "my value": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

❯ cat /tmp/test-ns.yaml | grep "my value"
    mykey: my value

By any chance we can have validation for this?

Kent

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