Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions kyaml/yaml/merge2/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,173 @@ spec:
},
},

//
// Test Case
//
{description: `port patch adds a field but omits protocol (partial compound key)`,
source: `
apiVersion: v1
kind: Service
metadata:
name: web
spec:
ports:
- port: 30900
targetPort: 30900
nodePort: 30900
`,
dest: `
apiVersion: v1
kind: Service
metadata:
name: web
spec:
ports:
- port: 30900
targetPort: 30900
protocol: TCP
`,
expected: `
apiVersion: v1
kind: Service
metadata:
name: web
spec:
ports:
- port: 30900
targetPort: 30900
protocol: TCP
nodePort: 30900
`,
mergeOptions: yaml.MergeOptions{
ListIncreaseDirection: yaml.MergeOptionsListAppend,
},
},

//
// Test Case
//
{description: `patch with multiple ports, some omitting protocol (#4752)`,
source: `
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: rtmpk
port: 1986
protocol: UDP
targetPort: 1986
- name: rtmp
port: 1935
targetPort: 1935
- name: rtmpq
port: 1935
protocol: UDP
targetPort: 1935
- name: https
port: 443
targetPort: 443
- name: http3
port: 443
protocol: UDP
targetPort: 443
`,
dest: `
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
`,
expected: `
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
- name: rtmpk
port: 1986
protocol: UDP
targetPort: 1986
- name: rtmp
port: 1935
targetPort: 1935
- name: rtmpq
port: 1935
protocol: UDP
targetPort: 1935
- name: https
port: 443
targetPort: 443
- name: http3
port: 443
protocol: UDP
targetPort: 443
`,
mergeOptions: yaml.MergeOptions{
ListIncreaseDirection: yaml.MergeOptionsListAppend,
},
},

//
// Test Case
//
{description: `partial-key patch when base has two elements sharing the port (ambiguous)`,
source: `
apiVersion: v1
kind: Service
metadata:
name: web
spec:
ports:
- port: 8080
targetPort: 9999
`,
dest: `
apiVersion: v1
kind: Service
metadata:
name: web
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
- port: 8080
protocol: UDP
targetPort: 8080
`,
expected: `
apiVersion: v1
kind: Service
metadata:
name: web
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 9999
- port: 8080
protocol: UDP
targetPort: 8080
`,
mergeOptions: yaml.MergeOptions{
ListIncreaseDirection: yaml.MergeOptionsListAppend,
},
},

//
// Test Case
//
Expand Down
Loading