From 5d24dda28a5588bf81fc82de7b5829324826468e Mon Sep 17 00:00:00 2001 From: Seth Pollack Date: Wed, 20 Jun 2018 23:20:28 -0400 Subject: [PATCH 1/2] add imagePullSecrets namerefs --- pkg/transformers/namereferenceconfig.go | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/pkg/transformers/namereferenceconfig.go b/pkg/transformers/namereferenceconfig.go index 8494b31ec..b34380b93 100644 --- a/pkg/transformers/namereferenceconfig.go +++ b/pkg/transformers/namereferenceconfig.go @@ -369,6 +369,14 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Version: "v1", + Kind: "Pod", + }, + Path: []string{"spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "Deployment", @@ -404,6 +412,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "Deployment", + }, + Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "ReplicaSet", @@ -439,6 +454,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "ReplicaSet", + }, + Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "DaemonSet", @@ -474,6 +496,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "DaemonSet", + }, + Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "StatefulSet", @@ -509,6 +538,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "StatefulSet", + }, + Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "Job", @@ -544,6 +580,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "Job", + }, + Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "CronJob", @@ -579,6 +622,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "CronJob", + }, + Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, { GroupVersionKind: &schema.GroupVersionKind{ Kind: "Ingress", @@ -586,6 +636,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{ Path: []string{"spec", "tls", "secretName"}, CreateIfNotPresent: false, }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "ServiceAccount", + }, + Path: []string{"imagePullSecrets", "name"}, + CreateIfNotPresent: false, + }, }, }, { From bbd29d9dc1604ef666540dd799dbc89e0674eee9 Mon Sep 17 00:00:00 2001 From: Seth Pollack Date: Thu, 21 Jun 2018 23:17:03 -0400 Subject: [PATCH 2/2] add test --- pkg/transformers/namereference_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/transformers/namereference_test.go b/pkg/transformers/namereference_test.go index 455246855..98f6e9fea 100644 --- a/pkg/transformers/namereference_test.go +++ b/pkg/transformers/namereference_test.go @@ -94,6 +94,11 @@ func TestNameReferenceRun(t *testing.T) { }, }, }, + "imagePullSecrets": []interface{}{ + map[string]interface{}{ + "name": "secret1", + }, + }, "volumes": map[string]interface{}{ "configMap": map[string]interface{}{ "name": "cm1", @@ -176,6 +181,11 @@ func TestNameReferenceRun(t *testing.T) { }, }, }, + "imagePullSecrets": []interface{}{ + map[string]interface{}{ + "name": "someprefix-secret1-somehash", + }, + }, "volumes": map[string]interface{}{ "configMap": map[string]interface{}{ "name": "someprefix-cm1-somehash",