-
Notifications
You must be signed in to change notification settings - Fork 40k
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
validate third party resources #25007
validate third party resources #25007
Conversation
@@ -152,6 +165,8 @@ func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorL | |||
version := &obj.Versions[ix] | |||
if len(version.Name) == 0 { | |||
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty")) | |||
} else if validation.IsDNS1123Label(version.Name) { |
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.
not sure how tight we should make this... we've never really defined what is allowed for a version. it definitely needs to be single-segment, but not sure beyond that. Pretty sure @thockin would be happy making this tight to begin with.
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.
@lavalamp @caesarxuchao @deads2k @kubernetes/sig-api-machinery opinions on allowed format for an api version?
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.
No slash, versions have to take one URL segment for API server routing sanity
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.
@lavalamp @caesarxuchao @deads2k @kubernetes/sig-api-machinery opinions on allowed format for an api version?
I like the tight rules. Definitely no dots or slashes we'll hose the cli.
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.
Starting with IsDNS1123Label LGTM.
Hold on-- why should these be cluster scoped? |
Never mind. I see you're not talking about the data objects. I agree the schemas need to be cluster scoped. |
cluster scope change is in #25006, see discussion there |
When you add a third party resources, they affect the types that are available across the entire cluster, effectively reserving that name. |
8ad7e9e
to
1bfd234
Compare
Validation looks ok to me. |
no red flags from me |
1bfd234
to
a17967f
Compare
a17967f
to
6c323a4
Compare
@@ -152,6 +165,8 @@ func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorL | |||
version := &obj.Versions[ix] | |||
if len(version.Name) == 0 { | |||
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty")) | |||
} else if !validation.IsDNS1123Label(version.Name) { |
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.
very restrictive, what if i want a third party resource that has an underscore in the name? Or a colon?
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.
yeah, I'm not sure what the right line to draw is. if there was a way for thirdpartyresources to specify what name formats they allow, that would be better, but in the absence of that, how much should we protect users of this API from bad names? see discussion at #25007 (diff)
@liggitt: should we make the name validation tight (dns label or subdomain, etc) or minimal (anything we can represent as a URL path segment)?
@deads2k: Without actual hooks to allow them to shape their names, I think forcing the label is reasonable.
@liggitt: you don't think most API consumers would be equipped to handle resources named İ ♥ \n?
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'm ok with starting tight. But it also encourages clients to make
assumptions "oh, third party is label, I'll just mix in some colons and
underscores and everything will be safe". No objection, otherwise LGTM.
On Mon, May 9, 2016 at 2:55 PM, Jordan Liggitt notifications@github.com
wrote:
In pkg/apis/extensions/validation/validation.go
#25007 (comment)
:@@ -152,6 +165,8 @@ func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorL
version := &obj.Versions[ix]
if len(version.Name) == 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty"))
} else if !validation.IsDNS1123Label(version.Name) {
yeah, I'm not sure what the right line to draw is. if there was a way for
thirdpartyresources to specify what name formats they allow, that would be
better, but in the absence of that, how much should we protect users of
this API from bad names? see discussion at #25007 (diff)
#25007 (diff)@liggitt https://github.com/liggitt: should we make the name validation
tight (dns label or subdomain, etc) or minimal (anything we can represent
as a URL path segment)?@deads2k https://github.com/deads2k: Without actual hooks to allow them
to shape their names, I think forcing the label is reasonable.@liggitt https://github.com/liggitt: you don't think most API consumers
would be equipped to handle resources named İ ♥ \n?—
You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/25007/files/6c323a4f723cbcb1a11d12edf1c81b8ed908057d#r62552880
this LGTM |
GCE e2e build/test passed for commit 6c323a4. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit 6c323a4. |
Automatic merge from submit-queue |
Bug 1825915: UPSTREAM: 90985: Set session scanning to manual to avoid discovering all iSCSI devices during login Origin-commit: afc841de5012eb1cb721be2ce6c70ea4c584ae9f
Bug 1825915: UPSTREAM: 90985: Set session scanning to manual to avoid discovering all iSCSI devices during login Origin-commit: afc841de5012eb1cb721be2ce6c70ea4c584ae9f
addresses validation portion of #22768
test improvements:
action required for alpha thirdpartyresource users: