Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use kyaml to decode Kustomization #5069

Closed
Closed
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
3 changes: 2 additions & 1 deletion api/internal/localizer/localizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ suffix: invalid`,

_, err := Run("/a", "", "", fSysTest)
require.EqualError(t, err,
`unable to localize target "/a": invalid Kustomization: error unmarshaling JSON: while decoding JSON: json: unknown field "suffix"`)
`unable to localize target "/a": invalid Kustomization: yaml: unmarshal errors:
line 2: field suffix not found in type types.Kustomization`)

checkFSys(t, fSysExpected, fSysTest)
}
Expand Down
6 changes: 3 additions & 3 deletions api/internal/target/vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ vars:
name: nobelPrize
apiVersion: v7
fieldref:
fieldpath: some.arbitrary.path
fieldPath: some.arbitrary.path
- name: BIRD
objref:
kind: Service
Expand Down Expand Up @@ -93,7 +93,7 @@ vars:
name: nobelPrize
apiVersion: v7
fieldref:
fieldpath: some.arbitrary.path
fieldPath: some.arbitrary.path
- name: BIRD
objref:
kind: Service
Expand Down Expand Up @@ -151,7 +151,7 @@ vars:
name: nobelPrize
apiVersion: v7
fieldref:
fieldpath: some.arbitrary.path
fieldPath: some.arbitrary.path
- name: BIRD
objref:
kind: Service
Expand Down
5 changes: 3 additions & 2 deletions api/krusty/configmaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ radon
t.Fatalf("expected an error")
}
assert.Contains(t, err.Error(),
"invalid Kustomization: error converting YAML to JSON: yaml: unmarshal errors:\n"+
" line 13: key \"literals\" already set in map\n line 18: key \"files\" already set in map")
"invalid Kustomization: yaml: unmarshal errors:\n"+
" line 12: mapping key \"literals\" already defined at line 9\n"+
" line 17: mapping key \"files\" already defined at line 15")
}

func TestIssue3393(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions api/krusty/customconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ vars:
kind: Giraffe
name: april
fieldref:
fieldpath: spec.diet
fieldPath: spec.diet
- name: KOKO_DIET
objref:
kind: Gorilla
name: koko
fieldref:
fieldpath: spec.diet
fieldPath: spec.diet
resources:
- animalPark.yaml
- giraffes.yaml
Expand Down
4 changes: 2 additions & 2 deletions api/krusty/intermediateresourceid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ vars:
name: xql-secret
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
`)

th.WriteF("app/resources/xql/xql-one/config/xql-one-secret.env", `
Expand All @@ -281,7 +281,7 @@ vars:
name: xql-secret
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
`)

th.WriteF("app/resources/xql/xql-zero/config/xql-zero-secret.env", `
Expand Down
4 changes: 2 additions & 2 deletions api/krusty/issue3377_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ vars:
kind: Ingress
name: service-a
fieldref:
fieldpath: spec.rules[0].host
fieldPath: spec.rules[0].host
- name: SERVICE_B_DNS_NAME
objref:
apiVersion: networking.k8s.io/v1
kind: Ingress
name: service-b
fieldref:
fieldpath: spec.rules[0].host
fieldPath: spec.rules[0].host
`)

th.WriteF("service-a.yaml", `
Expand Down
24 changes: 12 additions & 12 deletions api/krusty/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,28 +472,28 @@ vars:
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
- name: elasticsearch-test-protocol
objref:
kind: Service
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: spec.ports[0].protocol
fieldPath: spec.ports[0].protocol
- name: elasticsearch-dev-service-name
objref:
kind: Service
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
- name: elasticsearch-dev-protocol
objref:
kind: Service
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: spec.ports[0].protocol
fieldPath: spec.ports[0].protocol
`

const namespaceNeedInVarDevResources string = `
Expand Down Expand Up @@ -643,14 +643,14 @@ vars:
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
- name: elasticsearch-dev-protocol
objref:
kind: Service
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: spec.ports[0].protocol
fieldPath: spec.ports[0].protocol
`

const namespaceNeedInVarTestFolder string = `
Expand All @@ -663,14 +663,14 @@ vars:
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
- name: elasticsearch-test-protocol
objref:
kind: Service
name: elasticsearch
apiVersion: v1
fieldref:
fieldpath: spec.ports[0].protocol
fieldPath: spec.ports[0].protocol
`

// TestVariablesAmbiguousWorkaround demonstrates a possible workaround
Expand Down Expand Up @@ -705,31 +705,31 @@ vars:
namespace: test
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
- name: elasticsearch-test-protocol
objref:
kind: Service
name: elasticsearch
namespace: test
apiVersion: v1
fieldref:
fieldpath: spec.ports[0].protocol
fieldPath: spec.ports[0].protocol
- name: elasticsearch-dev-service-name
objref:
kind: Service
name: elasticsearch
namespace: dev
apiVersion: v1
fieldref:
fieldpath: metadata.name
fieldPath: metadata.name
- name: elasticsearch-dev-protocol
objref:
kind: Service
name: elasticsearch
namespace: dev
apiVersion: v1
fieldref:
fieldpath: spec.ports[0].protocol
fieldPath: spec.ports[0].protocol
`

// TestVariablesDisambiguatedWithNamespace demonstrates that adding the namespace
Expand Down
Loading