From 3b504fa3e5cc741993a81b666e395dcd6ff2e242 Mon Sep 17 00:00:00 2001 From: Natasha Sarkar Date: Mon, 2 Nov 2020 18:11:50 -0800 Subject: [PATCH] added StringList set --- .../patchstrategicmerge_test.go | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/api/filters/patchstrategicmerge/patchstrategicmerge_test.go b/api/filters/patchstrategicmerge/patchstrategicmerge_test.go index 867f83db6..6a7c3c9f8 100644 --- a/api/filters/patchstrategicmerge/patchstrategicmerge_test.go +++ b/api/filters/patchstrategicmerge/patchstrategicmerge_test.go @@ -370,6 +370,208 @@ spec: image: test2 - name: test image: test +`, + }, + // the following tests document broken behavior and + // will be fixed + // ref: #3111, #3159 + "list map keys - add a port, no names": { + input: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: TCP +`, + patch: yaml.MustParse(` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: UDP + - containerPort: 80 + protocol: UDP +`), + expected: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: UDP + - containerPort: 80 + protocol: UDP +`, + }, + "list map keys - add name to port": { + input: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: UDP + - containerPort: 8080 + protocol: TCP +`, + patch: yaml.MustParse(` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: UDP + name: UDP-name-patch +`), + expected: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: TCP +`, + }, + "list map keys - replace port name": { + input: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: UDP + name: UDP-name-original + - containerPort: 8080 + protocol: TCP + name: TCP-name-original +`, + patch: yaml.MustParse(` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: UDP + name: UDP-name-patch +`), + expected: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 + protocol: TCP + name: TCP-name-original +`, + }, + "list map keys - add a port, no protocol": { + input: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 8080 +`, + patch: yaml.MustParse(` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 80 +`), + expected: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-deployment +spec: + template: + spec: + containers: + - image: test-image + name: test-deployment + ports: + - containerPort: 80 + - containerPort: 8080 `, }, }