Skip to content

Commit

Permalink
rename helm imageKey to image to match starter workflows (Azure#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamero authored and aamgayle committed Mar 23, 2023
1 parent 1562ebf commit 983cd20
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ go-generate:
GO111MODULE=on go generate ./pkg/workflows/...; \
GO111MODULE=on go generate ./pkg/addons/...;

.PHONY: test
test: run-unit-tests run-e2e-tests-local

.PHONY: run-unit-tests
run-unit-tests:
docker build . -t gotest && docker run -t --rm --name draft-test gotest test ./... -buildvcs=false
Expand Down
6 changes: 3 additions & 3 deletions pkg/workflows/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type ServiceManifest interface {
}

type HelmProductionYaml struct {
ImageKey imageKey `yaml:"imageKey"`
Service service `yaml:"service"`
Image image `yaml:"image"`
Service service `yaml:"service"`
}

type service struct {
Expand All @@ -30,7 +30,7 @@ type service struct {
Port string `yaml:"port"`
}

type imageKey struct {
type image struct {
Repository string `yaml:"repository"`
PullPolicy string `yaml:"pullPolicy"`
Tag string `yaml:"tag"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func setHelmContainerImage(filePath, productionImage string) error {
return err
}

deploy.ImageKey.Repository = productionImage
deploy.Image.Repository = productionImage

out, err := yaml.Marshal(deploy)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestUpdateProductionDeployments(t *testing.T) {

helmDeploy := &HelmProductionYaml{}
assert.Nil(t, helmDeploy.LoadFromFile(helmFileName))
assert.Equal(t, "testImage", helmDeploy.ImageKey.Repository)
assert.Equal(t, "testImage", helmDeploy.Image.Repository)

assert.Nil(t, setDeploymentContainerImage(deploymentFileName, "testImage"))
decode := scheme.Codecs.UniversalDeserializer().Decode
Expand Down
2 changes: 1 addition & 1 deletion template/deployments/helm/charts/production.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
imageKey:
image:
repository: "{{APPNAME}}"
pullPolicy: IfNotPresent
tag: "latest"
Expand Down
4 changes: 2 additions & 2 deletions template/deployments/helm/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.imageKey.repository }}"
imagePullPolicy: {{ .Values.imageKey.pullPolicy }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
Expand Down
3 changes: 2 additions & 1 deletion template/deployments/helm/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace: {{NAMESPACE}}

containerPort: {{PORT}}

imageKey:
image:
repository: {{IMAGENAME}}
tag: {{IMAGETAG}}
pullPolicy: IfNotPresent


Expand Down
7 changes: 6 additions & 1 deletion template/deployments/helm/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ variables:
description: " the namespace to place new resources in"
- name: "IMAGENAME"
description: "the name of the image to use in the deployment"
- name: "IMAGETAG"
description: "the tag of the image to use in the deployment"
variableDefaults:
- name: "PORT"
value: 80
Expand All @@ -17,4 +19,7 @@ variableDefaults:
- name: "NAMESPACE"
value: default
- name: "IMAGENAME"
referenceVar: "APPNAME"
referenceVar: "APPNAME"
- name: "IMAGETAG"
value: "latest"
disablePrompt: true
2 changes: 1 addition & 1 deletion template/deployments/kustomize/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ spec:
spec:
containers:
- name: {{APPNAME}}
image: {{IMAGENAME}}
image: {{IMAGENAME}}:{{IMAGETAG}}
ports:
- containerPort: {{PORT}}
7 changes: 6 additions & 1 deletion template/deployments/kustomize/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ variables:
description: " the namespace to place new resources in"
- name: "IMAGENAME"
description: "the name of the image to use in the deployment"
- name: "IMAGETAG"
description: "the tag of the image to use in the deployment"
variableDefaults:
- name: "PORT"
value: 80
Expand All @@ -17,4 +19,7 @@ variableDefaults:
- name: "NAMESPACE"
value: default
- name: "IMAGENAME"
referenceVar: "APPNAME"
referenceVar: "APPNAME"
- name: "IMAGETAG"
value: "latest"
disablePrompt: true
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ spec:
spec:
containers:
- name: {{APPNAME}}
image: {{IMAGENAME}}
image: {{IMAGENAME}}:{{IMAGETAG}}
7 changes: 6 additions & 1 deletion template/deployments/manifests/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ variables:
description: " the namespace to place new resources in"
- name: "IMAGENAME"
description: "the name of the image to use in the deployment"
- name: "IMAGETAG"
description: "the tag of the image to use in the deployment"
variableDefaults:
- name: "PORT"
value: 80
Expand All @@ -17,4 +19,7 @@ variableDefaults:
- name: "NAMESPACE"
value: default
- name: "IMAGENAME"
referenceVar: "APPNAME"
referenceVar: "APPNAME"
- name: "IMAGETAG"
value: "latest"
disablePrompt: true
2 changes: 1 addition & 1 deletion template/deployments/manifests/manifests/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ spec:
spec:
containers:
- name: {{APPNAME}}
image: {{IMAGENAME}}
image: {{IMAGENAME}}:{{IMAGETAG}}
ports:
- containerPort: {{PORT}}
2 changes: 1 addition & 1 deletion test/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ deploy:
- name: my-chart
chartPath: charts
artifactOverrides:
imageKey: my-app
image: my-app
imageStrategy:
helm: {}
2 changes: 1 addition & 1 deletion test/templates/helm/charts/production.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
imageKey:
image:
repository: "test"
pullPolicy: IfNotPresent
tag: "latest"
Expand Down
4 changes: 2 additions & 2 deletions test/templates/helm/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.imageKey.repository }}:{{ .Values.imageKey.tag }}"
imagePullPolicy: {{ .Values.imageKey.pullPolicy }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
Expand Down
2 changes: 1 addition & 1 deletion test/templates/helm/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

containerPort: 8080

imageKey:
image:
repository: test
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
Expand Down
2 changes: 1 addition & 1 deletion test/templates/helm_prod_values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
imageKey:
image:
repository: "prodImage"
pullPolicy: IfNotPresent
tag: "latest"

0 comments on commit 983cd20

Please sign in to comment.