-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
386 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
charts/library/common-test/tests/rawResource/metadata_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json | ||
suite: rawResource metadata | ||
templates: | ||
- common.yaml | ||
values: | ||
- ../_values/controllers_main_default_container.yaml | ||
set: | ||
rawResources: | ||
config: | ||
apiVersion: v1 | ||
kind: Endpoint | ||
spec: | ||
test: test | ||
tests: | ||
- it: default metadata should pass | ||
asserts: | ||
- hasDocuments: | ||
count: 2 | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
notExists: | ||
path: metadata.annotations | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.labels | ||
value: | ||
app.kubernetes.io/instance: RELEASE-NAME | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: RELEASE-NAME | ||
helm.sh/chart: common-test-1.0.0 | ||
|
||
- it: custom metadata should pass | ||
set: | ||
rawResources: | ||
config: | ||
annotations: | ||
test_annotation: test | ||
labels: | ||
test_label: test | ||
asserts: | ||
- hasDocuments: | ||
count: 2 | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.annotations | ||
value: | ||
test_annotation: test | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.labels | ||
value: | ||
app.kubernetes.io/instance: RELEASE-NAME | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: RELEASE-NAME | ||
helm.sh/chart: common-test-1.0.0 | ||
test_label: test | ||
|
||
- it: custom metadata with global metadata should pass | ||
set: | ||
global: | ||
labels: | ||
global_label: test | ||
annotations: | ||
global_annotation: test | ||
rawResources: | ||
config: | ||
annotations: | ||
test_annotation: test | ||
labels: | ||
test_label: test | ||
asserts: | ||
- hasDocuments: | ||
count: 2 | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.annotations | ||
value: | ||
global_annotation: test | ||
test_annotation: test | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.labels | ||
value: | ||
app.kubernetes.io/instance: RELEASE-NAME | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: RELEASE-NAME | ||
global_label: test | ||
helm.sh/chart: common-test-1.0.0 | ||
test_label: test |
78 changes: 78 additions & 0 deletions
78
charts/library/common-test/tests/rawResource/values_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json | ||
suite: rawResource values | ||
templates: | ||
- common.yaml | ||
values: | ||
- ../_values/controllers_main_default_container.yaml | ||
set: | ||
rawResources: | ||
endpoint: | ||
apiVersion: v1 | ||
kind: Endpoint | ||
spec: | ||
subsets: | ||
- addresses: | ||
- ip: 127.0.0.1 | ||
ports: | ||
- name: "{{ .Release.Name }}" | ||
port: 443 | ||
protocol: TCP | ||
tests: | ||
- it: default should pass | ||
asserts: | ||
- hasDocuments: | ||
count: 2 | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: subsets[0].addresses[0].ip | ||
value: 127.0.0.1 | ||
|
||
- it: nameOverride should pass | ||
set: | ||
rawResources.endpoint: | ||
nameOverride: test | ||
asserts: | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.name | ||
value: RELEASE-NAME-test | ||
|
||
- it: nameOverride with template should pass | ||
set: | ||
rawResources.endpoint: | ||
nameOverride: "{{ .Release.Name }}" | ||
asserts: | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: metadata.name | ||
value: RELEASE-NAME | ||
|
||
- it: spec with template should pass | ||
set: | ||
rawResources.endpoint: | ||
spec: | ||
subsets: | ||
- addresses: | ||
- ip: 127.0.0.1 | ||
ports: | ||
- name: "{{ .Release.Name }}" | ||
port: 443 | ||
protocol: TCP | ||
asserts: | ||
- documentIndex: &rawResourceDocument 1 | ||
isKind: | ||
of: Endpoint | ||
- documentIndex: *rawResourceDocument | ||
equal: | ||
path: subsets[0].ports[0].name | ||
value: RELEASE-NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"instance": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"enabled": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"apiVersion": { | ||
"type": "string" | ||
}, | ||
"kind": { | ||
"type": "string" | ||
}, | ||
"annotations": { | ||
"$ref": "definitions.json#/annotations" | ||
}, | ||
"labels": { | ||
"$ref": "definitions.json#/labels" | ||
}, | ||
"nameOverride": { | ||
"type": "string" | ||
}, | ||
"spec": {} | ||
}, | ||
"required": ["apiVersion", "kind", "spec"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{/* | ||
This template serves as a blueprint for all raw resource objects that are created | ||
within the common library. | ||
*/}} | ||
{{- define "bjw-s.common.class.rawResource" -}} | ||
{{- $rootContext := .rootContext -}} | ||
{{- $resourceObject := .object -}} | ||
|
||
{{- $labels := merge | ||
($resourceObject.labels | default dict) | ||
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) | ||
-}} | ||
{{- $annotations := merge | ||
($resourceObject.annotations | default dict) | ||
(include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) | ||
-}} | ||
--- | ||
apiVersion: {{ $resourceObject.apiVersion }} | ||
kind: {{ $resourceObject.kind }} | ||
metadata: | ||
name: {{ $resourceObject.name }} | ||
{{- with $labels }} | ||
labels: | ||
{{- range $key, $value := . }} | ||
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with $annotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with $resourceObject.spec }} | ||
{{- tpl (toYaml .) $rootContext | nindent 0 }} | ||
{{- end }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.