-
Notifications
You must be signed in to change notification settings - Fork 440
✨ Add crd:validation:Schemaless marker #528
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
✨ Add crd:validation:Schemaless marker #528
Conversation
Welcome @maxsmythe! |
This marker will avoid trying to do any type detection on any struct field on which it is set. This gives users a safety valve when they hit an edge case where type inference does the wrong thing for them. Signed-off-by: Max Smythe <[email protected]>
80b5507
to
ddfa00f
Compare
We have a situation where we want to model spec:
config: # we want this to be map[string]interface
foo: '{some-fun-json}'
members: 3 Currently we're using: Config json.RawMessage `json:"config,omitempty"` And then converting to func (in *ProxyDefaults) convertConfig() map[string]interface{} {
if in.Spec.Config == nil {
return nil
}
var outConfig map[string]interface{}
json.Unmarshal(in.Spec.Config, &outConfig)
return outConfig
} The only CRD type we've found that works is properties:
config:
description: yada
type: object However the CRD generation gives us: config:
description: yada
format: byte
type: string If we use the annotation // +kubebuilder:validation:Type=object
Config json.RawMessage `json:"config,omitempty"` We get an error:
Would this change allow us to do: // +kubebuilder:validation:Type=object
// +kubebuilder:validation:Schemaless
Config json.RawMessage `json:"config,omitempty"` ? |
It should be able to. Some alternatives for you:
If neither of these alternatives work for you, this PR would be helpful. |
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.
minor comment on a go modules file change, otherwise lgtm
@@ -1,6 +1,4 @@ | |||
run: | |||
modules-download-mode: readonly |
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.
??
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.
That had fixed an error I was having running the linter. It's been a while, so I can't remember what the error was.
Testing again with this line re-added doesn't cause a problem anymore. I wonder if it only breaks if your go modules aren't already up-to-date?
In any case, not really in scope for this PR, so reverting.
Signed-off-by: Max Smythe <[email protected]>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, maxsmythe The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks! |
This marker will avoid trying to do any type detection on any struct field on which it is set. This gives users a safety valve when they hit an edge case where type inference does the wrong thing for them.
This fixes #291, which was recently re-broken by fixing #502
Signed-off-by: Max Smythe [email protected]