diff --git a/.circleci/config.yml b/.circleci/config.yml
index 95a41ffc..fbd2d24a 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -2,7 +2,7 @@ version: 2
jobs:
test:
docker:
- - image: circleci/golang:1.10
+ - image: circleci/golang:1.12
working_directory: /go/src/github.com/lrills/helm-unittest
steps:
- checkout
diff --git a/.drone.yml b/.drone.yml
index 8500e5be..096887b4 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -11,12 +11,12 @@ workspace:
steps:
- name: build
- image: golang:1.11
+ image: golang:1.12
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- - mkdir /go/bin
+ - mkdir /go/bin
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- dep ensure
- make dist
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89d4bd17..4f93bbd2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,21 @@
+0.1.5 / 2019-04-09
+==================
+- update sprig (#72, #73)
+
+0.1.4 / 2019-03-30
+==================
+- fix slash problem in windows (#70)
+- add update plugin hook, enable `helm plugin update` (#69)
+
+0.1.3 / 2019-03-29
+==================
+- use yaml.Decoder to parse multi doc manifest (#66)
+- fix doc typo (#56, #63)
+- upgrade sprig and helm (#49)
+- fix static linking of building (#46)
+- enhance install script (#43)
+- standard dockerfile for running (#42)
+
0.1.2 / 2018-03-29
==================
- feature: recursively find test suite files along dependencies in `charts`
diff --git a/DOCUMENT.md b/DOCUMENT.md
index 8c283f8b..b29b14d5 100644
--- a/DOCUMENT.md
+++ b/DOCUMENT.md
@@ -106,7 +106,7 @@ Available assertion types are listed below:
|----------------|------------|-------------|---------|
| `equal` | **path**: *string*. The `set` path to assert.
**value**: *any*. The expected value. | Assert the value of specified **path** equal to the **value**. |
equal:| | `notEqual` | **path**: *string*. The `set` path to assert.
path: metadata.name
value: my-deploy
notEqual:| -| `matchRegex` | **path**: *string*. The `set` path to assert, the value must be a *string*.
path: metadata.name
value: my-deploy
matchRegex:| +| `matchRegex` | **path**: *string*. The `set` path to assert, the value must be a *string*.
path: metadata.name
value: -my-chart$
matchRegex:| | `notMatchRegex` | **path**: *string*. The `set` path to assert, the value must be a *string*.
path: metadata.name
pattern: -my-chart$
notMatchRegex:| | `contains` | **path**: *string*. The `set` path to assert, the value must be an *array*.
path: metadata.name
pattern: -my-chat$
contains:| | `notContains` | **path**: *string*. The `set` path to assert, the value must be an *array*.
path: spec.ports
content:
name: web
port: 80
targetPort: 80
protocle:TCP
notContains:| diff --git a/Gopkg.lock b/Gopkg.lock index 4432355d..39d91406 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,54 +2,79 @@ [[projects]] + digest = "1:e4b30804a381d7603b8a344009987c1ba351c26043501b23b8c7ce21f0b67474" name = "github.com/BurntSushi/toml" packages = ["."] - revision = "b26d9c308763d68093482582cea63d69be07a0f0" - version = "v0.3.0" + pruneopts = "" + revision = "3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005" + version = "v0.3.1" [[projects]] + digest = "1:debe400440582cfe5580591afd0f7fdef5b17a25945f06bd3087bc67b4b8fd03" + name = "github.com/Masterminds/goutils" + packages = ["."] + pruneopts = "" + revision = "41ac8693c5c10a92ea1ff5ac3a7f95646f6123b0" + version = "v1.1.0" + +[[projects]] + digest = "1:b856d8248663c39265a764561c1a1a149783f6cc815feb54a1f3a591b91f6eca" name = "github.com/Masterminds/semver" packages = ["."] - revision = "15d8430ab86497c5c0da827b748823945e1cf1e1" - version = "v1.4.0" + pruneopts = "" + revision = "c7af12943936e8c39859482e61f0574c2fd7fc75" + version = "v1.4.2" [[projects]] + digest = "1:844a29d20675e6187639c578b6c690d198aac895ede377ebcb5545405d0ef80d" name = "github.com/Masterminds/sprig" packages = ["."] - revision = "b217b9c388de2cacde4354c536e520c52c055563" - version = "v2.14.1" + pruneopts = "" + revision = "9f8fceff796fb9f4e992cd2bece016be0121ab74" + version = "2.19.0" [[projects]] - name = "github.com/aokoli/goutils" + digest = "1:0f1cec63c43cdbea326265afcc44415c663123abf452ca9ba20a720884d9a16c" + name = "github.com/bradleyjkemp/cupaloy" packages = ["."] - revision = "3391d3790d23d03408670993e957e8f408993c34" - version = "v1.0.1" + pruneopts = "" + revision = "4ebc4e863ab6bedcc009ccfb5f209939090ceadd" + version = "v2.4.0" [[projects]] - name = "github.com/bradleyjkemp/cupaloy" + digest = "1:a9854984bc40330dde2125537b7f46d0a8d7860b3750de2e7cd0a6f904506212" + name = "github.com/cyphar/filepath-securejoin" packages = ["."] - revision = "0d797813a76b4573317a916b0c5816dc55fff62d" - version = "v2.0.0" + pruneopts = "" + revision = "a261ee33d7a517f054effbf451841abaafe3e0fd" + version = "v0.2.2" [[projects]] + digest = "1:0deddd908b6b4b768cfc272c16ee61e7088a60f7fe2f06c547bd3d8e1f8b8e77" name = "github.com/davecgh/go-spew" packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" + pruneopts = "" + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" [[projects]] + digest = "1:e988ed0ca0d81f4d28772760c02ee95084961311291bdfefc1b04617c178b722" name = "github.com/fatih/color" packages = ["."] - revision = "570b54cabe6b8eb0bc2dfce68d964677d63b5260" - version = "v1.5.0" + pruneopts = "" + revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4" + version = "v1.7.0" [[projects]] + digest = "1:b13707423743d41665fd23f0c36b2f37bb49c30e94adb813319c44188a51ba22" name = "github.com/ghodss/yaml" packages = ["."] + pruneopts = "" revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7" version = "v1.0.0" [[projects]] + digest = "1:9ab1b1c637d7c8f49e39d8538a650d7eb2137b076790cff69d160823b505964c" name = "github.com/gobwas/glob" packages = [ ".", @@ -59,124 +84,168 @@ "syntax/ast", "syntax/lexer", "util/runes", - "util/strings" + "util/strings", ] - revision = "bea32b9cd2d6f55753d94a28e959b13f0244797a" - version = "v0.2.2" + pruneopts = "" + revision = "5ccd90ef52e1e632236f7326478d4faa74f99438" + version = "v0.2.3" [[projects]] - branch = "master" + digest = "1:529d738b7976c3848cae5cf3a8036440166835e389c1f617af701eeb12a0518d" name = "github.com/golang/protobuf" packages = [ "proto", "ptypes/any", - "ptypes/timestamp" + "ptypes/timestamp", ] - revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" + pruneopts = "" + revision = "b5d812f8a3706043e23a9cd5babf2e5423744d30" + version = "v1.3.1" [[projects]] - branch = "master" + digest = "1:ad92aa49f34cbc3546063c7eb2cabb55ee2278b72842eda80e2a20a8a06a8d73" + name = "github.com/google/uuid" + packages = ["."] + pruneopts = "" + revision = "0cd6bf5da1e1c83f8b45653022c74f71af0538a4" + version = "v1.1.1" + +[[projects]] + digest = "1:35979179658d20a73693589e67bdc3baf4dc0ef9f524b1dfd3cc55fb5f6ae384" name = "github.com/huandu/xstrings" packages = ["."] - revision = "37469d0c81a7910b49d64a0d308ded4823e90937" + pruneopts = "" + revision = "f02667b379e2fb5916c3cda2cf31e0eb885d79f8" + version = "v1.2.0" [[projects]] + digest = "1:31bfd110d31505e9ffbc9478e31773bf05bf02adcaeb9b139af42684f9294c13" name = "github.com/imdario/mergo" packages = ["."] - revision = "7fe0c75c13abdee74b09fcacef5ea1c6bba6a874" - version = "0.2.4" + pruneopts = "" + revision = "7c29201646fa3de8506f701213473dd407f19646" + version = "v0.3.7" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:9ea83adf8e96d6304f394d40436f2eb44c1dc3250d223b74088cc253a6cd0a1c" name = "github.com/mattn/go-colorable" packages = ["."] + pruneopts = "" revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" version = "v0.0.9" [[projects]] + digest = "1:d0600e4cf07697303f37130791b2ce4577367931416bea8ec4f601bde3f7c5bf" name = "github.com/mattn/go-isatty" packages = ["."] - revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" - version = "v0.0.3" + pruneopts = "" + revision = "c2a7a6ca930a4cd0bc33a3f298eb71960732a3a7" + version = "v0.0.7" [[projects]] - branch = "master" + digest = "1:bcc46a0fbd9e933087bef394871256b5c60269575bb661935874729c65bbbf60" name = "github.com/mitchellh/mapstructure" packages = ["."] - revision = "06020f85339e21b2478f756a78e295255ffa4d6a" + pruneopts = "" + revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe" + version = "v1.1.2" [[projects]] + digest = "1:1d7e1867c49a6dd9856598ef7c3123604ea3daabf5b83f303ff457bcbc410b1d" + name = "github.com/pkg/errors" + packages = ["."] + pruneopts = "" + revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4" + version = "v0.8.1" + +[[projects]] + digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411" name = "github.com/pmezard/go-difflib" packages = ["difflib"] + pruneopts = "" revision = "792786c7400a136282c1664665ae0a8db921c6c2" version = "v1.0.0" [[projects]] - name = "github.com/satori/go.uuid" - packages = ["."] - revision = "879c5887cd475cd7864858769793b2ceb0d44feb" - version = "v1.1.0" - -[[projects]] + digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6" name = "github.com/spf13/cobra" packages = ["."] - revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b" - version = "v0.0.1" + pruneopts = "" + revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" + version = "v0.0.3" [[projects]] + digest = "1:cbaf13cdbfef0e4734ed8a7504f57fe893d471d62a35b982bf6fb3f036449a66" name = "github.com/spf13/pflag" packages = ["."] - revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" - version = "v1.0.0" + pruneopts = "" + revision = "298182f68c66c05229eb03ac171abe6e309ee79a" + version = "v1.0.3" [[projects]] + digest = "1:711eebe744c0151a9d09af2315f0bb729b2ec7637ef4c410fa90a18ef74b65b6" name = "github.com/stretchr/objx" packages = ["."] - revision = "facf9a85c22f48d2f52f2380e4efce1768749a89" - version = "v0.1" + pruneopts = "" + revision = "477a77ecc69700c7cdeb1fa9e129548e1c1c393c" + version = "v0.1.1" [[projects]] + digest = "1:381bcbeb112a51493d9d998bbba207a529c73dbb49b3fd789e48c63fac1f192c" name = "github.com/stretchr/testify" packages = [ "assert", - "mock" + "mock", ] - revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" - version = "v1.1.4" + pruneopts = "" + revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053" + version = "v1.3.0" [[projects]] branch = "master" + digest = "1:36ef1d8645934b1744cc7d8726e00d3dd9d8d84c18617bf7367a3a6d532f3370" name = "golang.org/x/crypto" packages = [ "pbkdf2", - "scrypt" + "scrypt", ] - revision = "94eea52f7b742c7cbe0b03b22f0c4c8631ece122" + pruneopts = "" + revision = "a5d413f7728c81fb97d96a2b722368945f651e78" [[projects]] branch = "master" + digest = "1:2c8100dd5d57b0803cebab4de1d55e0438b40afdfad520cbbecba7c8a13aed15" name = "golang.org/x/sys" packages = ["unix"] - revision = "af50095a40f9041b3b38960738837185c26e9419" + pruneopts = "" + revision = "baf5eb976a8cd65845293cd814ea151018552292" [[projects]] - branch = "v2" + digest = "1:cedccf16b71e86db87a24f8d4c70b0a855872eb967cb906a66b95de56aefbd0d" name = "gopkg.in/yaml.v2" packages = ["."] - revision = "287cf08546ab5e7e37d55a84f7ed3fd1db036de5" + pruneopts = "" + revision = "51d6538a90f86fe93ac480b35f37b2be17fef232" + version = "v2.2.2" [[projects]] branch = "master" + digest = "1:9fe71fb011ae5d0e37120a90c940a05ea76dc46909ec73ff1c78c8db1038cb75" name = "k8s.io/apimachinery" packages = ["pkg/version"] - revision = "5250765d28a6a1e07c6f09fe814a4b58ad74cc11" + pruneopts = "" + revision = "10bf64c7018d1bf6b021767df5126dec74b08010" [[projects]] + digest = "1:93dacf333c11ff29b3a336c1bbff8f2f1dc689a47a49f9e58a183202eaeae184" name = "k8s.io/helm" packages = [ "pkg/chartutil", @@ -186,14 +255,28 @@ "pkg/proto/hapi/version", "pkg/sympath", "pkg/timeconv", - "pkg/version" + "pkg/version", ] - revision = "a80231648a1473929271764b920a8e346f6de844" - version = "v2.8.2" + pruneopts = "" + revision = "618447cbf203d147601b4b9bd7f8c37a5d39fbb4" + version = "v2.13.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "1d7458c3b71571c4abd8101b5fe1c9457be6aae45e8a724614cf3f123499ccea" + input-imports = [ + "github.com/bradleyjkemp/cupaloy", + "github.com/fatih/color", + "github.com/mitchellh/mapstructure", + "github.com/pmezard/go-difflib/difflib", + "github.com/spf13/cobra", + "github.com/stretchr/testify/assert", + "github.com/stretchr/testify/mock", + "gopkg.in/yaml.v2", + "k8s.io/helm/pkg/chartutil", + "k8s.io/helm/pkg/engine", + "k8s.io/helm/pkg/proto/hapi/chart", + "k8s.io/helm/pkg/timeconv", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Makefile b/Makefile index 08020fb8..20189ab9 100644 --- a/Makefile +++ b/Makefile @@ -25,13 +25,13 @@ build: dist: mkdir -p $(DIST) CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o untt -ldflags $(LDFLAGS) ./main.go - tar -zcvf $(DIST)/helm-unittest-linux-amd64-$(VERSION).tgz untt README.md LICENSE plugin.yaml + tar -zcvf $(DIST)/helm-unittest-linux-amd64.tgz untt README.md LICENSE plugin.yaml CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o untt -ldflags $(LDFLAGS) ./main.go - tar -zcvf $(DIST)/helm-unittest-macos-amd64-$(VERSION).tgz untt README.md LICENSE plugin.yaml + tar -zcvf $(DIST)/helm-unittest-macos-amd64.tgz untt README.md LICENSE plugin.yaml CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o untt.exe -ldflags $(LDFLAGS) ./main.go - tar -zcvf $(DIST)/helm-unittest-windows-amd64-$(VERSION).tgz untt.exe README.md LICENSE plugin.yaml + tar -zcvf $(DIST)/helm-unittest-windows-amd64.tgz untt.exe README.md LICENSE plugin.yaml CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o untt -ldflags $(LDFLAGS) ./main.go - tar -zcvf $(DIST)/helm-unittest-linux-arm64-$(VERSION).tgz untt README.md LICENSE plugin.yaml + tar -zcvf $(DIST)/helm-unittest-linux-arm64.tgz untt README.md LICENSE plugin.yaml .PHONY: bootstrap bootstrap: diff --git a/__fixtures__/basic/templates/deployment.yaml b/__fixtures__/basic/templates/deployment.yaml index 33336006..b7a567a7 100644 --- a/__fixtures__/basic/templates/deployment.yaml +++ b/__fixtures__/basic/templates/deployment.yaml @@ -1,3 +1,4 @@ +--- apiVersion: extensions/v1beta1 kind: Deployment metadata: @@ -35,3 +36,32 @@ spec: nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }} {{- end }} +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: db + labels: + app: {{ template "basic.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: 1 + template: + metadata: + labels: + app: {{ template "basic.name" . }} + release: {{ .Release.Name }} + annotations: + some_template: | + --- + apiVersion: ... + this: is test for old separator workaround bug + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.dbPort }} diff --git a/__fixtures__/basic/tests/deployment_test.yaml b/__fixtures__/basic/tests/deployment_test.yaml index d60bbb22..2f9a4b4c 100644 --- a/__fixtures__/basic/tests/deployment_test.yaml +++ b/__fixtures__/basic/tests/deployment_test.yaml @@ -41,6 +41,6 @@ tests: - isAPIVersion: of: extensions/v1beta1 - hasDocuments: - count: 1 + count: 2 - matchSnapshot: path: spec diff --git a/__fixtures__/basic/tests_failed/deployment_test.yaml b/__fixtures__/basic/tests_failed/deployment_test.yaml index cf672d94..21a231cf 100644 --- a/__fixtures__/basic/tests_failed/deployment_test.yaml +++ b/__fixtures__/basic/tests_failed/deployment_test.yaml @@ -41,6 +41,6 @@ tests: - isAPIVersion: of: v2 - hasDocuments: - count: 2 + count: 1 - matchSnapshot: path: spec diff --git a/__fixtures__/basic/values.yaml b/__fixtures__/basic/values.yaml index 04f9f966..45d1817a 100644 --- a/__fixtures__/basic/values.yaml +++ b/__fixtures__/basic/values.yaml @@ -12,6 +12,7 @@ service: externalPort: 80 internalPort: 80 ingress: + class: foo enabled: false # Used to create an Ingress record. hosts: diff --git a/__fixtures__/with-subchart/Chart.yaml b/__fixtures__/with-subchart/Chart.yaml index 8d5f0094..54fff304 100644 --- a/__fixtures__/with-subchart/Chart.yaml +++ b/__fixtures__/with-subchart/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v1 description: An example chart with customized subchart -name: with-subchart +name: parent-chart version: 0.1.0 diff --git a/__fixtures__/with-subchart/charts/childchart/Chart.yaml b/__fixtures__/with-subchart/charts/child-chart/Chart.yaml similarity index 78% rename from __fixtures__/with-subchart/charts/childchart/Chart.yaml rename to __fixtures__/with-subchart/charts/child-chart/Chart.yaml index 6cf7a2be..d9b1bdee 100644 --- a/__fixtures__/with-subchart/charts/childchart/Chart.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v1 description: An customized subchart -name: childchart +name: child-chart version: 0.1.0 diff --git a/__fixtures__/with-subchart/charts/childchart/templates/NOTES.txt b/__fixtures__/with-subchart/charts/child-chart/templates/NOTES.txt similarity index 78% rename from __fixtures__/with-subchart/charts/childchart/templates/NOTES.txt rename to __fixtures__/with-subchart/charts/child-chart/templates/NOTES.txt index 1a86eef9..c84cdeb0 100644 --- a/__fixtures__/with-subchart/charts/childchart/templates/NOTES.txt +++ b/__fixtures__/with-subchart/charts/child-chart/templates/NOTES.txt @@ -4,16 +4,16 @@ http://{{ . }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "basic.fullname" . }}) + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "child-chart.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "basic.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "basic.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + You can watch the status of by running 'kubectl get svc -w {{ template "child-chart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "child-chart.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo http://$SERVICE_IP:{{ .Values.service.externalPort }} {{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "basic.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "child-chart.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort }} {{- end }} diff --git a/__fixtures__/with-subchart/charts/childchart/templates/_helpers.tpl b/__fixtures__/with-subchart/charts/child-chart/templates/_helpers.tpl similarity index 55% rename from __fixtures__/with-subchart/charts/childchart/templates/_helpers.tpl rename to __fixtures__/with-subchart/charts/child-chart/templates/_helpers.tpl index b417510b..36659b67 100644 --- a/__fixtures__/with-subchart/charts/childchart/templates/_helpers.tpl +++ b/__fixtures__/with-subchart/charts/child-chart/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{- define "basic.name" -}} +{{- define "child-chart.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -10,7 +10,17 @@ Expand the name of the chart. Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} -{{- define "basic.fullname" -}} +{{- define "child-chart.fullname" -}} {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{- define "child-chart.ingressClass" -}} + {{- $ingressClass := .Values.ingress.class -}} + {{- if .Values.global -}} + {{- if .Values.global.ingressClass -}} + {{- $ingressClass = .Values.global.ingressClass -}} + {{- end -}} + {{- end -}} + {{- printf "%s" $ingressClass -}} +{{- end -}} diff --git a/__fixtures__/with-subchart/charts/childchart/templates/deployment.yaml b/__fixtures__/with-subchart/charts/child-chart/templates/deployment.yaml similarity index 87% rename from __fixtures__/with-subchart/charts/childchart/templates/deployment.yaml rename to __fixtures__/with-subchart/charts/child-chart/templates/deployment.yaml index 33336006..e3cc7727 100644 --- a/__fixtures__/with-subchart/charts/childchart/templates/deployment.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/templates/deployment.yaml @@ -1,9 +1,9 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: - name: {{ template "basic.fullname" . }} + name: {{ template "child-chart.fullname" . }} labels: - app: {{ template "basic.name" . }} + app: {{ template "child-chart.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} @@ -12,7 +12,7 @@ spec: template: metadata: labels: - app: {{ template "basic.name" . }} + app: {{ template "child-chart.name" . }} release: {{ .Release.Name }} spec: containers: diff --git a/__fixtures__/with-subchart/charts/childchart/templates/ingress.yaml b/__fixtures__/with-subchart/charts/child-chart/templates/ingress.yaml similarity index 73% rename from __fixtures__/with-subchart/charts/childchart/templates/ingress.yaml rename to __fixtures__/with-subchart/charts/child-chart/templates/ingress.yaml index e55c347d..ca3620b7 100644 --- a/__fixtures__/with-subchart/charts/childchart/templates/ingress.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/templates/ingress.yaml @@ -1,19 +1,17 @@ {{- if .Values.ingress.enabled -}} -{{- $serviceName := include "basic.fullname" . -}} +{{- $serviceName := include "child-chart.fullname" . -}} {{- $servicePort := .Values.service.externalPort -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ template "basic.fullname" . }} + name: {{ template "child-chart.fullname" . }} labels: - app: {{ template "basic.name" . }} + app: {{ template "child-chart.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} annotations: - {{- range $key, $value := .Values.ingress.annotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} + kubernetes.io/ingress.class: {{ template "child-chart.ingressClass" . }} spec: rules: {{- range $host := .Values.ingress.hosts }} diff --git a/__fixtures__/with-subchart/charts/childchart/templates/service.yaml b/__fixtures__/with-subchart/charts/child-chart/templates/service.yaml similarity index 76% rename from __fixtures__/with-subchart/charts/childchart/templates/service.yaml rename to __fixtures__/with-subchart/charts/child-chart/templates/service.yaml index 0d4d20eb..00bf6b5a 100644 --- a/__fixtures__/with-subchart/charts/childchart/templates/service.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "basic.fullname" . }} + name: {{ template "child-chart.fullname" . }} labels: - app: {{ template "basic.name" . }} + app: {{ template "child-chart.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} @@ -15,5 +15,5 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ template "basic.name" . }} + app: {{ template "child-chart.name" . }} release: {{ .Release.Name }} diff --git a/__fixtures__/with-subchart/charts/childchart/tests/__snapshot__/deployment_test.yaml.snap b/__fixtures__/with-subchart/charts/child-chart/tests/__snapshot__/deployment_test.yaml.snap similarity index 89% rename from __fixtures__/with-subchart/charts/childchart/tests/__snapshot__/deployment_test.yaml.snap rename to __fixtures__/with-subchart/charts/child-chart/tests/__snapshot__/deployment_test.yaml.snap index 04b9b5dc..cc42ae82 100644 --- a/__fixtures__/with-subchart/charts/childchart/tests/__snapshot__/deployment_test.yaml.snap +++ b/__fixtures__/with-subchart/charts/child-chart/tests/__snapshot__/deployment_test.yaml.snap @@ -4,7 +4,7 @@ should pass all kinds of assertion: template: metadata: labels: - app: childchart + app: child-chart release: RELEASE-NAME spec: containers: @@ -14,7 +14,7 @@ should pass all kinds of assertion: httpGet: path: / port: 8080 - name: childchart + name: child-chart ports: - containerPort: 8080 readinessProbe: diff --git a/__fixtures__/with-subchart/charts/childchart/tests/deployment_test.yaml b/__fixtures__/with-subchart/charts/child-chart/tests/deployment_test.yaml similarity index 97% rename from __fixtures__/with-subchart/charts/childchart/tests/deployment_test.yaml rename to __fixtures__/with-subchart/charts/child-chart/tests/deployment_test.yaml index 3979249f..778a1e4b 100644 --- a/__fixtures__/with-subchart/charts/childchart/tests/deployment_test.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/tests/deployment_test.yaml @@ -16,7 +16,7 @@ tests: value: nginx:stable - matchRegex: path: metadata.name - pattern: ^.*-childchart$ + pattern: ^.*-child-chart$ - notMatchRegex: path: metadata.name pattern: ^.*-foobar$ diff --git a/__fixtures__/with-subchart/charts/childchart/tests/ingress_test.yaml b/__fixtures__/with-subchart/charts/child-chart/tests/ingress_test.yaml similarity index 89% rename from __fixtures__/with-subchart/charts/childchart/tests/ingress_test.yaml rename to __fixtures__/with-subchart/charts/child-chart/tests/ingress_test.yaml index b4be7a00..1182d092 100644 --- a/__fixtures__/with-subchart/charts/childchart/tests/ingress_test.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/tests/ingress_test.yaml @@ -25,7 +25,7 @@ tests: content: path: / backend: - serviceName: my-release-childchart + serviceName: my-release-child-chart servicePort: 12345 - isNull: path: spec.tls @@ -43,8 +43,6 @@ tests: path: metadata.annotations value: kubernetes.io/ingress.class: nginx - kubernetes.io/tls-acme: "true" - ingress.kubernetes.io/rewrite-target: / - it: should set tls if given set: diff --git a/__fixtures__/with-subchart/charts/childchart/tests/service_test.yaml b/__fixtures__/with-subchart/charts/child-chart/tests/service_test.yaml similarity index 96% rename from __fixtures__/with-subchart/charts/childchart/tests/service_test.yaml rename to __fixtures__/with-subchart/charts/child-chart/tests/service_test.yaml index ca22809b..ff51d5a1 100644 --- a/__fixtures__/with-subchart/charts/childchart/tests/service_test.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/tests/service_test.yaml @@ -19,7 +19,7 @@ tests: - equal: path: spec.selector value: - app: childchart + app: child-chart release: my-release - it: should render right if values given diff --git a/__fixtures__/with-subchart/charts/childchart/tests/values/image.yaml b/__fixtures__/with-subchart/charts/child-chart/tests/values/image.yaml similarity index 100% rename from __fixtures__/with-subchart/charts/childchart/tests/values/image.yaml rename to __fixtures__/with-subchart/charts/child-chart/tests/values/image.yaml diff --git a/__fixtures__/with-subchart/charts/childchart/values.yaml b/__fixtures__/with-subchart/charts/child-chart/values.yaml similarity index 91% rename from __fixtures__/with-subchart/charts/childchart/values.yaml rename to __fixtures__/with-subchart/charts/child-chart/values.yaml index 04f9f966..7f7d3509 100644 --- a/__fixtures__/with-subchart/charts/childchart/values.yaml +++ b/__fixtures__/with-subchart/charts/child-chart/values.yaml @@ -12,13 +12,11 @@ service: externalPort: 80 internalPort: 80 ingress: + class: nginx enabled: false # Used to create an Ingress record. hosts: - chart-example.local - annotations: - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" tls: # Secrets must be manually created in the namespace. # - secretName: chart-example-tls diff --git a/__fixtures__/with-subchart/templates/NOTES.txt b/__fixtures__/with-subchart/templates/NOTES.txt index 1a86eef9..30e62529 100644 --- a/__fixtures__/with-subchart/templates/NOTES.txt +++ b/__fixtures__/with-subchart/templates/NOTES.txt @@ -4,16 +4,16 @@ http://{{ . }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "basic.fullname" . }}) + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "parant-chart.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "basic.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "basic.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + You can watch the status of by running 'kubectl get svc -w {{ template "parant-chart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "parant-chart.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo http://$SERVICE_IP:{{ .Values.service.externalPort }} {{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "basic.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "parant-chart.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort }} {{- end }} diff --git a/__fixtures__/with-subchart/templates/_helpers.tpl b/__fixtures__/with-subchart/templates/_helpers.tpl index b417510b..0954d3e8 100644 --- a/__fixtures__/with-subchart/templates/_helpers.tpl +++ b/__fixtures__/with-subchart/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{- define "basic.name" -}} +{{- define "parent-chart.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -10,7 +10,7 @@ Expand the name of the chart. Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} -{{- define "basic.fullname" -}} +{{- define "parent-chart.fullname" -}} {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} diff --git a/__fixtures__/with-subchart/templates/deployment.yaml b/__fixtures__/with-subchart/templates/deployment.yaml index 33336006..5f639c53 100644 --- a/__fixtures__/with-subchart/templates/deployment.yaml +++ b/__fixtures__/with-subchart/templates/deployment.yaml @@ -1,9 +1,9 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: - name: {{ template "basic.fullname" . }} + name: {{ template "parent-chart.fullname" . }} labels: - app: {{ template "basic.name" . }} + app: {{ template "parent-chart.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} @@ -12,7 +12,7 @@ spec: template: metadata: labels: - app: {{ template "basic.name" . }} + app: {{ template "parent-chart.name" . }} release: {{ .Release.Name }} spec: containers: diff --git a/__fixtures__/with-subchart/templates/ingress.yaml b/__fixtures__/with-subchart/templates/ingress.yaml index e55c347d..88d0f7a2 100644 --- a/__fixtures__/with-subchart/templates/ingress.yaml +++ b/__fixtures__/with-subchart/templates/ingress.yaml @@ -1,12 +1,12 @@ {{- if .Values.ingress.enabled -}} -{{- $serviceName := include "basic.fullname" . -}} +{{- $serviceName := include "parent-chart.fullname" . -}} {{- $servicePort := .Values.service.externalPort -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ template "basic.fullname" . }} + name: {{ template "parent-chart.fullname" . }} labels: - app: {{ template "basic.name" . }} + app: {{ template "parent-chart.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} diff --git a/__fixtures__/with-subchart/templates/service.yaml b/__fixtures__/with-subchart/templates/service.yaml index 0d4d20eb..bb7f6786 100644 --- a/__fixtures__/with-subchart/templates/service.yaml +++ b/__fixtures__/with-subchart/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "basic.fullname" . }} + name: {{ template "parent-chart.fullname" . }} labels: - app: {{ template "basic.name" . }} + app: {{ template "parent-chart.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} @@ -15,5 +15,5 @@ spec: protocol: TCP name: {{ .Values.service.name }} selector: - app: {{ template "basic.name" . }} + app: {{ template "parent-chart.name" . }} release: {{ .Release.Name }} diff --git a/__fixtures__/with-subchart/tests/__snapshot__/deployment_test.yaml.snap b/__fixtures__/with-subchart/tests/__snapshot__/deployment_test.yaml.snap index d70d8503..f60e98b3 100644 --- a/__fixtures__/with-subchart/tests/__snapshot__/deployment_test.yaml.snap +++ b/__fixtures__/with-subchart/tests/__snapshot__/deployment_test.yaml.snap @@ -4,7 +4,7 @@ should pass all kinds of assertion: template: metadata: labels: - app: with-subchart + app: parent-chart release: RELEASE-NAME spec: containers: @@ -14,7 +14,7 @@ should pass all kinds of assertion: httpGet: path: / port: 8080 - name: with-subchart + name: parent-chart ports: - containerPort: 8080 readinessProbe: diff --git a/__fixtures__/with-subchart/tests/deployment_test.yaml b/__fixtures__/with-subchart/tests/deployment_test.yaml index 724a7201..73aa0a95 100644 --- a/__fixtures__/with-subchart/tests/deployment_test.yaml +++ b/__fixtures__/with-subchart/tests/deployment_test.yaml @@ -16,7 +16,7 @@ tests: value: nginx:stable - matchRegex: path: metadata.name - pattern: ^.*-with-subchart$ + pattern: ^.*-parent-chart$ - notMatchRegex: path: metadata.name pattern: ^.*-foobar$ diff --git a/__fixtures__/with-subchart/tests/ingress_test.yaml b/__fixtures__/with-subchart/tests/ingress_test.yaml index 55bcd04f..098628f2 100644 --- a/__fixtures__/with-subchart/tests/ingress_test.yaml +++ b/__fixtures__/with-subchart/tests/ingress_test.yaml @@ -23,7 +23,7 @@ tests: content: path: / backend: - serviceName: my-release-with-subchart + serviceName: my-release-parent-chart servicePort: 12345 - isNull: path: spec.tls diff --git a/__fixtures__/with-subchart/tests/service_test.yaml b/__fixtures__/with-subchart/tests/service_test.yaml index 515a287f..2254eb61 100644 --- a/__fixtures__/with-subchart/tests/service_test.yaml +++ b/__fixtures__/with-subchart/tests/service_test.yaml @@ -19,7 +19,7 @@ tests: - equal: path: spec.selector value: - app: with-subchart + app: parent-chart release: my-release - it: should render right if values given diff --git a/install-binary.sh b/install-binary.sh index ed648462..847b8222 100755 --- a/install-binary.sh +++ b/install-binary.sh @@ -63,18 +63,20 @@ verifySupported() { fi } + # getDownloadURL checks the latest available version. getDownloadURL() { - # Use the GitHub API to find the latest version for this project. - local latest_url="https://api.github.com/repos/$PROJECT_GH/releases/latest" - local version=$(git describe --tags --exact-match 2>/dev/null) + local version=$(git -C $HELM_PLUGIN_PATH describe --tags --exact-match 2>/dev/null) if [ -n "$version" ]; then - url="https://api.github.com/repos/$PROJECT_GH/releases/tags/$version" - fi - if type "curl" >/dev/null 2>&1; then - DOWNLOAD_URL=$(curl -s $latest_url | grep $OS-$ARCH | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') - elif type "wget" >/dev/null 2>&1; then - DOWNLOAD_URL=$(wget -q -O - $latest_url | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') + DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/$PROJECT_NAME-$OS-$ARCH.tgz" + else + # Use the GitHub API to find the download url for this project. + local url="https://api.github.com/repos/$PROJECT_GH/releases/latest" + if type "curl" > /dev/null; then + DOWNLOAD_URL=$(curl -s $url | grep $OS-$ARCH | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') + elif type "wget" > /dev/null; then + DOWNLOAD_URL=$(wget -q -O - $url | grep $OS-$ARCH | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') + fi fi } diff --git a/plugin.yaml b/plugin.yaml index ad3eb278..edcd7958 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,8 +1,9 @@ name: "unittest" -version: "0.1.2" +version: "0.1.5-rancher1" usage: "unittest for helm charts" description: "Unit test for helm chart in YAML with ease to keep your chart functional and robust." ignoreFlags: false command: "$HELM_PLUGIN_DIR/untt" hooks: install: "$HELM_PLUGIN_DIR/install-binary.sh" + update: "$HELM_PLUGIN_DIR/install-binary.sh" diff --git a/unittest/.snapshots/TestRunnerOkWithFailedTests b/unittest/.snapshots/TestRunnerOkWithFailedTests index b7eb069e..31c59004 100644 --- a/unittest/.snapshots/TestRunnerOkWithFailedTests +++ b/unittest/.snapshots/TestRunnerOkWithFailedTests @@ -121,8 +121,8 @@ - asserts[12] `hasDocuments` fail - Expected documents count: 2 - Actual: 1 + Expected documents count: 1 + Actual: 2 - asserts[13] `matchSnapshot` fail diff --git a/unittest/.snapshots/TestRunnerWithTestsInSubchart b/unittest/.snapshots/TestRunnerWithTestsInSubchart index a88e0cfc..2d0e806c 100644 --- a/unittest/.snapshots/TestRunnerWithTestsInSubchart +++ b/unittest/.snapshots/TestRunnerWithTestsInSubchart @@ -1,12 +1,12 @@ -### Chart [ with-subchart ] ../__fixtures__/with-subchart +### Chart [ parent-chart ] ../__fixtures__/with-subchart - PASS test deployment ../__fixtures__/with-subchart/charts/childchart/tests/deployment_test.yaml + PASS test deployment ../__fixtures__/with-subchart/charts/child-chart/tests/deployment_test.yaml PASS test deployment ../__fixtures__/with-subchart/tests/deployment_test.yaml - PASS test ingress ../__fixtures__/with-subchart/charts/childchart/tests/ingress_test.yaml + PASS test ingress ../__fixtures__/with-subchart/charts/child-chart/tests/ingress_test.yaml PASS test ingress ../__fixtures__/with-subchart/tests/ingress_test.yaml - PASS test service ../__fixtures__/with-subchart/charts/childchart/tests/service_test.yaml + PASS test service ../__fixtures__/with-subchart/charts/child-chart/tests/service_test.yaml PASS test service ../__fixtures__/with-subchart/tests/service_test.yaml diff --git a/unittest/.snapshots/TestRunnerWithTestsInSubchartButFlagFalse b/unittest/.snapshots/TestRunnerWithTestsInSubchartButFlagFalse index a882265d..9ba8ffe7 100644 --- a/unittest/.snapshots/TestRunnerWithTestsInSubchartButFlagFalse +++ b/unittest/.snapshots/TestRunnerWithTestsInSubchartButFlagFalse @@ -1,5 +1,5 @@ -### Chart [ with-subchart ] ../__fixtures__/with-subchart +### Chart [ parent-chart ] ../__fixtures__/with-subchart PASS test deployment ../__fixtures__/with-subchart/tests/deployment_test.yaml diff --git a/unittest/test_job.go b/unittest/test_job.go index 6177aee4..eb4bf45d 100644 --- a/unittest/test_job.go +++ b/unittest/test_job.go @@ -2,6 +2,7 @@ package unittest import ( "fmt" + "io" "io/ioutil" "path" "path/filepath" @@ -137,6 +138,7 @@ func (t *TestJob) renderChart(targetChart *chart.Chart, userValues []byte) (map[ if err != nil { return nil, err } + return outputOfFiles, nil } @@ -165,24 +167,32 @@ func (t *TestJob) parseManifestsFromOutputOfFiles(outputOfFiles map[string]strin error, ) { manifestsOfFiles := make(map[string][]common.K8sManifest) + for file, rendered := range outputOfFiles { + decoder := yaml.NewDecoder(strings.NewReader(rendered)) + if filepath.Ext(file) == ".yaml" { - documents := strings.Split(rendered, "---") - manifests := make([]common.K8sManifest, 0, len(documents)) + manifests := make([]common.K8sManifest, 0) - for _, doc := range documents { + for { manifest := make(common.K8sManifest) - if err := yaml.Unmarshal([]byte(doc), manifest); err != nil { - return nil, err + if err := decoder.Decode(manifest); err != nil { + if err == io.EOF { + break + } else { + return nil, err + } } if len(manifest) > 0 { manifests = append(manifests, manifest) } } + manifestsOfFiles[file] = manifests } } + return manifestsOfFiles, nil } @@ -212,8 +222,10 @@ func (t *TestJob) polishAssertionsTemplate(targetChart *chart.Chart) { if t.chartRoute == "" { t.chartRoute = targetChart.Metadata.Name } + for _, assertion := range t.Assertions { var templateToAssert string + if assertion.Template == "" { if t.defaultTemplateToAssert == "" { return @@ -222,6 +234,10 @@ func (t *TestJob) polishAssertionsTemplate(targetChart *chart.Chart) { } else { templateToAssert = assertion.Template } - assertion.Template = filepath.Join(t.chartRoute, "templates", templateToAssert) + + // map the file name to the path of helm rendered result + assertion.Template = filepath.ToSlash( + filepath.Join(t.chartRoute, "templates", templateToAssert), + ) } }
path: spec.ports
content:
name: server
port: 80
targetPort: 80
protocle: TCP