Interpret projected configMap volume names

Append hashes to configMap names under the projected configMap volume,
for Kind: Deployment and StatefulSet
This commit is contained in:
George Angel
2018-07-11 10:28:57 +01:00
parent 3305be9589
commit aa729229e2
3 changed files with 105 additions and 0 deletions

View File

@@ -35,6 +35,14 @@ func TestNameReferenceRun(t *testing.T) {
"name": "someprefix-cm1-somehash",
},
}),
resource.NewResId(cmap, "cm2"): resource.NewResourceFromMap(
map[string]interface{}{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": "someprefix-cm2-somehash",
},
}),
resource.NewResId(secret, "secret1"): resource.NewResourceFromMap(
map[string]interface{}{
"apiVersion": "v1",
@@ -111,6 +119,13 @@ func TestNameReferenceRun(t *testing.T) {
"configMap": map[string]interface{}{
"name": "cm1",
},
"projected": map[string]interface{}{
"sources": map[string]interface{}{
"configMap": map[string]interface{}{
"name": "cm2",
},
},
},
"secret": map[string]interface{}{
"secretName": "secret1",
},
@@ -122,6 +137,36 @@ func TestNameReferenceRun(t *testing.T) {
},
},
}),
resource.NewResId(statefulset, "statefulset1"): resource.NewResourceFromMap(
map[string]interface{}{
"group": "apps",
"apiVersion": "v1",
"kind": "StatefulSet",
"metadata": map[string]interface{}{
"name": "statefulset1",
},
"spec": map[string]interface{}{
"template": map[string]interface{}{
"spec": map[string]interface{}{
"containers": []interface{}{
map[string]interface{}{
"name": "nginx",
"image": "nginx:1.7.9",
},
},
"volumes": map[string]interface{}{
"projected": map[string]interface{}{
"sources": map[string]interface{}{
"configMap": map[string]interface{}{
"name": "cm2",
},
},
},
},
},
},
},
}),
}
expected := resmap.ResMap{
@@ -133,6 +178,14 @@ func TestNameReferenceRun(t *testing.T) {
"name": "someprefix-cm1-somehash",
},
}),
resource.NewResId(cmap, "cm2"): resource.NewResourceFromMap(
map[string]interface{}{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": "someprefix-cm2-somehash",
},
}),
resource.NewResId(secret, "secret1"): resource.NewResourceFromMap(
map[string]interface{}{
"apiVersion": "v1",
@@ -209,6 +262,13 @@ func TestNameReferenceRun(t *testing.T) {
"configMap": map[string]interface{}{
"name": "someprefix-cm1-somehash",
},
"projected": map[string]interface{}{
"sources": map[string]interface{}{
"configMap": map[string]interface{}{
"name": "someprefix-cm2-somehash",
},
},
},
"secret": map[string]interface{}{
"secretName": "someprefix-secret1-somehash",
},
@@ -220,6 +280,36 @@ func TestNameReferenceRun(t *testing.T) {
},
},
}),
resource.NewResId(statefulset, "statefulset1"): resource.NewResourceFromMap(
map[string]interface{}{
"group": "apps",
"apiVersion": "v1",
"kind": "StatefulSet",
"metadata": map[string]interface{}{
"name": "statefulset1",
},
"spec": map[string]interface{}{
"template": map[string]interface{}{
"spec": map[string]interface{}{
"containers": []interface{}{
map[string]interface{}{
"name": "nginx",
"image": "nginx:1.7.9",
},
},
"volumes": map[string]interface{}{
"projected": map[string]interface{}{
"sources": map[string]interface{}{
"configMap": map[string]interface{}{
"name": "someprefix-cm2-somehash",
},
},
},
},
},
},
},
}),
}
nrt, err := NewDefaultingNameReferenceTransformer()