sprig
sprig copied to clipboard
DNS-1123 converter
Thank you for creating sprig! :smiley:
DNS-1123 is a key Kubernetes naming requirement.
Often when templating it happens that variables contain not acceptable characters causing errors like
ConfigMap "database-yml-Union-ver-1" is invalid: metadata.name: Invalid value: "database-yml-Union-ver-1": a DNS-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]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*') (reason: Invalid)
It would be awesome if such a function would be available!
Found similar implementations like here https://gitlab.com/gitlab-org/gitlab-runner/-/blob/0e2ae0001684f681ff901baa85e0d63ec7838568/executors/kubernetes/util.go#L268