Skip to content

Conversation

ryane
Copy link
Contributor

@ryane ryane commented Aug 11, 2018

fixes #246

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 11, 2018
Copy link
Contributor

@Liujingfang1 Liujingfang1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this.

return errors.New("must specify exactly one namespace value")
}
ns := args[0]
if errs := validation.IsDNS1123Label(ns); len(errs) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does namespace follow this label format? Is there any doc for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of a doc but I used this validation function after a little experimentation and reading some source code:

$ kubectl create ns _test_    
The Namespace "_test_" is invalid: metadata.name: Invalid value: "_test_": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

I traced that error through:

https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L108
https://github.com/kubernetes/apimachinery/blob/master/pkg/api/validation/generic.go#L62
https://github.com/kubernetes/kubernetes/blob/e38efdcce6860141609bb8b9f959d06d6643fdf5/pkg/apis/core/validation/validation.go#L4996

But let me know if I missed something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good tracing and that gives enough info.

@Liujingfang1
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2018
@Liujingfang1 Liujingfang1 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: ryane

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit f9577ab into kubernetes-sigs:master Aug 13, 2018
@ryane ryane deleted the setnamespace branch October 29, 2018 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support kustomize edit set namespace
3 participants