dotnet-operator-sdk icon indicating copy to clipboard operation
dotnet-operator-sdk copied to clipboard

Filter out invalid name information to generate valid hook name

Open stevefan1999-personal opened this issue 1 year ago • 0 comments

Some resources like Service, may not have a group:

apiVersion: v1
kind: Service

So it become some value like this originally: mutate.service..v1

But the regex for the webhook name in k8s demands this syntax:

      k8s.Autorest.HttpOperationException: Operation returned an invalid status code 'UnprocessableEntity', response body {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"MutatingWebhookConfiguration.admissionregistration.k8s.io \"dev-mutators\" is invalid: webhooks[1].name: Invalid value: \"mutate.service..v1\": 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]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')","reason":"Invalid","details":{"name":"dev-mutators","group":"admissionregistration.k8s.io","kind":"MutatingWebhookConfiguration","causes":[{"reason":"FieldValueInvalid","message":"Invalid value: \"mutate.service..v1\": 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]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')","field":"webhooks[1].name"}]},"code":422}

Fixes #713

stevefan1999-personal avatar Feb 10 '24 12:02 stevefan1999-personal