Permalink
Browse files

Merge pull request #71955 from apelisse/automated-cherry-pick-of-#719…

…23-upstream-release-1.13

Automated cherry pick of #71923: diff: Fix overlapping filenames
  • Loading branch information...
k8s-ci-robot committed Dec 12, 2018
2 parents 1c51137 + 4980403 commit eec55b9ba98609a46fee712359c7b5b365bdd920
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
spec:
replicas: 3
selector:
matchLabels:
name: test
template:
metadata:
labels:
name: test
spec:
containers:
- name: nginx
image: nginx
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- name: nginx
image: nginx
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Secret
metadata:
name: test
@@ -289,7 +289,17 @@ func (obj InfoObject) Merged() (runtime.Object, error) {
}

func (obj InfoObject) Name() string {
return obj.Info.Name
group := ""
if obj.Info.Mapping.GroupVersionKind.Group != "" {
group = fmt.Sprintf("%v.", obj.Info.Mapping.GroupVersionKind.Group)
}
return group + fmt.Sprintf(
"%v.%v.%v.%v",
obj.Info.Mapping.GroupVersionKind.Version,
obj.Info.Mapping.GroupVersionKind.Kind,
obj.Info.Namespace,
obj.Info.Name,
)
}

// Differ creates two DiffVersion and diffs them.
@@ -40,3 +40,20 @@ run_kubectl_diff_tests() {
set +o nounset
set +o errexit
}

run_kubectl_diff_same_names() {
set -o nounset
set -o errexit

create_and_use_new_namespace
kube::log::status "Test kubectl diff with multiple resources with the same name"

output_message=$(KUBECTL_EXTERNAL_DIFF=find kubectl diff -Rf hack/testdata/diff/)
kube::test::if_has_string "${output_message}" 'v1\.Pod\..*\.test'
kube::test::if_has_string "${output_message}" 'apps\.v1\.Deployment\..*\.test'
kube::test::if_has_string "${output_message}" 'v1\.ConfigMap\..*\.test'
kube::test::if_has_string "${output_message}" 'v1\.Secret\..*\.test'

set +o nounset
set +o errexit
}
@@ -473,6 +473,7 @@ runTests() {
# Kubectl diff #
################
record_command run_kubectl_diff_tests
record_command run_kubectl_diff_same_names

###############
# Kubectl get #

0 comments on commit eec55b9

Please sign in to comment.