-
Notifications
You must be signed in to change notification settings - Fork 9
Validation support for strings, arrays, numbers #329
Conversation
440ceef
to
ff50ac7
Compare
- if [ -d "./config/crd/bases" ]; then find "./config/crd/bases" -type f -delete; fi | ||
- controller-gen object:headerFile=../boilerplate.go.txt paths="./..." || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TO FIX: controller-gen emitting bad code
2e50efe
to
c01d898
Compare
@@ -123,10 +122,7 @@ func StorageAccount_BlobServices_CRUD(t *testing.T, testContext testcommon.KubeP | |||
g := NewGomegaWithT(t) | |||
|
|||
blobService := &storage.StorageAccountsBlobService{ | |||
ObjectMeta: ctrl.ObjectMeta{ | |||
Name: "default", // MUST be 'default' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the thing I’ve been working towards 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I know @babbageclunk likes stuff like this 😉)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's like when they say the title of the movie in the movie.
7902a4a
to
b341b50
Compare
b341b50
to
b56a371
Compare
16d020a
to
9dcbb87
Compare
9dcbb87
to
ce697e2
Compare
dir: "{{.CONTROLLER_ROOT}}" | ||
deps: [generate-crds] | ||
cmds: | ||
# the webhook configuration file, as it stands, is too big to load into k8s 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we open an issue with kubebuilder on this topic? Presumably the issue is that the yaml file is too big but if it were split up it'd be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe there already is one? Link it here if so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might actually be small enough now; part of the earlier problem was webhook definitions were being generated for the storage types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few other thoughts:
- Yes, I think
controller-gen
should generate multiple files - We should be able to generate fewer webhooks that apply to more types.
hack/generator/pkg/codegen/testdata/EnumNames/Single_valued_enum_name.golden
Outdated
Show resolved
Hide resolved
@@ -22,7 +22,7 @@ type PropertyDefinition struct { | |||
propertyName PropertyName | |||
propertyType Type | |||
description string | |||
validations []Validation | |||
isRequired bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this about the required validation?
Why have this here then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it's about the validation and the Optional
-ness of the type, ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the requiredness is a property of the property, not of the type of the property (this is all a bit conflated by us because we tie this to optionalness via MakeRequired/MakeOptional)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor feedback, nothing too material.
Ok, this got a bit bigger than expected:
ValidatedType
which adds support for validations.^.*/default$
validation used by Storage for names; disable AzureName when detected.SetAzureName
function instead of writing the “setter” code inline in the from-ARM conversion, which simplifies things somewhat.PropertyDefinition
by removing general validation support; properties only haveRequired
as a validation.Name
intoAzureName
(when required), this has a marker comment forcontroller-gen
which outputs the webhook configuration files.