kwctl icon indicating copy to clipboard operation
kwctl copied to clipboard

Feature: kwctl should check for validity of `metadata.name`

Open viccuad opened this issue 6 months ago • 0 comments

Problem

Setting a wrong annotations."io.kubewarden.policy.title" in metadata.yaml may result in a wrong metadata.name of the CRD after scaffolding. For example a name my policy is invalid as it contains spaces, while my-policy is valid. Valid k8s metadata.name must follow:

a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is 'a-z0-9?(.a-z0-9?)*')

This is not necessarily true for raw policies as they don't need to be deployed via a CRD in the K8s api. But maybe is good to enforce it anyways.

Notice that a user can manually edit the metadata.yaml after scaffolding.

Acceptance criteria

  • Running E2E tests with kwctl (for example kwctl run, kwctl scaffold) should error and inform the user of incorrect metadata.

viccuad avatar Jan 25 '24 12:01 viccuad