Introduce gvk package to isolate apimachinery schema.

This commit is contained in:
Jeffrey Regan
2018-09-25 16:57:31 -07:00
parent 8aa0cc145c
commit fb355eb320
38 changed files with 570 additions and 477 deletions

View File

@@ -20,7 +20,7 @@ import (
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/resource"
"sigs.k8s.io/kustomize/pkg/types"
@@ -59,7 +59,7 @@ func TestImageTagTransformer(t *testing.T) {
},
},
}),
resource.NewResId(schema.GroupVersionKind{Kind: "randomeKind"}, "random"): resource.NewResourceFromMap(
resource.NewResId(gvk.Gvk{Kind: "randomKind"}, "random"): resource.NewResourceFromMap(
map[string]interface{}{
"spec": map[string]interface{}{
"template": map[string]interface{}{
@@ -127,7 +127,7 @@ func TestImageTagTransformer(t *testing.T) {
},
},
}),
resource.NewResId(schema.GroupVersionKind{Kind: "randomeKind"}, "random"): resource.NewResourceFromMap(
resource.NewResId(gvk.Gvk{Kind: "randomKind"}, "random"): resource.NewResourceFromMap(
map[string]interface{}{
"spec": map[string]interface{}{
"template": map[string]interface{}{

View File

@@ -59,7 +59,7 @@ func (o *mapTransformer) Transform(m resmap.ResMap) error {
for id := range m {
objMap := m[id].UnstructuredContent()
for _, path := range o.pathConfigs {
if !selectByGVK(id.Gvk(), path.GroupVersionKind) {
if !id.Gvk().IsSelected(path.GroupVersionKind) {
continue
}
err := mutateField(objMap, path.Path, path.CreateIfNotPresent, o.addMap)

View File

@@ -20,25 +20,25 @@ import (
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/resource"
)
var service = schema.GroupVersionKind{Version: "v1", Kind: "Service"}
var secret = schema.GroupVersionKind{Version: "v1", Kind: "Secret"}
var cmap = schema.GroupVersionKind{Version: "v1", Kind: "ConfigMap"}
var ns = schema.GroupVersionKind{Version: "v1", Kind: "Namespace"}
var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
var statefulset = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "StatefulSet"}
var foo = schema.GroupVersionKind{Group: "example.com", Version: "v1", Kind: "Foo"}
var crd = schema.GroupVersionKind{Group: "apiwctensions.k8s.io", Version: "v1beta1", Kind: "CustomResourceDefinition"}
var job = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}
var cronjob = schema.GroupVersionKind{Group: "batch", Version: "v1beta1", Kind: "CronJob"}
var pvc = schema.GroupVersionKind{Version: "v1", Kind: "PersistentVolumeClaim"}
var crb = schema.GroupVersionKind{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"}
var sa = schema.GroupVersionKind{Version: "v1", Kind: "ServiceAccount"}
var ingress = schema.GroupVersionKind{Kind: "Ingress"}
var service = gvk.Gvk{Version: "v1", Kind: "Service"}
var secret = gvk.Gvk{Version: "v1", Kind: "Secret"}
var cmap = gvk.Gvk{Version: "v1", Kind: "ConfigMap"}
var ns = gvk.Gvk{Version: "v1", Kind: "Namespace"}
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
var statefulset = gvk.Gvk{Group: "apps", Version: "v1", Kind: "StatefulSet"}
var foo = gvk.Gvk{Group: "example.com", Version: "v1", Kind: "Foo"}
var crd = gvk.Gvk{Group: "apiwctensions.k8s.io", Version: "v1beta1", Kind: "CustomResourceDefinition"}
var job = gvk.Gvk{Group: "batch", Version: "v1", Kind: "Job"}
var cronjob = gvk.Gvk{Group: "batch", Version: "v1beta1", Kind: "CronJob"}
var pvc = gvk.Gvk{Version: "v1", Kind: "PersistentVolumeClaim"}
var crb = gvk.Gvk{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBinding"}
var sa = gvk.Gvk{Version: "v1", Kind: "ServiceAccount"}
var ingress = gvk.Gvk{Kind: "Ingress"}
func TestLabelsRun(t *testing.T) {
m := resmap.ResMap{
@@ -568,7 +568,7 @@ func TestAddPathConfigs(t *testing.T) {
lexpected := len(defaultLabelsPathConfigs) + 1
pathConfigs := []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{Group: "GroupA", Kind: "KindB"},
GroupVersionKind: &gvk.Gvk{Group: "GroupA", Kind: "KindB"},
Path: []string{"path", "to", "a", "field"},
CreateIfNotPresent: true,
},

View File

@@ -17,7 +17,7 @@ limitations under the License.
package transformers
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
)
// defaultLabelsPathConfigs is the default configuration for mutating labels and
@@ -28,149 +28,149 @@ var defaultLabelsPathConfigs = []PathConfig{
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Version: "v1", Kind: "Service"},
GroupVersionKind: &gvk.Gvk{Version: "v1", Kind: "Service"},
Path: []string{"spec", "selector"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"},
GroupVersionKind: &gvk.Gvk{Version: "v1", Kind: "ReplicationController"},
Path: []string{"spec", "selector"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"},
GroupVersionKind: &gvk.Gvk{Version: "v1", Kind: "ReplicationController"},
Path: []string{"spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "selector", "matchLabels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "affinity", "podAffinity",
"preferredDuringSchedulingIgnoredDuringExecution",
"podAffinityTerm", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "affinity", "podAffinity",
"requiredDuringSchedulingIgnoredDuringExecution", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "affinity", "podAntiAffinity",
"preferredDuringSchedulingIgnoredDuringExecution",
"podAffinityTerm", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "affinity", "podAntiAffinity",
"requiredDuringSchedulingIgnoredDuringExecution", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "ReplicaSet"},
GroupVersionKind: &gvk.Gvk{Kind: "ReplicaSet"},
Path: []string{"spec", "selector", "matchLabels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "ReplicaSet"},
GroupVersionKind: &gvk.Gvk{Kind: "ReplicaSet"},
Path: []string{"spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "DaemonSet"},
GroupVersionKind: &gvk.Gvk{Kind: "DaemonSet"},
Path: []string{"spec", "selector", "matchLabels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "DaemonSet"},
GroupVersionKind: &gvk.Gvk{Kind: "DaemonSet"},
Path: []string{"spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "selector", "matchLabels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "affinity", "podAffinity",
"preferredDuringSchedulingIgnoredDuringExecution",
"podAffinityTerm", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "affinity", "podAffinity",
"requiredDuringSchedulingIgnoredDuringExecution", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "affinity", "podAntiAffinity",
"preferredDuringSchedulingIgnoredDuringExecution",
"podAffinityTerm", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "affinity", "podAntiAffinity",
"requiredDuringSchedulingIgnoredDuringExecution", "labelSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "Job"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "Job"},
Path: []string{"spec", "selector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "Job"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "Job"},
Path: []string{"spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "spec", "selector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "spec", "template", "metadata", "labels"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "policy", Kind: "PodDisruptionBudget"},
GroupVersionKind: &gvk.Gvk{Group: "policy", Kind: "PodDisruptionBudget"},
Path: []string{"spec", "selector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "networking.k8s.io", Kind: "NetworkPolicy"},
GroupVersionKind: &gvk.Gvk{Group: "networking.k8s.io", Kind: "NetworkPolicy"},
Path: []string{"spec", "podSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "networking.k8s.io", Kind: "NetworkPolicy"},
GroupVersionKind: &gvk.Gvk{Group: "networking.k8s.io", Kind: "NetworkPolicy"},
Path: []string{"spec", "ingress", "from", "podSelector", "matchLabels"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "networking.k8s.io", Kind: "NetworkPolicy"},
GroupVersionKind: &gvk.Gvk{Group: "networking.k8s.io", Kind: "NetworkPolicy"},
Path: []string{"spec", "egress", "to", "podSelector", "matchLabels"},
CreateIfNotPresent: false,
},
@@ -184,42 +184,42 @@ var defaultAnnotationsPathConfigs = []PathConfig{
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"},
GroupVersionKind: &gvk.Gvk{Version: "v1", Kind: "ReplicationController"},
Path: []string{"spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "ReplicaSet"},
GroupVersionKind: &gvk.Gvk{Kind: "ReplicaSet"},
Path: []string{"spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "DaemonSet"},
GroupVersionKind: &gvk.Gvk{Kind: "DaemonSet"},
Path: []string{"spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "apps", Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Group: "apps", Kind: "StatefulSet"},
Path: []string{"spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "Job"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "Job"},
Path: []string{"spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "metadata", "annotations"},
CreateIfNotPresent: true,
},
{
GroupVersionKind: &schema.GroupVersionKind{Group: "batch", Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Group: "batch", Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "spec", "template", "metadata", "annotations"},
CreateIfNotPresent: true,
},

View File

@@ -21,7 +21,7 @@ import (
"fmt"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/hash"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/resource"
@@ -43,13 +43,13 @@ func (o *nameHashTransformer) Transform(m resmap.ResMap) error {
for id, res := range m {
if res.IsGenerated() {
switch {
case selectByGVK(id.Gvk(), &schema.GroupVersionKind{Version: "v1", Kind: "ConfigMap"}):
case id.Gvk().IsSelected(&gvk.Gvk{Version: "v1", Kind: "ConfigMap"}):
err := appendHashForConfigMap(res)
if err != nil {
return err
}
case selectByGVK(id.Gvk(), &schema.GroupVersionKind{Version: "v1", Kind: "Secret"}):
case id.Gvk().IsSelected(&gvk.Gvk{Version: "v1", Kind: "Secret"}):
err := appendHashForSecret(res)
if err != nil {
return err

View File

@@ -20,7 +20,7 @@ import (
"errors"
"fmt"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/resource"
)
@@ -55,7 +55,7 @@ func (o *nameReferenceTransformer) Transform(m resmap.ResMap) error {
objMap := m[id].UnstructuredContent()
for _, referencePathConfig := range o.pathConfigs {
for _, path := range referencePathConfig.pathConfigs {
if !selectByGVK(id.Gvk(), path.GroupVersionKind) {
if !id.Gvk().IsSelected(path.GroupVersionKind) {
continue
}
err := mutateField(objMap, path.Path, path.CreateIfNotPresent,
@@ -70,7 +70,7 @@ func (o *nameReferenceTransformer) Transform(m resmap.ResMap) error {
}
func (o *nameReferenceTransformer) updateNameReference(
GVK schema.GroupVersionKind, m resmap.ResMap) func(in interface{}) (interface{}, error) {
k gvk.Gvk, m resmap.ResMap) func(in interface{}) (interface{}, error) {
return func(in interface{}) (interface{}, error) {
s, ok := in.(string)
if !ok {
@@ -78,7 +78,7 @@ func (o *nameReferenceTransformer) updateNameReference(
}
for id, res := range m {
if !selectByGVK(id.Gvk(), &GVK) {
if !id.Gvk().IsSelected(&k) {
continue
}
if id.Name() == s {

View File

@@ -20,7 +20,7 @@ import (
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/resource"
)
@@ -342,12 +342,12 @@ func TestAddNameReferencePathConfigs(t *testing.T) {
pathConfigs := []ReferencePathConfig{
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Kind: "KindA",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "KindB",
},
Path: []string{"path", "to", "a", "field"},

View File

@@ -17,19 +17,19 @@ limitations under the License.
package transformers
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
)
// defaultNameReferencePathConfigs is the default configuration for updating
// the fields reference the name of other resources.
var defaultNameReferencePathConfigs = []ReferencePathConfig{
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Kind: "Deployment",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "HorizontalPodAutoscaler",
},
Path: []string{"spec", "scaleTargetRef", "name"},
@@ -38,12 +38,12 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Kind: "ReplicationController",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "HorizontalPodAutoscaler",
},
Path: []string{"spec", "scaleTargetRef", "name"},
@@ -52,12 +52,12 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Kind: "ReplicaSet",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "HorizontalPodAutoscaler",
},
Path: []string{"spec", "scaleTargetRef", "name"},
@@ -66,13 +66,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Version: "v1",
Kind: "ConfigMap",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -80,7 +80,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -88,7 +88,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -96,7 +96,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -104,7 +104,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -112,224 +112,224 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "volumes", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "volumes", "projected", "sources", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "volumes", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "volumes", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "volumes", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "volumes", "projected", "sources", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "volumes", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "volumes", "configMap", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "initContainers", "env", "valueFrom", "configMapKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "envFrom", "configMapRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "initContainers", "envFrom", "configMapRef", "name"},
@@ -338,13 +338,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Version: "v1",
Kind: "Secret",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -352,7 +352,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -360,7 +360,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -368,7 +368,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -376,7 +376,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -384,7 +384,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Version: "v1",
Kind: "Pod",
},
@@ -392,308 +392,308 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "volumes", "secret", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "volumes", "secret", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicaSet",
},
Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "volumes", "secret", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "volumes", "secret", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "volumes", "secret", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "containers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "initContainers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "containers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "volumes", "secret", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "initContainers", "env", "valueFrom", "secretKeyRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "initContainers", "envFrom", "secretRef", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Ingress",
},
Path: []string{"spec", "tls", "secretName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Ingress",
},
Path: []string{"metadata", "annotations", "ingress.kubernetes.io/auth-secret"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Ingress",
},
Path: []string{"metadata", "annotations", "nginx.ingress.kubernetes.io/auth-secret"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ServiceAccount",
},
Path: []string{"imagePullSecrets", "name"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StorageClass",
},
Path: []string{"parameters", "secretName"}, // This is for Glusterfs,
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StorageClass",
},
Path: []string{"parameters", "adminSecretName"}, // This is for Quobyte, CephRBD, StorageOS
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StorageClass",
},
Path: []string{"parameters", "userSecretName"}, // This is for CephRBD
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StorageClass",
},
Path: []string{"parameters", "secretRef"}, // This is for ScaleIO
@@ -703,13 +703,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
{
// StatefulSet references headless service, so need to update the references.
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Version: "v1",
Kind: "Service",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Group: "apps",
Kind: "StatefulSet",
},
@@ -717,14 +717,14 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Ingress",
},
Path: []string{"spec", "rules", "http", "paths", "backend", "serviceName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Ingress",
},
Path: []string{"spec", "backend", "serviceName"},
@@ -733,13 +733,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "Role",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "RoleBinding",
},
@@ -749,13 +749,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "RoleBinding",
},
@@ -763,7 +763,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "ClusterRoleBinding",
},
@@ -773,13 +773,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Version: "v1",
Kind: "ServiceAccount",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "RoleBinding",
},
@@ -787,7 +787,7 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Group: "rbac.authorization.k8s.io",
Kind: "ClusterRoleBinding",
},
@@ -795,49 +795,49 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Pod",
},
Path: []string{"spec", "serviceAccountName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "serviceAccountName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "serviceAccountName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicationController",
},
Path: []string{"spec", "template", "spec", "serviceAccountName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "serviceAccountName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "serviceAccountName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "serviceAccountName"},
@@ -846,55 +846,55 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Version: "v1",
Kind: "PersistentVolumeClaim",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Pod",
},
Path: []string{"spec", "volumes", "persistentVolumeClaim", "claimName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "StatefulSet",
},
Path: []string{"spec", "template", "spec", "volumes", "persistentVolumeClaim", "claimName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Deployment",
},
Path: []string{"spec", "template", "spec", "volumes", "persistentVolumeClaim", "claimName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ReplicationController",
},
Path: []string{"spec", "template", "spec", "volumes", "persistentVolumeClaim", "claimName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CronJob",
},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "volumes", "persistentVolumeClaim", "claimName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Job",
},
Path: []string{"spec", "template", "spec", "volumes", "persistentVolumeClaim", "claimName"},
CreateIfNotPresent: false,
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "DaemonSet",
},
Path: []string{"spec", "template", "spec", "volumes", "persistentVolumeClaim", "claimName"},
@@ -903,13 +903,13 @@ var defaultNameReferencePathConfigs = []ReferencePathConfig{
},
},
{
referencedGVK: schema.GroupVersionKind{
referencedGVK: gvk.Gvk{
Version: "v1",
Kind: "PersistentVolume",
},
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "PersistentVolumeClaim",
},
Path: []string{"spec", "volumeName"},

View File

@@ -17,7 +17,7 @@ limitations under the License.
package transformers
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
)
@@ -36,22 +36,22 @@ var namespacePathConfigs = []PathConfig{
var skipNamespacePathConfigs = []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "Namespace",
},
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ClusterRoleBinding",
},
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "ClusterRole",
},
},
{
GroupVersionKind: &schema.GroupVersionKind{
GroupVersionKind: &gvk.Gvk{
Kind: "CustomResourceDefinition",
},
},
@@ -79,7 +79,7 @@ func (o *namespaceTransformer) Transform(m resmap.ResMap) error {
for id := range m {
found := false
for _, path := range o.skipPathConfigs {
if selectByGVK(id.Gvk(), path.GroupVersionKind) {
if id.Gvk().IsSelected(path.GroupVersionKind) {
found = true
break
}
@@ -93,7 +93,7 @@ func (o *namespaceTransformer) Transform(m resmap.ResMap) error {
for id := range mf {
objMap := mf[id].UnstructuredContent()
for _, path := range o.pathConfigs {
if !selectByGVK(id.Gvk(), path.GroupVersionKind) {
if !id.Gvk().IsSelected(path.GroupVersionKind) {
continue
}
@@ -114,9 +114,8 @@ func (o *namespaceTransformer) Transform(m resmap.ResMap) error {
func (o *namespaceTransformer) updateClusterRoleBinding(m resmap.ResMap) {
saMap := map[string]bool{}
saGVK := schema.GroupVersionKind{Version: "v1", Kind: "ServiceAccount"}
for id := range m {
if id.Gvk().String() == saGVK.String() {
if id.Gvk().Equals(gvk.Gvk{Version: "v1", Kind: "ServiceAccount"}) {
saMap[id.Name()] = true
}
}

View File

@@ -65,7 +65,7 @@ func (pt *patchTransformer) Transform(baseResourceMap resmap.ResMap) error {
id = matchedIds[0]
base := baseResourceMap[id]
merged := map[string]interface{}{}
versionedObj, err := scheme.Scheme.New(id.Gvk())
versionedObj, err := scheme.Scheme.New(id.Gvk().ToSchemaGvk())
baseName := base.GetName()
switch {
case runtime.IsNotRegisteredError(err):
@@ -123,7 +123,7 @@ func (pt *patchTransformer) mergePatches() (resmap.ResMap, error) {
continue
}
versionedObj, err := scheme.Scheme.New(id.Gvk())
versionedObj, err := scheme.Scheme.New(id.Gvk().ToSchemaGvk())
if err != nil && !runtime.IsNotRegisteredError(err) {
return nil, err
}

View File

@@ -17,7 +17,7 @@ limitations under the License.
package transformers
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
)
// PathConfig contains the configuration of a field, including the gvk it ties to,
@@ -28,7 +28,7 @@ type PathConfig struct {
// The gvk that this path tied to.
// If unset, it applied to any gvk
// If some fields are set, it applies to all matching gvk.
GroupVersionKind *schema.GroupVersionKind
GroupVersionKind *gvk.Gvk
// Path to the field that will be munged.
Path []string
}
@@ -49,15 +49,15 @@ type PathConfig struct {
type ReferencePathConfig struct {
// referencedGVK is the GroupVersionKind that is referenced by
// the PathConfig's gvk in the path of PathConfig.Path.
referencedGVK schema.GroupVersionKind
referencedGVK gvk.Gvk
// PathConfig is the gvk that is referencing the referencedGVK object's name.
pathConfigs []PathConfig
}
// NewReferencePathConfig creates a new ReferencePathConfig object
func NewReferencePathConfig(gvk schema.GroupVersionKind, pathconfigs []PathConfig) ReferencePathConfig {
func NewReferencePathConfig(k gvk.Gvk, pathconfigs []PathConfig) ReferencePathConfig {
return ReferencePathConfig{
referencedGVK: gvk,
referencedGVK: k,
pathConfigs: pathconfigs,
}
}

View File

@@ -21,9 +21,8 @@ import (
"fmt"
"log"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// namePrefixTransformer contains the prefix and the path config for each field that
@@ -45,13 +44,13 @@ var defaultNamePrefixPathConfigs = []PathConfig{
var skipNamePrefixPathConfigs = []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "CustomResourceDefinition"},
GroupVersionKind: &gvk.Gvk{Kind: "CustomResourceDefinition"},
},
}
// deprecateNamePrefixPathConfig will be moved into skipNamePrefixPathConfigs in next release
var deprecateNamePrefixPathConfig = PathConfig{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Namespace"},
GroupVersionKind: &gvk.Gvk{Kind: "Namespace"},
}
// NewDefaultingNamePrefixTransformer construct a namePrefixTransformer with defaultNamePrefixPathConfigs.
@@ -77,7 +76,7 @@ func (o *namePrefixTransformer) Transform(m resmap.ResMap) error {
for id := range m {
found := false
for _, path := range o.skipPathConfigs {
if selectByGVK(id.Gvk(), path.GroupVersionKind) {
if id.Gvk().IsSelected(path.GroupVersionKind) {
found = true
break
}
@@ -89,12 +88,12 @@ func (o *namePrefixTransformer) Transform(m resmap.ResMap) error {
}
for id := range mf {
if selectByGVK(id.Gvk(), deprecateNamePrefixPathConfig.GroupVersionKind) {
if id.Gvk().IsSelected(deprecateNamePrefixPathConfig.GroupVersionKind) {
log.Println("Adding nameprefix to Namespace resource will be deprecated in next release.")
}
objMap := mf[id].UnstructuredContent()
for _, path := range o.pathConfigs {
if !selectByGVK(id.Gvk(), path.GroupVersionKind) {
if !id.Gvk().IsSelected(path.GroupVersionKind) {
continue
}
err := mutateField(objMap, path.Path, path.CreateIfNotPresent, o.addPrefix)

View File

@@ -20,7 +20,7 @@ import (
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/resource"
)
@@ -98,7 +98,7 @@ func TestAddPrefixPathConfigs(t *testing.T) {
pathConfigs := []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{Group: "GroupA", Kind: "KindB"},
GroupVersionKind: &gvk.Gvk{Group: "GroupA", Kind: "KindB"},
Path: []string{"path", "to", "a", "field"},
CreateIfNotPresent: true,
},

View File

@@ -3,8 +3,8 @@ package transformers
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/pkg/expansion"
"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
)
@@ -19,87 +19,87 @@ func NewRefVarTransformer(vars map[string]string) (Transformer, error) {
vars: vars,
pathConfigs: []PathConfig{
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "initContainers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "containers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "initContainers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "containers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"},
GroupVersionKind: &gvk.Gvk{Kind: "Job"},
Path: []string{"spec", "template", "spec", "containers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "initContainers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "containers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "initContainers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "containers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"},
GroupVersionKind: &gvk.Gvk{Kind: "Job"},
Path: []string{"spec", "template", "spec", "containers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "initContainers", "env", "value"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"},
GroupVersionKind: &gvk.Gvk{Kind: "StatefulSet"},
Path: []string{"spec", "template", "spec", "containers", "env", "value"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "initContainers", "env", "value"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"},
GroupVersionKind: &gvk.Gvk{Kind: "Deployment"},
Path: []string{"spec", "template", "spec", "containers", "env", "value"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"},
GroupVersionKind: &gvk.Gvk{Kind: "Job"},
Path: []string{"spec", "template", "spec", "containers", "env", "value"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "CronJob"},
GroupVersionKind: &gvk.Gvk{Kind: "CronJob"},
Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "env", "value"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Pod"},
GroupVersionKind: &gvk.Gvk{Kind: "Pod"},
Path: []string{"spec", "containers", "command"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Pod"},
GroupVersionKind: &gvk.Gvk{Kind: "Pod"},
Path: []string{"spec", "containers", "args"},
},
{
GroupVersionKind: &schema.GroupVersionKind{Kind: "Pod"},
GroupVersionKind: &gvk.Gvk{Kind: "Pod"},
Path: []string{"spec", "containers", "env", "value"},
},
},
@@ -116,10 +116,10 @@ func NewRefVarTransformer(vars map[string]string) (Transformer, error) {
// 2. Create the container's environment in the order variables are declared
// 3. Add remaining service environment vars
func (rv *refvarTransformer) Transform(resources resmap.ResMap) error {
for GVKn := range resources {
objMap := resources[GVKn].UnstructuredContent()
for resId := range resources {
objMap := resources[resId].UnstructuredContent()
for _, pc := range rv.pathConfigs {
if !selectByGVK(GVKn.Gvk(), pc.GroupVersionKind) {
if !resId.Gvk().IsSelected(pc.GroupVersionKind) {
continue
}
err := mutateField(objMap, pc.Path, false, func(in interface{}) (interface{}, error) {

View File

@@ -1,50 +0,0 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package transformers
import (
"k8s.io/apimachinery/pkg/runtime/schema"
)
// selectByGVK returns true if `selector` selects `in`; otherwise, false.
// If `selector` and `in` are the same, return true.
// If `selector` is nil, it is considered as a wildcard and always return true.
// e.g. selector <Group: "", Version: "", Kind: "Deployment"> CAN select
// <Group: "extensions", Version: "v1beta1", Kind: "Deployment">.
// selector <Group: "apps", Version: "", Kind: "Deployment"> CANNOT select
// <Group: "extensions", Version: "v1beta1", Kind: "Deployment">.
func selectByGVK(in schema.GroupVersionKind, selector *schema.GroupVersionKind) bool {
if selector == nil {
return true
}
if len(selector.Group) > 0 {
if in.Group != selector.Group {
return false
}
}
if len(selector.Version) > 0 {
if in.Version != selector.Version {
return false
}
}
if len(selector.Kind) > 0 {
if in.Kind != selector.Kind {
return false
}
}
return true
}

View File

@@ -1,131 +0,0 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package transformers
import (
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
)
func TestSelectByGVK(t *testing.T) {
type testCase struct {
description string
in schema.GroupVersionKind
filter *schema.GroupVersionKind
expected bool
}
testCases := []testCase{
{
description: "nil filter",
in: schema.GroupVersionKind{},
filter: nil,
expected: true,
},
{
description: "gvk matches",
in: schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
filter: &schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
expected: true,
},
{
description: "group doesn't matches",
in: schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
filter: &schema.GroupVersionKind{
Group: "group2",
Version: "version1",
Kind: "kind1",
},
expected: false,
},
{
description: "version doesn't matches",
in: schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
filter: &schema.GroupVersionKind{
Group: "group1",
Version: "version2",
Kind: "kind1",
},
expected: false,
},
{
description: "kind doesn't matches",
in: schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
filter: &schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind2",
},
expected: false,
},
{
description: "no version in filter",
in: schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
filter: &schema.GroupVersionKind{
Group: "group1",
Version: "",
Kind: "kind1",
},
expected: true,
},
{
description: "only kind is set in filter",
in: schema.GroupVersionKind{
Group: "group1",
Version: "version1",
Kind: "kind1",
},
filter: &schema.GroupVersionKind{
Group: "",
Version: "",
Kind: "kind1",
},
expected: true,
},
}
for _, tc := range testCases {
filtered := selectByGVK(tc.in, tc.filter)
if filtered != tc.expected {
t.Fatalf("unexpected filter result for test case: %v", tc.description)
}
}
}