Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_probes
Browse files Browse the repository at this point in the history
  • Loading branch information
RealAnna authored Mar 13, 2023
2 parents 1fa7383 + 3b265bd commit 7d6451d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions examples/operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ spec:
key: VAR1
name: {{ include "operator.fullname" . }}-secret-vars
- name: VAR2
value: {{ .Values.controllerManager.manager.var2 }}
value: {{ .Values.controllerManager.manager.env.var2 }}
- name: VAR3_MY_ENV
value: {{ .Values.controllerManager.manager.var3MyEnv }}
value: {{ .Values.controllerManager.manager.env.var3MyEnv }}
- name: VAR4
valueFrom:
configMapKeyRef:
Expand All @@ -74,6 +74,7 @@ spec:
value: {{ .Values.kubernetesClusterDomain }}
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
| default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.controllerManager.manager.imagePullPolicy }}
name: manager
resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10 }}
securityContext:
Expand Down
1 change: 1 addition & 0 deletions examples/operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ controllerManager:
image:
repository: controller
tag: latest
imagePullPolicy: Always
resources:
limits:
cpu: 100m
Expand Down
14 changes: 12 additions & 2 deletions pkg/processor/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const selectorTempl = `%[1]s
{{- include "%[2]s.selectorLabels" . | nindent 6 }}
%[3]s`

const envValue = "{{ .Values.%[1]s.%[2]s.%[3]s }}"
const imagePullPolicyTemplate = "{{ .Values.%[1]s.%[2]s.imagePullPolicy }}"
const envValue = "{{ .Values.%[1]s.%[2]s.%[3]s.%[4]s }}"


// New creates processor for k8s Deployment resource.
func New() helmify.Processor {
Expand Down Expand Up @@ -284,6 +286,14 @@ func processPodContainer(name string, appMeta helmify.AppMetadata, c corev1.Cont
return c, errors.Wrap(err, "unable to set container resources value")
}
}

if c.ImagePullPolicy != "" {
err = unstructured.SetNestedField(*values, string(c.ImagePullPolicy), name, containerName, "imagePullPolicy")
if err != nil {
return c, errors.Wrap(err, "unable to set container imagePullPolicy")
}
c.ImagePullPolicy = corev1.PullPolicy(fmt.Sprintf(imagePullPolicyTemplate, name, containerName))
}
return c, nil
}

Expand All @@ -306,7 +316,7 @@ func processEnv(name string, appMeta helmify.AppMetadata, c corev1.Container, va
if err != nil {
return c, errors.Wrap(err, "unable to set deployment value field")
}
c.Env[i].Value = fmt.Sprintf(envValue, name, containerName, strcase.ToLowerCamel(strings.ToLower(c.Env[i].Name)))
c.Env[i].Value = fmt.Sprintf(envValue, name, containerName, "env", strcase.ToLowerCamel(strings.ToLower(c.Env[i].Name)))
}
return c, nil
}
Expand Down
1 change: 1 addition & 0 deletions test_data/k8s-operator-kustomize.output
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ spec:
resourceFieldRef:
resource: limits.cpu
image: controller:latest
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /healthz
Expand Down

0 comments on commit 7d6451d

Please sign in to comment.