Skip to content

Commit

Permalink
Update setter comments during 3-way merge
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimarupaka committed Aug 3, 2020
1 parent 17f9354 commit 4e74947
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 56 deletions.
60 changes: 40 additions & 20 deletions kyaml/yaml/merge3/element_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var elementTestCases = []testCase{
//
// Test Case
//
{description: `Add an element to an existing list`,
{
description: `Add an element to an existing list`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -57,7 +58,8 @@ spec:
//
// Test Case
//
{description: `Add an element to a non-existing list`,
{
description: `Add an element to a non-existing list`,
origin: `
apiVersion: apps/v1
kind: Deployment`,
Expand Down Expand Up @@ -86,7 +88,8 @@ spec:
name: foo
`},

{description: `Add an element to a non-existing list, existing in dest`,
{
description: `Add an element to a non-existing list, existing in dest`,
origin: `
apiVersion: apps/v1
kind: Deployment`,
Expand Down Expand Up @@ -127,7 +130,8 @@ spec:
// Test Case
// TODO(pwittrock): Figure out if there is something better we can do here
// This element is missing from the destination -- only the new fields are added
{description: `Add a field to the element, element missing from dest`,
{
description: `Add a field to the element, element missing from dest`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -168,7 +172,8 @@ spec:
//
// Test Case
//
{description: `Update a field on the elem, element missing from the dest`,
{
description: `Update a field on the elem, element missing from the dest`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -212,7 +217,8 @@ spec:
//
// Test Case
//
{description: `Update a field on the elem, element present in the dest`,
{
description: `Update a field on the elem, element present in the dest`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -308,7 +314,8 @@ spec:
//
// Test Case
//
{description: `Add a field on the elem, element and field present in the dest`,
{
description: `Add a field on the elem, element and field present in the dest`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -356,7 +363,8 @@ spec:
//
// Test Case
//
{description: `Ignore an element`,
{
description: `Ignore an element`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -397,7 +405,8 @@ spec:
//
// Test Case
//
{description: `Leave deleted`,
{
description: `Leave deleted`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand All @@ -424,7 +433,8 @@ kind: Deployment
//
// Test Case
//
{description: `Remove an element -- matching`,
{
description: `Remove an element -- matching`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -463,7 +473,8 @@ spec:
//
// Test Case
//
{description: `Remove an element -- field missing from update`,
{
description: `Remove an element -- field missing from update`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -503,7 +514,8 @@ spec:
//
// Test Case
//
{description: `Remove an element -- element missing`,
{
description: `Remove an element -- element missing`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -554,7 +566,8 @@ spec:
//
// Test Case
//
{description: `Remove an element -- empty containers`,
{
description: `Remove an element -- empty containers`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -595,7 +608,8 @@ spec:
//
// Test Case
//
{description: `Remove an element -- missing list field`,
{
description: `Remove an element -- missing list field`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -635,7 +649,8 @@ spec:
//
// Test Case
//
{description: `infer merge keys merge'`,
{
description: `infer merge keys merge'`,
origin: `
kind: Deployment
spec:
Expand Down Expand Up @@ -678,7 +693,8 @@ spec:
//
// Test Case
//
{description: `no infer merge keys merge using schema`,
{
description: `no infer merge keys merge using schema`,
origin: `
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -725,7 +741,8 @@ spec:
//
// Test Case
//
{description: `no infer merge keys merge using explicit schema as line comment'`,
{
description: `no infer merge keys merge using explicit schema as line comment'`,
origin: `
apiVersion: custom
kind: Deployment
Expand Down Expand Up @@ -772,7 +789,8 @@ spec:
//
// Test Case
//
{description: `no infer merge keys merge using explicit schema as head comment'`,
{
description: `no infer merge keys merge using explicit schema as head comment'`,
origin: `
apiVersion: custom
kind: Deployment
Expand Down Expand Up @@ -821,7 +839,8 @@ spec:
//
// Test Case
//
{description: `no infer merge keys merge using explicit schema to parent field'`,
{
description: `no infer merge keys merge using explicit schema to parent field'`,
origin: `
apiVersion: custom
kind: Deployment
Expand Down Expand Up @@ -860,7 +879,8 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
//
// Test Case
//
{description: `no infer merge keys merge using explicit schema to parent field header'`,
{
description: `no infer merge keys merge using explicit schema to parent field header'`,
origin: `
apiVersion: custom
kind: Deployment
Expand Down
6 changes: 4 additions & 2 deletions kyaml/yaml/merge3/kustomization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package merge3_test
var kustomizationTestCases = []testCase{
// Kustomization Test Cases

{description: `ConfigMapGenerator merge`,
{
description: `ConfigMapGenerator merge`,
origin: `
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Expand Down Expand Up @@ -48,7 +49,8 @@ configMapGenerator:
- configkey=configs/another_configfile2
name: a-configmap2`},

{description: `SecretGenerator merge`,
{
description: `SecretGenerator merge`,
origin: `
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Expand Down
27 changes: 18 additions & 9 deletions kyaml/yaml/merge3/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var listTestCases = []testCase{
//
// Test Case
//
{description: `Replace list`,
{
description: `Replace list`,
origin: `
list:
- 1
Expand All @@ -34,7 +35,8 @@ list:
//
// Test Case
//
{description: `Add an updated list`,
{
description: `Add an updated list`,
origin: `
apiVersion: apps/v1
list: # old value
Expand Down Expand Up @@ -62,7 +64,8 @@ list:
//
// Test Case
//
{description: `Add keep an omitted field`,
{
description: `Add keep an omitted field`,
origin: `
apiVersion: apps/v1
kind: Deployment`,
Expand All @@ -89,7 +92,8 @@ kind: StatefulSet
// Test Case
//
// TODO(#36): consider making this an error
{description: `Change an updated field`,
{
description: `Change an updated field`,
origin: `
apiVersion: apps/v1
list: # old value
Expand Down Expand Up @@ -119,7 +123,8 @@ list: # conflicting value
//
// Test Case
//
{description: `Ignore a field -- set`,
{
description: `Ignore a field -- set`,
origin: `
apiVersion: apps/v1
list: # ignore value
Expand Down Expand Up @@ -151,7 +156,8 @@ list:
//
// Test Case
//
{description: `Ignore a field -- empty`,
{
description: `Ignore a field -- empty`,
origin: `
apiVersion: apps/v1
list: # ignore value
Expand All @@ -174,7 +180,8 @@ apiVersion: apps/v1
//
// Test Case
//
{description: `Explicitly clear a field`,
{
description: `Explicitly clear a field`,
origin: `
apiVersion: apps/v1`,
update: `
Expand All @@ -192,7 +199,8 @@ apiVersion: apps/v1`},
//
// Test Case
//
{description: `Implicitly clear a field`,
{
description: `Implicitly clear a field`,
origin: `
apiVersion: apps/v1
list: # clear value
Expand All @@ -214,7 +222,8 @@ apiVersion: apps/v1`},
// Test Case
//
// TODO(#36): consider making this an error
{description: `Implicitly clear a changed field`,
{
description: `Implicitly clear a changed field`,
origin: `
apiVersion: apps/v1
list: # old value
Expand Down

0 comments on commit 4e74947

Please sign in to comment.