Merge pull request #42083 from fraenkel/validate_name

Automatic merge from submit-queue (batch tested with PRs 42038, 42083)

Validate ConfigMapRef and SecretRef name

fixes #42037

**Release note**:
```release-note
When creating a container using envFrom,
1. validate the name of the ConfigMap in a ConfigMapRef
2. validate the name of the Secret in a SecretRef
```
This commit is contained in:
Kubernetes Submit Queue
2017-04-03 04:07:21 -07:00
committed by GitHub
2 changed files with 28 additions and 0 deletions

View File

@@ -2415,6 +2415,16 @@ func TestValidateEnvFrom(t *testing.T) {
},
expectedError: "field[0].configMapRef.name: Required value",
},
{
name: "invalid name",
envs: []api.EnvFromSource{
{
ConfigMapRef: &api.ConfigMapEnvSource{
LocalObjectReference: api.LocalObjectReference{Name: "$"}},
},
},
expectedError: "field[0].configMapRef.name: Invalid value",
},
{
name: "invalid prefix",
envs: []api.EnvFromSource{
@@ -2436,6 +2446,16 @@ func TestValidateEnvFrom(t *testing.T) {
},
expectedError: "field[0].secretRef.name: Required value",
},
{
name: "invalid name",
envs: []api.EnvFromSource{
{
SecretRef: &api.SecretEnvSource{
LocalObjectReference: api.LocalObjectReference{Name: "&"}},
},
},
expectedError: "field[0].secretRef.name: Invalid value",
},
{
name: "invalid prefix",
envs: []api.EnvFromSource{