• Kubernetes Submit Queue's avatar
    Merge pull request #31353 from juanvallejo/jvallejo_fix-duplicate-errors-kubectl-set-env · bda57b8f
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    fix duplicate validation/field/errors
    
    **Release note**:
    
    ``` release-note
    release-note-none
    ```
    
    Related PR: https://github.com/kubernetes/kubernetes/pull/30313
    
    PR #30313 fixed duplicate errors for invalid aggregate errors in
    https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/util/helpers.go
    
    However, duplicate aggregate errors that went through
    https://github.com/kubernetes/kubernetes/blob/master/pkg/util/validation/field/errors.go
    were not affected by that patch.
    
    This patch adds duplicate aggregate error checking to
    `pkg/util/validation/field/errors.go`
    ##### Before
    
    `$ kubectl set env rc/idling-echo-1 test-abc=1234`
    
    ```
    error: ReplicationController "idling-echo-1" is invalid:
    [spec.template.spec.containers[0].env[0].name: Invalid value:
    "test-abc": must be a C identifier (matching regex
    [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName",
    spec.template.spec.containers[1].env[0].name: Invalid value: "test-abc":
    must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.
    "my_name" or "MyName", spec.template.spec.containers[0].env[0].name:
    Invalid value: "test-abc": must be a C identifier (matching regex
    [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName",
    spec.template.spec.containers[1].env[0].name: Invalid value: "test-abc":
    must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.
    "my_name" or "MyName"]
    ```
    
    `$ kubectl set env rc/node-1 test-abc=1234`
    
    ```
    error: ReplicationController "idling-echo-1" is invalid:
    [spec.template.spec.containers[0].env[0].name: Invalid value:
    "test-abc": must be a C identifier (matching regex
    [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName",
    spec.template.spec.containers[1].env[0].name: Invalid value: "test-abc":
    must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.
    "my_name" or "MyName"]
    ```
    ##### After
    
    `$ kubectl set env rc/idling-echo-1 test-abc=1234`
    
    ```
    error: ReplicationController "idling-echo-1" is invalid:
    [spec.template.spec.containers[0].env[0].name: Invalid value:
    "test-abc": must be a C identifier (matching regex
    [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName",
    spec.template.spec.containers[1].env[0].name: Invalid value: "test-abc":
    must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.
    "my_name" or "MyName"]
    ```
    
    `$ kubectl set env rc/node-1 test-abc=1234`
    
    ```
    error: ReplicationController "node-1" is invalid:
    spec.template.spec.containers[0].env[0].name: Invalid value: "test-abc":
    must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.
    "my_name" or "MyName"
    ```
    bda57b8f
Name
Last commit
Last update
.github Loading commit data...
Godeps Loading commit data...
api Loading commit data...
build-tools Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
docs Loading commit data...
examples Loading commit data...
federation Loading commit data...
hack Loading commit data...
hooks Loading commit data...
logo Loading commit data...
pkg Loading commit data...
plugin Loading commit data...
staging Loading commit data...
test Loading commit data...
third_party Loading commit data...
vendor Loading commit data...
.gazelcfg.json Loading commit data...
.generated_docs Loading commit data...
.generated_files Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
BUILD Loading commit data...
CHANGELOG.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
Makefile.generated_files Loading commit data...
OWNERS Loading commit data...
OWNERS_ALIASES Loading commit data...
README.md Loading commit data...
Vagrantfile Loading commit data...
WORKSPACE Loading commit data...
code-of-conduct.md Loading commit data...
labels.yaml Loading commit data...