-
Notifications
You must be signed in to change notification settings - Fork 2
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
Align scaffolding with K8up #91
Conversation
1e21969
to
85dc860
Compare
api/v1alpha1/syncconfig_types.go
Outdated
@@ -22,6 +14,7 @@ type ( | |||
// NamespaceSelector defines which namespaces should be targeted | |||
NamespaceSelector *NamespaceSelector `json:"namespaceSelector,omitempty"` | |||
// SyncItems lists items to be synced to targeted namespaces | |||
// +kubebuilder:pruning:PreserveUnknownFields |
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.
// +kubebuilder:pruning:PreserveUnknownFields | |
// +kubebuilder:pruning:PreserveUnknownFields | |
// +kubebuilder:validation:EmbeddedResource |
Would this maybe help to get rid of the mentioned validation errors?
https://book.kubebuilder.io/reference/markers/crd-validation.html
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.
uuuh, lemme try
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 think it's having a problem with this property being an array:
The CustomResourceDefinition "syncconfigs.sync.appuio.ch" is invalid: spec.validation.openAPIV3Schema.properties[spec].properties[syncItems].type: Invalid value: "array": must be object if x-kubernetes-embedded-resource is true
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:EmbeddedResource
// SyncItems lists items to be synced to targeted namespaces
SyncItems []unstructured.Unstructured `json:"syncItems,omitempty"`
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.
We might be able to define a type alias for unstructured.Unstructured
and set the validation on it?
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 think I was able to get rid of the validation error by aliasing Unstructured
and put the preserveUnknownFields marker there.
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.
Can you try with // +kubebuilder:validation:EmbeddedResource
as well? Would be nice to have some basic validation that the sync items include valid K8s objects.
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 put that marker in both SyncItems []SyncItem
and SyncItem
. make generate
did not add any other fields to the CRD spec except for preserveUnknownFields, so I left it out again.
Do you think we should do it for forward compatibility?
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 left it in there now, even it doesn't do anything now.
// +kubebuilder:validation:EmbeddedResource
may be working if Unstructured
is used as its own field, but not in an array.
Now that we upgraded K8s to v1.19+, we can use the utilities from upstream
Summary
Makefile
from K8uptesting
apiextensions.k8s.io/v1
CRD version.Checklist
bug
,enhancement
,documentation
,change
,breaking
,as they show up in the changelog