Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using IntOrString with Pattern causes validation to not occur when Int is specified #928

Open
jonathan-innis opened this issue Apr 21, 2024 · 0 comments

Comments

@jonathan-innis
Copy link
Member

We're using controller-gen generation in the aws/karpenter-provider-aws project, but we see that a pattern that we are using in our CRD is not validated when the key is of type IntOrString and the value that is passed-through is an integer. It doesn't seem to actually get validated until we attempt to update the resource later after the resource has already been applied to the apiserver. This causes resources to get stuck because they don't adhere to the "pattern" that is specified in the validation section, but the initial create is not rejected.

For example, I created a small repo that exemplifies this. When i install the test resource, and then apply the examples, I see the expected behavior when the inputs are strings; however, once the input becomes an integer, it passes right by the pattern validation.

# Install the CRDs from the repository
make install

# Apply a valid Test resource
kubectl apply -f config/samples/test_v1_valid_str.yaml

# Apply an invalid Test resource, see it fails
kubectl apply -f config/samples/test_v1_invalid_str.yaml

# Apply an invalid Test resource that doesn't adhere to the pattern but specifies an integer, see it passes when it shouldn't
kubectl apply -f config/samples/test_v1_valid_int.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant