diff --git a/assets/auto-deploy-app/Chart.yaml b/assets/auto-deploy-app/Chart.yaml index 800ba75ad48ef1e75beaedd74f8ad91cc8df599c..ab83790ea2f6fd0a84714cbde324b7244129ce24 100644 --- a/assets/auto-deploy-app/Chart.yaml +++ b/assets/auto-deploy-app/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 description: GitLab's Auto-deploy Helm Chart name: auto-deploy-app -version: 2.27.0 +version: 2.28.0 icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png diff --git a/assets/auto-deploy-app/README.md b/assets/auto-deploy-app/README.md index b962f90f108d355f2856e9a896bdf0a8866d0921..33b9619a04923ecd67beae169e06f51ab22cf880 100644 --- a/assets/auto-deploy-app/README.md +++ b/assets/auto-deploy-app/README.md @@ -35,6 +35,8 @@ | application.secretName | Pass in the name of a Secret which the deployment will [load all key-value pairs from the Secret as environment variables](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables) in the application container. | `nil` | | application.secretChecksum | Pass in the checksum of the secrets referenced by `application.secretName`. | `nil` | | application.database_url | If present, sets the `DATABASE_URL` environment variable. If postgres is enabled this will be autogenerated. | `nil` | +| application.command | If present, overrides docker image `ENTRYPOINT`. Needs to be an array. | `nil` | +| application.args | If present, overrides docker image `CMD`. Needs to be an array. | `nil` | | hpa.enabled | If true, enables horizontal pod autoscaler. A resource request is also required to be set, such as `resources.requests.cpu: 200m`.| `false` | | hpa.minReplicas | | `1` | | hpa.maxReplicas | | `5` | diff --git a/assets/auto-deploy-app/templates/deployment.yaml b/assets/auto-deploy-app/templates/deployment.yaml index d47fad452a924ee4f5b7aec749db717ea8fdeb01..453a36398c494d7003cce32b475704e4dcbf98df 100644 --- a/assets/auto-deploy-app/templates/deployment.yaml +++ b/assets/auto-deploy-app/templates/deployment.yaml @@ -80,6 +80,14 @@ spec: - name: {{ .Chart.Name }} image: {{ template "imagename" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} +{{- if .Values.application.command }} + command: +{{ toYaml .Values.application.command | indent 8 }} +{{- end }} +{{- if .Values.application.args }} + args: +{{ toYaml .Values.application.args | indent 8 }} +{{- end }} {{- if .Values.application.secretName }} envFrom: - secretRef: diff --git a/assets/auto-deploy-app/test/templates/deployment_test.go b/assets/auto-deploy-app/test/templates/deployment_test.go index d06b636cce601e17afb4a702a909bd0479169d8f..c6093adebd034cb1498ef5c83e98ffc2ef068ae0 100644 --- a/assets/auto-deploy-app/test/templates/deployment_test.go +++ b/assets/auto-deploy-app/test/templates/deployment_test.go @@ -172,6 +172,59 @@ func TestDeploymentTemplate(t *testing.T) { }) } + for _, tc := range []struct { + CaseName string + Release string + Values map[string]string + ExpectedCommand []string + ExpectedArgs []string + }{ + { + CaseName: "application-command", + Release: "production", + Values: map[string]string{ + "application.command[0]": "foo", + "application.command[1]": "bar", + "application.command[2]": "baz", + }, + ExpectedCommand: []string{"foo", "bar", "baz"}, + }, + { + CaseName: "application-args", + Release: "production", + Values: map[string]string{ + "application.args[0]": "foo", + "application.args[1]": "bar", + "application.args[2]": "baz", + }, + ExpectedArgs: []string{"foo", "bar", "baz"}, + }, + } { + t.Run(tc.CaseName, func(t *testing.T) { + namespaceName := "minimal-ruby-app-" + strings.ToLower(random.UniqueId()) + + values := map[string]string{ + "gitlab.app": "auto-devops-examples/minimal-ruby-app", + "gitlab.env": "prod", + } + + mergeStringMap(values, tc.Values) + + options := &helm.Options{ + SetValues: values, + KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), + } + + output := helm.RenderTemplate(t, options, helmChartPath, tc.Release, []string{"templates/deployment.yaml"}) + + var deployment appsV1.Deployment + helm.UnmarshalK8SYaml(t, output, &deployment) + + require.Equal(t, tc.ExpectedCommand, deployment.Spec.Template.Spec.Containers[0].Command) + require.Equal(t, tc.ExpectedArgs, deployment.Spec.Template.Spec.Containers[0].Args) + }) + } + // serviceAccountName for _, tc := range []struct { CaseName string