Skip to content

Commit af486d5

Browse files
laxmikantbpandhareYour Name
authored andcommitted
rebase
Rebase laxmikantbpandhare commits on top of master
1 parent 616c084 commit af486d5

File tree

6 files changed

+266
-156
lines changed

6 files changed

+266
-156
lines changed

api/internal/builtins/PatchJson6902Transformer.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/internal/builtins/PatchTransformer.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/krusty/extendedpatch_test.go

Lines changed: 46 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package krusty_test
66
import (
77
"testing"
88

9+
"github.com/stretchr/testify/assert"
910
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
1011
)
1112

@@ -821,82 +822,8 @@ metadata:
821822
annotations:
822823
new-key: new-value
823824
`)
824-
m := th.Run("base", th.MakeDefaultOptions())
825-
th.AssertActualEqualsExpected(m, `
826-
apiVersion: apps/v1
827-
kind: Deployment
828-
metadata:
829-
labels:
830-
app: nginx
831-
name: nginx
832-
spec:
833-
template:
834-
metadata:
835-
labels:
836-
app: nginx
837-
spec:
838-
containers:
839-
- image: nginx
840-
name: nginx
841-
volumeMounts:
842-
- mountPath: /tmp/ps
843-
name: nginx-persistent-storage
844-
volumes:
845-
- emptyDir: {}
846-
name: nginx-persistent-storage
847-
- configMap:
848-
name: configmap-in-base
849-
name: configmap-in-base
850-
---
851-
apiVersion: apps/v1
852-
kind: Deployment
853-
metadata:
854-
labels:
855-
app: busybox
856-
name: busybox
857-
spec:
858-
template:
859-
metadata:
860-
labels:
861-
app: busybox
862-
spec:
863-
containers:
864-
- image: busybox
865-
name: busybox
866-
volumeMounts:
867-
- mountPath: /tmp/ps
868-
name: busybox-persistent-storage
869-
volumes:
870-
- emptyDir: {}
871-
name: busybox-persistent-storage
872-
- configMap:
873-
name: configmap-in-base
874-
name: configmap-in-base
875-
---
876-
apiVersion: v1
877-
kind: Service
878-
metadata:
879-
labels:
880-
app: nginx
881-
name: nginx
882-
spec:
883-
ports:
884-
- port: 80
885-
selector:
886-
app: nginx
887-
---
888-
apiVersion: v1
889-
kind: Service
890-
metadata:
891-
labels:
892-
app: busybox
893-
name: busybox
894-
spec:
895-
ports:
896-
- port: 8080
897-
selector:
898-
app: busybox
899-
`)
825+
err := th.RunWithErr("base", th.MakeDefaultOptions())
826+
assert.Contains(t, err.Error(), "patches target not found for [noKind].[noVer].[noGrp]/no-match.[noNs]")
900827
}
901828

902829
func TestExtendedPatchWithoutTarget(t *testing.T) {
@@ -1021,82 +948,8 @@ metadata:
1021948
annotations:
1022949
new-key: new-value
1023950
`)
1024-
m := th.Run("base", th.MakeDefaultOptions())
1025-
th.AssertActualEqualsExpected(m, `
1026-
apiVersion: apps/v1
1027-
kind: Deployment
1028-
metadata:
1029-
labels:
1030-
app: nginx
1031-
name: nginx
1032-
spec:
1033-
template:
1034-
metadata:
1035-
labels:
1036-
app: nginx
1037-
spec:
1038-
containers:
1039-
- image: nginx
1040-
name: nginx
1041-
volumeMounts:
1042-
- mountPath: /tmp/ps
1043-
name: nginx-persistent-storage
1044-
volumes:
1045-
- emptyDir: {}
1046-
name: nginx-persistent-storage
1047-
- configMap:
1048-
name: configmap-in-base
1049-
name: configmap-in-base
1050-
---
1051-
apiVersion: apps/v1
1052-
kind: Deployment
1053-
metadata:
1054-
labels:
1055-
app: busybox
1056-
name: busybox
1057-
spec:
1058-
template:
1059-
metadata:
1060-
labels:
1061-
app: busybox
1062-
spec:
1063-
containers:
1064-
- image: busybox
1065-
name: busybox
1066-
volumeMounts:
1067-
- mountPath: /tmp/ps
1068-
name: busybox-persistent-storage
1069-
volumes:
1070-
- emptyDir: {}
1071-
name: busybox-persistent-storage
1072-
- configMap:
1073-
name: configmap-in-base
1074-
name: configmap-in-base
1075-
---
1076-
apiVersion: v1
1077-
kind: Service
1078-
metadata:
1079-
labels:
1080-
app: nginx
1081-
name: nginx
1082-
spec:
1083-
ports:
1084-
- port: 80
1085-
selector:
1086-
app: nginx
1087-
---
1088-
apiVersion: v1
1089-
kind: Service
1090-
metadata:
1091-
labels:
1092-
app: busybox
1093-
name: busybox
1094-
spec:
1095-
ports:
1096-
- port: 8080
1097-
selector:
1098-
app: busybox
1099-
`)
951+
err := th.RunWithErr("base", th.MakeDefaultOptions())
952+
assert.Contains(t, err.Error(), "patches target not found for [noKind].[noVer].[noGrp]/no-match.[noNs]")
1100953
}
1101954

1102955
func TestExtendedPatchMultiplePatchOverlapping(t *testing.T) {
@@ -1213,3 +1066,44 @@ spec:
12131066
app: busybox
12141067
`)
12151068
}
1069+
1070+
func TestTargetMissingPatchJson6902Error(t *testing.T) {
1071+
th := kusttest_test.MakeHarness(t)
1072+
makeCommonFileForExtendedPatchTest(th)
1073+
th.WriteK("base", `
1074+
resources:
1075+
- servicemonitor.yaml
1076+
patchesJson6902:
1077+
- target:
1078+
group: monitoring.coreos.com
1079+
kind: ServiceMonitor
1080+
name: starboard-exporter
1081+
namespace: starboard
1082+
version: v2
1083+
path: patch.0.yaml
1084+
`)
1085+
th.WriteF("base/servicemonitor.yaml", `
1086+
apiVersion: monitoring.coreos.com/v1
1087+
kind: ServiceMonitor
1088+
metadata:
1089+
labels:
1090+
app: starboard-exporter
1091+
name: starboard-exporter
1092+
namespace: starboard
1093+
spec:
1094+
endpoints:
1095+
- path: /metrics
1096+
port: metrics
1097+
selector:
1098+
matchLabels:
1099+
app.kubernetes.io/instance: starboard-exporter
1100+
app.kubernetes.io/name: starboard-exporter
1101+
`)
1102+
th.WriteF("base/patch.0.yaml", `
1103+
- op: add
1104+
path: /metadata/labels/release
1105+
value: kube-prometheus-stack
1106+
`)
1107+
err := th.RunWithErr("base", th.MakeDefaultOptions())
1108+
assert.Contains(t, err.Error(), "patchesJson6902 target not found for ServiceMonitor.v2.monitoring.coreos.com/starboard-exporter.starboard")
1109+
}

0 commit comments

Comments
 (0)