From 07e8d1bdb14e04c5dc2f87ab33eddd7ef39d4254 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:40:27 -0700 Subject: [PATCH 1/9] adding the config template to the helm deployment template --- .../helm/charts/templates/deployment.yaml | 17 +++-------------- template/deployments/helm/configmap.yaml | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 template/deployments/helm/configmap.yaml diff --git a/template/deployments/helm/charts/templates/deployment.yaml b/template/deployments/helm/charts/templates/deployment.yaml index dd1537e0..7844b67c 100644 --- a/template/deployments/helm/charts/templates/deployment.yaml +++ b/template/deployments/helm/charts/templates/deployment.yaml @@ -42,20 +42,9 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.containerPort }} - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} + envFrom: + - configMapRef: + name: configmap {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/template/deployments/helm/configmap.yaml b/template/deployments/helm/configmap.yaml new file mode 100644 index 00000000..46b43102 --- /dev/null +++ b/template/deployments/helm/configmap.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap +data: + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http \ No newline at end of file From 3be7c645b0b1be770f64b39e759aa11da10beb75 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:03:17 -0700 Subject: [PATCH 2/9] few changes to the configmap --- .../helm/charts/templates/configmap.yaml | 5 +++++ .../helm/charts/templates/deployment.yaml | 16 +++++++++++++++- template/deployments/helm/charts/values.yaml | 5 ++++- template/deployments/helm/configmap.yaml | 17 ----------------- 4 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 template/deployments/helm/charts/templates/configmap.yaml delete mode 100644 template/deployments/helm/configmap.yaml diff --git a/template/deployments/helm/charts/templates/configmap.yaml b/template/deployments/helm/charts/templates/configmap.yaml new file mode 100644 index 00000000..b0758dbc --- /dev/null +++ b/template/deployments/helm/charts/templates/configmap.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap +data: diff --git a/template/deployments/helm/charts/templates/deployment.yaml b/template/deployments/helm/charts/templates/deployment.yaml index 7844b67c..c59f94dc 100644 --- a/template/deployments/helm/charts/templates/deployment.yaml +++ b/template/deployments/helm/charts/templates/deployment.yaml @@ -42,9 +42,23 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: { { .Values.containerPort } } + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} envFrom: - configMapRef: - name: configmap + name: {{ .Values.configMapName }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/template/deployments/helm/charts/values.yaml b/template/deployments/helm/charts/values.yaml index 321227f8..41f98132 100644 --- a/template/deployments/helm/charts/values.yaml +++ b/template/deployments/helm/charts/values.yaml @@ -60,4 +60,7 @@ tolerations: [] affinity: {} -generatorLabel: {{.GENERATORLABEL}} \ No newline at end of file +generatorLabel: {{.GENERATORLABEL}} + +# environment variables will be read from the configmap.yaml +configMapName: configmap \ No newline at end of file diff --git a/template/deployments/helm/configmap.yaml b/template/deployments/helm/configmap.yaml deleted file mode 100644 index 46b43102..00000000 --- a/template/deployments/helm/configmap.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: configmap -data: - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http \ No newline at end of file From 9f5b0671e33df66e153fea174971b67ed95ac4b0 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:19:21 -0700 Subject: [PATCH 3/9] syntax fix --- template/deployments/helm/charts/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/deployments/helm/charts/templates/deployment.yaml b/template/deployments/helm/charts/templates/deployment.yaml index c59f94dc..421211e1 100644 --- a/template/deployments/helm/charts/templates/deployment.yaml +++ b/template/deployments/helm/charts/templates/deployment.yaml @@ -44,7 +44,7 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: { { .Values.containerPort } } + containerPort: {{ .Values.containerPort }} protocol: TCP livenessProbe: httpGet: From f97c990693f65267732cfd9fbeb6cef15cafab72 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:45:35 -0700 Subject: [PATCH 4/9] adding configmap to kustomize and manifests --- template/deployments/kustomize/base/configmap.yaml | 5 +++++ template/deployments/kustomize/base/deployment.yaml | 5 ++++- .../deployments/kustomize/overlays/production/configmap.yaml | 5 +++++ .../kustomize/overlays/production/deployment.yaml | 5 ++++- template/deployments/manifests/manifests/configmap.yaml | 5 +++++ template/deployments/manifests/manifests/deployment.yaml | 5 ++++- 6 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 template/deployments/kustomize/base/configmap.yaml create mode 100644 template/deployments/kustomize/overlays/production/configmap.yaml create mode 100644 template/deployments/manifests/manifests/configmap.yaml diff --git a/template/deployments/kustomize/base/configmap.yaml b/template/deployments/kustomize/base/configmap.yaml new file mode 100644 index 00000000..b0758dbc --- /dev/null +++ b/template/deployments/kustomize/base/configmap.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap +data: diff --git a/template/deployments/kustomize/base/deployment.yaml b/template/deployments/kustomize/base/deployment.yaml index 4e07bd64..508dcd8d 100644 --- a/template/deployments/kustomize/base/deployment.yaml +++ b/template/deployments/kustomize/base/deployment.yaml @@ -21,4 +21,7 @@ spec: image: {{.IMAGENAME}}:{{.IMAGETAG}} imagePullPolicy: Always ports: - - containerPort: {{.PORT}} \ No newline at end of file + - containerPort: {{.PORT}} + envFrom: + - configMapRef: + name: configmap \ No newline at end of file diff --git a/template/deployments/kustomize/overlays/production/configmap.yaml b/template/deployments/kustomize/overlays/production/configmap.yaml new file mode 100644 index 00000000..b0758dbc --- /dev/null +++ b/template/deployments/kustomize/overlays/production/configmap.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap +data: diff --git a/template/deployments/kustomize/overlays/production/deployment.yaml b/template/deployments/kustomize/overlays/production/deployment.yaml index 0929b145..eb19efd4 100644 --- a/template/deployments/kustomize/overlays/production/deployment.yaml +++ b/template/deployments/kustomize/overlays/production/deployment.yaml @@ -14,4 +14,7 @@ spec: spec: containers: - name: {{.APPNAME}} - image: {{.IMAGENAME}}:{{.IMAGETAG}} \ No newline at end of file + image: {{.IMAGENAME}}:{{.IMAGETAG}} + envFrom: + - configMapRef: + name: configmap \ No newline at end of file diff --git a/template/deployments/manifests/manifests/configmap.yaml b/template/deployments/manifests/manifests/configmap.yaml new file mode 100644 index 00000000..b0758dbc --- /dev/null +++ b/template/deployments/manifests/manifests/configmap.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap +data: diff --git a/template/deployments/manifests/manifests/deployment.yaml b/template/deployments/manifests/manifests/deployment.yaml index 4e07bd64..508dcd8d 100644 --- a/template/deployments/manifests/manifests/deployment.yaml +++ b/template/deployments/manifests/manifests/deployment.yaml @@ -21,4 +21,7 @@ spec: image: {{.IMAGENAME}}:{{.IMAGETAG}} imagePullPolicy: Always ports: - - containerPort: {{.PORT}} \ No newline at end of file + - containerPort: {{.PORT}} + envFrom: + - configMapRef: + name: configmap \ No newline at end of file From a8a74f471f23d7c9929feac4510e5180dba549b6 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:55:08 -0700 Subject: [PATCH 5/9] updated the configmap --- template/deployments/helm/charts/templates/configmap.yaml | 1 + template/deployments/kustomize/base/configmap.yaml | 1 + .../deployments/kustomize/overlays/production/configmap.yaml | 1 + template/deployments/manifests/manifests/configmap.yaml | 1 + 4 files changed, 4 insertions(+) diff --git a/template/deployments/helm/charts/templates/configmap.yaml b/template/deployments/helm/charts/templates/configmap.yaml index b0758dbc..2cdb3782 100644 --- a/template/deployments/helm/charts/templates/configmap.yaml +++ b/template/deployments/helm/charts/templates/configmap.yaml @@ -3,3 +3,4 @@ kind: ConfigMap metadata: name: configmap data: + key: "exampleValue" diff --git a/template/deployments/kustomize/base/configmap.yaml b/template/deployments/kustomize/base/configmap.yaml index b0758dbc..2cdb3782 100644 --- a/template/deployments/kustomize/base/configmap.yaml +++ b/template/deployments/kustomize/base/configmap.yaml @@ -3,3 +3,4 @@ kind: ConfigMap metadata: name: configmap data: + key: "exampleValue" diff --git a/template/deployments/kustomize/overlays/production/configmap.yaml b/template/deployments/kustomize/overlays/production/configmap.yaml index b0758dbc..1f453fce 100644 --- a/template/deployments/kustomize/overlays/production/configmap.yaml +++ b/template/deployments/kustomize/overlays/production/configmap.yaml @@ -3,3 +3,4 @@ kind: ConfigMap metadata: name: configmap data: + key: "exampleValue" \ No newline at end of file diff --git a/template/deployments/manifests/manifests/configmap.yaml b/template/deployments/manifests/manifests/configmap.yaml index b0758dbc..1f453fce 100644 --- a/template/deployments/manifests/manifests/configmap.yaml +++ b/template/deployments/manifests/manifests/configmap.yaml @@ -3,3 +3,4 @@ kind: ConfigMap metadata: name: configmap data: + key: "exampleValue" \ No newline at end of file From f54956ce95c6eabec1776fecd7d0d6243210b114 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:26:30 -0700 Subject: [PATCH 6/9] changes --- template/deployments/helm/charts/templates/configmap.yaml | 2 +- template/deployments/kustomize/base/configmap.yaml | 2 +- template/deployments/kustomize/base/kustomization.yaml | 3 ++- .../deployments/kustomize/overlays/production/configmap.yaml | 1 - .../kustomize/overlays/production/kustomization.yaml | 3 ++- template/deployments/manifests/manifests/configmap.yaml | 1 - 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/template/deployments/helm/charts/templates/configmap.yaml b/template/deployments/helm/charts/templates/configmap.yaml index 2cdb3782..7f2636be 100644 --- a/template/deployments/helm/charts/templates/configmap.yaml +++ b/template/deployments/helm/charts/templates/configmap.yaml @@ -3,4 +3,4 @@ kind: ConfigMap metadata: name: configmap data: - key: "exampleValue" + diff --git a/template/deployments/kustomize/base/configmap.yaml b/template/deployments/kustomize/base/configmap.yaml index 2cdb3782..7f2636be 100644 --- a/template/deployments/kustomize/base/configmap.yaml +++ b/template/deployments/kustomize/base/configmap.yaml @@ -3,4 +3,4 @@ kind: ConfigMap metadata: name: configmap data: - key: "exampleValue" + diff --git a/template/deployments/kustomize/base/kustomization.yaml b/template/deployments/kustomize/base/kustomization.yaml index ca1d88ef..b04efeef 100644 --- a/template/deployments/kustomize/base/kustomization.yaml +++ b/template/deployments/kustomize/base/kustomization.yaml @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - deployment.yaml - - service.yaml \ No newline at end of file + - service.yaml + - configmap.yaml \ No newline at end of file diff --git a/template/deployments/kustomize/overlays/production/configmap.yaml b/template/deployments/kustomize/overlays/production/configmap.yaml index 1f453fce..b0758dbc 100644 --- a/template/deployments/kustomize/overlays/production/configmap.yaml +++ b/template/deployments/kustomize/overlays/production/configmap.yaml @@ -3,4 +3,3 @@ kind: ConfigMap metadata: name: configmap data: - key: "exampleValue" \ No newline at end of file diff --git a/template/deployments/kustomize/overlays/production/kustomization.yaml b/template/deployments/kustomize/overlays/production/kustomization.yaml index d13c9cee..1cf6ad84 100644 --- a/template/deployments/kustomize/overlays/production/kustomization.yaml +++ b/template/deployments/kustomize/overlays/production/kustomization.yaml @@ -4,4 +4,5 @@ resources: - ../../base patchesStrategicMerge: - deployment.yaml - - service.yaml \ No newline at end of file + - service.yaml + - configmap.yaml \ No newline at end of file diff --git a/template/deployments/manifests/manifests/configmap.yaml b/template/deployments/manifests/manifests/configmap.yaml index 1f453fce..b0758dbc 100644 --- a/template/deployments/manifests/manifests/configmap.yaml +++ b/template/deployments/manifests/manifests/configmap.yaml @@ -3,4 +3,3 @@ kind: ConfigMap metadata: name: configmap data: - key: "exampleValue" \ No newline at end of file From 7d1a8c2e81e60be1a7da85c8452c8b887722d5b9 Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:43:11 -0700 Subject: [PATCH 7/9] updating the helm deployment files --- template/deployments/helm/charts/templates/configmap.yaml | 4 ++-- template/deployments/helm/charts/templates/deployment.yaml | 2 +- template/deployments/helm/charts/values.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/template/deployments/helm/charts/templates/configmap.yaml b/template/deployments/helm/charts/templates/configmap.yaml index 7f2636be..513a5dce 100644 --- a/template/deployments/helm/charts/templates/configmap.yaml +++ b/template/deployments/helm/charts/templates/configmap.yaml @@ -1,6 +1,6 @@ apiVersion: v1 kind: ConfigMap metadata: - name: configmap + name: envvars-configmap data: - + envVariables: {{ print "{{ .Values.envVariables }}" }} \ No newline at end of file diff --git a/template/deployments/helm/charts/templates/deployment.yaml b/template/deployments/helm/charts/templates/deployment.yaml index 421211e1..1d58acbb 100644 --- a/template/deployments/helm/charts/templates/deployment.yaml +++ b/template/deployments/helm/charts/templates/deployment.yaml @@ -58,7 +58,7 @@ spec: {{- toYaml .Values.resources | nindent 12 }} envFrom: - configMapRef: - name: {{ .Values.configMapName }} + name: envvars-configmap {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/template/deployments/helm/charts/values.yaml b/template/deployments/helm/charts/values.yaml index 41f98132..919c1bd2 100644 --- a/template/deployments/helm/charts/values.yaml +++ b/template/deployments/helm/charts/values.yaml @@ -63,4 +63,4 @@ affinity: {} generatorLabel: {{.GENERATORLABEL}} # environment variables will be read from the configmap.yaml -configMapName: configmap \ No newline at end of file +envVariables: \ No newline at end of file From 45b465e97626f340af7019129b5f9ba430d9211d Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:52:31 -0700 Subject: [PATCH 8/9] updated the kustomize and manifest deployment templates --- .dockerignore | 9 +---- Dockerfile | 37 +++++++------------ pkg/config/draftconfig.go | 4 +- pkg/osutil/osutil.go | 2 +- pkg/osutil/osutil_test.go | 10 ++--- .../deployments/kustomize/base/configmap.yaml | 3 +- .../kustomize/base/deployment.yaml | 2 +- template/deployments/kustomize/draft.yaml | 6 +++ .../overlays/production/configmap.yaml | 3 +- .../overlays/production/deployment.yaml | 2 +- template/deployments/manifests/draft.yaml | 6 +++ .../manifests/manifests/configmap.yaml | 3 +- .../manifests/manifests/deployment.yaml | 2 +- 13 files changed, 45 insertions(+), 44 deletions(-) diff --git a/.dockerignore b/.dockerignore index 1f9c9352..843dec4f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,2 @@ -vendor/ -.idea/ -/pkg/deployments/deployTypes/ -/pkg/workflows/workflow/ -.DS_Store -draft -langtest \ No newline at end of file +Dockerfile +charts/ diff --git a/Dockerfile b/Dockerfile index 7b2d1b67..bf92baf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,14 @@ -FROM golang:1.22-alpine - -WORKDIR /draft - -RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo make -RUN apk add py3-pip - -RUN python3 -m venv az-cli-env -RUN az-cli-env/bin/pip install --upgrade pip -RUN az-cli-env/bin/pip install --upgrade setuptools -RUN az-cli-env/bin/pip install --upgrade azure-cli -RUN az-cli-env/bin/pip install --upgrade setuptools -RUN az-cli-env/bin/az --version - -ENV PATH "$PATH:/draft/az-cli-env/bin" - -RUN apk add github-cli - -COPY . ./ -RUN make go-generate - -RUN go mod download -ENTRYPOINT ["go"] \ No newline at end of file +FROM golang:1.18 AS builder +ENV PORT 80 +EXPOSE 80 + +WORKDIR /build +COPY go.mod go.sum ./ +RUN go mod download && go mod verify +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -v -o app-binary + +FROM gcr.io/distroless/static-debian12 +WORKDIR /app +COPY --from=builder /build/app-binary . +CMD ["/app/app-binary"] diff --git a/pkg/config/draftconfig.go b/pkg/config/draftconfig.go index fc7c57e3..5c648e2c 100644 --- a/pkg/config/draftconfig.go +++ b/pkg/config/draftconfig.go @@ -65,8 +65,8 @@ func (d *DraftConfig) GetVariableExampleValues() map[string][]string { } // Returns a map of variable names to values used in Gotemplate -func (d *DraftConfig) GetVariableMap() map[string]string { - variableMap := make(map[string]string) +func (d *DraftConfig) GetVariableMap() map[string]interface{} { + variableMap := make(map[string]interface{}) for _, variable := range d.Variables { variableMap[variable.Name] = variable.Value } diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go index 4d83f11b..98a9ff9e 100644 --- a/pkg/osutil/osutil.go +++ b/pkg/osutil/osutil.go @@ -213,7 +213,7 @@ func CopyDirWithTemplates( return nil } -func replaceGoTemplateVariables(fileSys fs.FS, srcPath string, variableMap map[string]string) ([]byte, error) { +func replaceGoTemplateVariables(fileSys fs.FS, srcPath string, variableMap map[string]interface{}) ([]byte, error) { file, err := fs.ReadFile(fileSys, srcPath) if err != nil { return nil, err diff --git a/pkg/osutil/osutil_test.go b/pkg/osutil/osutil_test.go index 33ce8b70..1837492b 100644 --- a/pkg/osutil/osutil_test.go +++ b/pkg/osutil/osutil_test.go @@ -217,7 +217,7 @@ func TestReplaceGoTemplateVariables(t *testing.T) { name string fileSys fs.FS srcPath string - variableMap map[string]string + variableMap map[string]interface{} expected string expectedError bool }{ @@ -227,7 +227,7 @@ func TestReplaceGoTemplateVariables(t *testing.T) { "template.txt": &fstest.MapFile{Data: []byte("Hello, {{.Name}}!")}, }, srcPath: "template.txt", - variableMap: map[string]string{"Name": "Joe"}, + variableMap: map[string]interface{}{"Name": "Joe"}, expected: "Hello, Joe!", expectedError: false, }, @@ -237,7 +237,7 @@ func TestReplaceGoTemplateVariables(t *testing.T) { "template.txt": &fstest.MapFile{Data: []byte("Hello, {{.Name}}!")}, }, srcPath: "template.txt", - variableMap: map[string]string{}, + variableMap: map[string]interface{}{}, expected: "", expectedError: true, }, @@ -247,7 +247,7 @@ func TestReplaceGoTemplateVariables(t *testing.T) { "template.txt": &fstest.MapFile{Data: []byte("Hello, {{.Name}}!")}, }, srcPath: "nonexistent.txt", - variableMap: map[string]string{"Name": "Joe"}, + variableMap: map[string]interface{}{"Name": "Joe"}, expected: "", expectedError: true, }, @@ -257,7 +257,7 @@ func TestReplaceGoTemplateVariables(t *testing.T) { "template.txt": &fstest.MapFile{Data: []byte("Hello, {{.Name}} and {{.Place}}!")}, }, srcPath: "template.txt", - variableMap: map[string]string{"Name": "Joe"}, + variableMap: map[string]interface{}{"Name": "Joe"}, expected: "", expectedError: true, }, diff --git a/template/deployments/kustomize/base/configmap.yaml b/template/deployments/kustomize/base/configmap.yaml index 7f2636be..0063413f 100644 --- a/template/deployments/kustomize/base/configmap.yaml +++ b/template/deployments/kustomize/base/configmap.yaml @@ -1,6 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: configmap + name: envvars-configmap data: + {{ .ENVVARIABLES }} diff --git a/template/deployments/kustomize/base/deployment.yaml b/template/deployments/kustomize/base/deployment.yaml index 508dcd8d..57ee63f0 100644 --- a/template/deployments/kustomize/base/deployment.yaml +++ b/template/deployments/kustomize/base/deployment.yaml @@ -24,4 +24,4 @@ spec: - containerPort: {{.PORT}} envFrom: - configMapRef: - name: configmap \ No newline at end of file + name: envvars-configmap \ No newline at end of file diff --git a/template/deployments/kustomize/draft.yaml b/template/deployments/kustomize/draft.yaml index d8b79d0d..f6077bb6 100644 --- a/template/deployments/kustomize/draft.yaml +++ b/template/deployments/kustomize/draft.yaml @@ -44,3 +44,9 @@ variables: disablePrompt: true value: "draft" description: "the label to identify who generated the resource" + - name: "ENVVARIABLES" + type: "map" + kind: "environmentVariables" + description: "environment variables for the application" + default: + value: key1=value1 \ No newline at end of file diff --git a/template/deployments/kustomize/overlays/production/configmap.yaml b/template/deployments/kustomize/overlays/production/configmap.yaml index b0758dbc..5d99e8c5 100644 --- a/template/deployments/kustomize/overlays/production/configmap.yaml +++ b/template/deployments/kustomize/overlays/production/configmap.yaml @@ -1,5 +1,6 @@ apiVersion: v1 kind: ConfigMap metadata: - name: configmap + name: envvars-configmap data: + {{ .ENVVARIABLES }} diff --git a/template/deployments/kustomize/overlays/production/deployment.yaml b/template/deployments/kustomize/overlays/production/deployment.yaml index eb19efd4..73861e1f 100644 --- a/template/deployments/kustomize/overlays/production/deployment.yaml +++ b/template/deployments/kustomize/overlays/production/deployment.yaml @@ -17,4 +17,4 @@ spec: image: {{.IMAGENAME}}:{{.IMAGETAG}} envFrom: - configMapRef: - name: configmap \ No newline at end of file + name: envvars-configmap \ No newline at end of file diff --git a/template/deployments/manifests/draft.yaml b/template/deployments/manifests/draft.yaml index 168794ad..46f7bbf0 100644 --- a/template/deployments/manifests/draft.yaml +++ b/template/deployments/manifests/draft.yaml @@ -44,3 +44,9 @@ variables: disablePrompt: true value: "draft" description: "the label to identify who generated the resource" + - name: "ENVVARIABLES" + type: "map" + kind: "environmentVariables" + description: "environment variables for the application" + default: + value: key1=value1 \ No newline at end of file diff --git a/template/deployments/manifests/manifests/configmap.yaml b/template/deployments/manifests/manifests/configmap.yaml index b0758dbc..fd7c2619 100644 --- a/template/deployments/manifests/manifests/configmap.yaml +++ b/template/deployments/manifests/manifests/configmap.yaml @@ -1,5 +1,6 @@ apiVersion: v1 kind: ConfigMap metadata: - name: configmap + name: envvars-configmap data: + {{ .ENVVARIABLES }} \ No newline at end of file diff --git a/template/deployments/manifests/manifests/deployment.yaml b/template/deployments/manifests/manifests/deployment.yaml index 508dcd8d..57ee63f0 100644 --- a/template/deployments/manifests/manifests/deployment.yaml +++ b/template/deployments/manifests/manifests/deployment.yaml @@ -24,4 +24,4 @@ spec: - containerPort: {{.PORT}} envFrom: - configMapRef: - name: configmap \ No newline at end of file + name: envvars-configmap \ No newline at end of file From 565236a6675ecccb66f151bc860919ca54fb5c5e Mon Sep 17 00:00:00 2001 From: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:25:48 -0700 Subject: [PATCH 9/9] addressing comments --- .dockerignore | 9 ++++- Dockerfile | 37 ++++++++++++------- .../helm/charts/templates/configmap.yaml | 9 ++++- template/deployments/helm/charts/values.yaml | 2 +- template/deployments/helm/draft.yaml | 4 ++ template/deployments/kustomize/draft.yaml | 4 +- template/deployments/manifests/draft.yaml | 4 +- 7 files changed, 45 insertions(+), 24 deletions(-) diff --git a/.dockerignore b/.dockerignore index 843dec4f..44e96d03 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,7 @@ -Dockerfile -charts/ +vendor/ +.idea/ +/pkg/deployments/deployTypes/ +/pkg/workflows/workflow/ +.DS_Store +draft +langtest diff --git a/Dockerfile b/Dockerfile index bf92baf6..1f556309 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ -FROM golang:1.18 AS builder -ENV PORT 80 -EXPOSE 80 - -WORKDIR /build -COPY go.mod go.sum ./ -RUN go mod download && go mod verify -COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -v -o app-binary - -FROM gcr.io/distroless/static-debian12 -WORKDIR /app -COPY --from=builder /build/app-binary . -CMD ["/app/app-binary"] +FROM golang:1.22-alpine + +WORKDIR /draft + +RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo make +RUN apk add py3-pip + +RUN python3 -m venv az-cli-env +RUN az-cli-env/bin/pip install --upgrade pip +RUN az-cli-env/bin/pip install --upgrade setuptools +RUN az-cli-env/bin/pip install --upgrade azure-cli +RUN az-cli-env/bin/pip install --upgrade setuptools +RUN az-cli-env/bin/az --version + +ENV PATH "$PATH:/draft/az-cli-env/bin" + +RUN apk add github-cli + +COPY . ./ +RUN make go-generate + +RUN go mod download +ENTRYPOINT ["go"] diff --git a/template/deployments/helm/charts/templates/configmap.yaml b/template/deployments/helm/charts/templates/configmap.yaml index 513a5dce..44d10f52 100644 --- a/template/deployments/helm/charts/templates/configmap.yaml +++ b/template/deployments/helm/charts/templates/configmap.yaml @@ -3,4 +3,11 @@ kind: ConfigMap metadata: name: envvars-configmap data: - envVariables: {{ print "{{ .Values.envVariables }}" }} \ No newline at end of file + {{- if .Values.envVariables }} + {{- range $key, $value := .Values.envVariables }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + {{- else }} + # No environment variables provided + {{- end }} \ No newline at end of file diff --git a/template/deployments/helm/charts/values.yaml b/template/deployments/helm/charts/values.yaml index 919c1bd2..14331e03 100644 --- a/template/deployments/helm/charts/values.yaml +++ b/template/deployments/helm/charts/values.yaml @@ -63,4 +63,4 @@ affinity: {} generatorLabel: {{.GENERATORLABEL}} # environment variables will be read from the configmap.yaml -envVariables: \ No newline at end of file +envVariables: {{.ENVVARIABLES}} \ No newline at end of file diff --git a/template/deployments/helm/draft.yaml b/template/deployments/helm/draft.yaml index eaae9017..55a92db8 100644 --- a/template/deployments/helm/draft.yaml +++ b/template/deployments/helm/draft.yaml @@ -44,3 +44,7 @@ variables: disablePrompt: true value: "draft" description: "the label to identify who generated the resource" + - name: "ENVVARIABLES" + type: "map" + kind: "environmentVariables" + description: "environment variables for the application" \ No newline at end of file diff --git a/template/deployments/kustomize/draft.yaml b/template/deployments/kustomize/draft.yaml index f6077bb6..8e3e8db4 100644 --- a/template/deployments/kustomize/draft.yaml +++ b/template/deployments/kustomize/draft.yaml @@ -47,6 +47,4 @@ variables: - name: "ENVVARIABLES" type: "map" kind: "environmentVariables" - description: "environment variables for the application" - default: - value: key1=value1 \ No newline at end of file + description: "environment variables for the application" \ No newline at end of file diff --git a/template/deployments/manifests/draft.yaml b/template/deployments/manifests/draft.yaml index 46f7bbf0..6f4f329a 100644 --- a/template/deployments/manifests/draft.yaml +++ b/template/deployments/manifests/draft.yaml @@ -47,6 +47,4 @@ variables: - name: "ENVVARIABLES" type: "map" kind: "environmentVariables" - description: "environment variables for the application" - default: - value: key1=value1 \ No newline at end of file + description: "environment variables for the application" \ No newline at end of file