diff --git a/integration/render_test.go b/integration/render_test.go index 834dc19da4d..f70d516e2f6 100644 --- a/integration/render_test.go +++ b/integration/render_test.go @@ -365,8 +365,112 @@ spec: pathType: ImplementationSpecific `, }, { - description: "Template with Release.namespace set from skaffold.yaml file", - dir: "testdata/helm-namespace", + description: "Template with Release.namespace set from skaffold.yaml file deploy.helm.releases.namespace", + dir: "testdata/helm-deploy-namespace", + withoutBuildJSON: true, + expectedOut: `apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + name: skaffold-helm + namespace: helm-namespace +spec: + replicas: 2 + selector: + matchLabels: + app: skaffold-helm + template: + metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + spec: + containers: + - image: skaffold-helm:latest + name: skaffold-helm +`, + }, { + description: "Template with Release.namespace set from skaffold.yaml file manifests.helm.releases.namespace", + dir: "testdata/helm-manifests-namespace", + withoutBuildJSON: true, + expectedOut: `apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + name: skaffold-helm + namespace: helm-namespace +spec: + replicas: 2 + selector: + matchLabels: + app: skaffold-helm + template: + metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + spec: + containers: + - image: skaffold-helm:latest + name: skaffold-helm +`, + }, { + description: "Template with Release.namespace set from skaffold.yaml file manifests.helm.releases.namespace and deploy.helm.releases.namespace", + dir: "testdata/helm-manifests-and-deploy-namespace", + withoutBuildJSON: true, + expectedOut: `apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + name: skaffold-helm + namespace: helm-namespace-1 +spec: + replicas: 2 + selector: + matchLabels: + app: skaffold-helm + template: + metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + spec: + containers: + - image: skaffold-helm:latest + name: skaffold-helm +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + name: skaffold-helm + namespace: helm-namespace-2 +spec: + replicas: 2 + selector: + matchLabels: + app: skaffold-helm + template: + metadata: + labels: + app: skaffold-helm + skaffold.dev/run-id: phony-run-id + spec: + containers: + - image: skaffold-helm:latest + name: skaffold-helm +`, + }, { + description: "Template with Release.namespace set from skaffold.yaml file deploy.helm.releases.namespace - v1 skaffold schema", + dir: "testdata/helm-deploy-namespace-v1-schema", withoutBuildJSON: true, expectedOut: `apiVersion: apps/v1 kind: Deployment diff --git a/integration/testdata/helm-namespace/charts/Chart.yaml b/integration/testdata/helm-deploy-namespace-v1-schema/charts/Chart.yaml similarity index 100% rename from integration/testdata/helm-namespace/charts/Chart.yaml rename to integration/testdata/helm-deploy-namespace-v1-schema/charts/Chart.yaml diff --git a/integration/testdata/helm-namespace/charts/templates/deployment.yaml b/integration/testdata/helm-deploy-namespace-v1-schema/charts/templates/deployment.yaml similarity index 100% rename from integration/testdata/helm-namespace/charts/templates/deployment.yaml rename to integration/testdata/helm-deploy-namespace-v1-schema/charts/templates/deployment.yaml diff --git a/integration/testdata/helm-namespace/charts/values.yaml b/integration/testdata/helm-deploy-namespace-v1-schema/charts/values.yaml similarity index 100% rename from integration/testdata/helm-namespace/charts/values.yaml rename to integration/testdata/helm-deploy-namespace-v1-schema/charts/values.yaml diff --git a/integration/testdata/helm-deploy-namespace-v1-schema/skaffold.yaml b/integration/testdata/helm-deploy-namespace-v1-schema/skaffold.yaml new file mode 100644 index 00000000000..27deff4c36a --- /dev/null +++ b/integration/testdata/helm-deploy-namespace-v1-schema/skaffold.yaml @@ -0,0 +1,9 @@ +apiVersion: skaffold/v2beta29 +kind: Config + +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: charts + namespace: helm-namespace \ No newline at end of file diff --git a/integration/testdata/helm-deploy-namespace/charts/Chart.yaml b/integration/testdata/helm-deploy-namespace/charts/Chart.yaml new file mode 100644 index 00000000000..82cbe036a7e --- /dev/null +++ b/integration/testdata/helm-deploy-namespace/charts/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: Skaffold example with Helm +name: skaffold-helm +version: 0.1.0 diff --git a/integration/testdata/helm-deploy-namespace/charts/templates/deployment.yaml b/integration/testdata/helm-deploy-namespace/charts/templates/deployment.yaml new file mode 100644 index 00000000000..aea1d4fdd3f --- /dev/null +++ b/integration/testdata/helm-deploy-namespace/charts/templates/deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Chart.Name }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} diff --git a/integration/testdata/helm-deploy-namespace/charts/values.yaml b/integration/testdata/helm-deploy-namespace/charts/values.yaml new file mode 100644 index 00000000000..b5041524234 --- /dev/null +++ b/integration/testdata/helm-deploy-namespace/charts/values.yaml @@ -0,0 +1,5 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 2 +image: skaffold-helm:latest diff --git a/integration/testdata/helm-namespace/skaffold.yaml b/integration/testdata/helm-deploy-namespace/skaffold.yaml similarity index 100% rename from integration/testdata/helm-namespace/skaffold.yaml rename to integration/testdata/helm-deploy-namespace/skaffold.yaml diff --git a/integration/testdata/helm-manifests-and-deploy-namespace/charts/Chart.yaml b/integration/testdata/helm-manifests-and-deploy-namespace/charts/Chart.yaml new file mode 100644 index 00000000000..82cbe036a7e --- /dev/null +++ b/integration/testdata/helm-manifests-and-deploy-namespace/charts/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: Skaffold example with Helm +name: skaffold-helm +version: 0.1.0 diff --git a/integration/testdata/helm-manifests-and-deploy-namespace/charts/templates/deployment.yaml b/integration/testdata/helm-manifests-and-deploy-namespace/charts/templates/deployment.yaml new file mode 100644 index 00000000000..aea1d4fdd3f --- /dev/null +++ b/integration/testdata/helm-manifests-and-deploy-namespace/charts/templates/deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Chart.Name }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} diff --git a/integration/testdata/helm-manifests-and-deploy-namespace/charts/values.yaml b/integration/testdata/helm-manifests-and-deploy-namespace/charts/values.yaml new file mode 100644 index 00000000000..b5041524234 --- /dev/null +++ b/integration/testdata/helm-manifests-and-deploy-namespace/charts/values.yaml @@ -0,0 +1,5 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 2 +image: skaffold-helm:latest diff --git a/integration/testdata/helm-manifests-and-deploy-namespace/skaffold.yaml b/integration/testdata/helm-manifests-and-deploy-namespace/skaffold.yaml new file mode 100644 index 00000000000..57df4e3a137 --- /dev/null +++ b/integration/testdata/helm-manifests-and-deploy-namespace/skaffold.yaml @@ -0,0 +1,14 @@ +apiVersion: skaffold/v4beta2 +kind: Config +manifests: + helm: + releases: + - name: skaffold-helm + chartPath: charts + namespace: helm-namespace-1 +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: charts + namespace: helm-namespace-2 \ No newline at end of file diff --git a/integration/testdata/helm-manifests-namespace/charts/Chart.yaml b/integration/testdata/helm-manifests-namespace/charts/Chart.yaml new file mode 100644 index 00000000000..82cbe036a7e --- /dev/null +++ b/integration/testdata/helm-manifests-namespace/charts/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: Skaffold example with Helm +name: skaffold-helm +version: 0.1.0 diff --git a/integration/testdata/helm-manifests-namespace/charts/templates/deployment.yaml b/integration/testdata/helm-manifests-namespace/charts/templates/deployment.yaml new file mode 100644 index 00000000000..aea1d4fdd3f --- /dev/null +++ b/integration/testdata/helm-manifests-namespace/charts/templates/deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Chart.Name }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} diff --git a/integration/testdata/helm-manifests-namespace/charts/values.yaml b/integration/testdata/helm-manifests-namespace/charts/values.yaml new file mode 100644 index 00000000000..b5041524234 --- /dev/null +++ b/integration/testdata/helm-manifests-namespace/charts/values.yaml @@ -0,0 +1,5 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 2 +image: skaffold-helm:latest diff --git a/integration/testdata/helm-manifests-namespace/skaffold.yaml b/integration/testdata/helm-manifests-namespace/skaffold.yaml new file mode 100644 index 00000000000..4b41e74c56c --- /dev/null +++ b/integration/testdata/helm-manifests-namespace/skaffold.yaml @@ -0,0 +1,8 @@ +apiVersion: skaffold/v4beta2 +kind: Config +manifests: + helm: + releases: + - name: skaffold-helm + chartPath: charts + namespace: helm-namespace \ No newline at end of file