Skip to content

Commit

Permalink
feat: added fix
Browse files Browse the repository at this point in the history
Signed-off-by: RealAnna <[email protected]>
  • Loading branch information
RealAnna committed Feb 16, 2023
1 parent 3180a6b commit 4f33263
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/processor/probes/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,53 @@ import (
)

const livenessProbe = "\n{{- if .Values.%[1]s.%[2]s.livenessProbe }}\n" +
"livenessProbe: {{- include \"tplvalues.render\" (dict \"value\" .Values.%[1]s.%[2]s.livenessProbe \"context\" $) | nindent 12 }}\n" +
"livenessProbe: {{- include \"tplvalues.render\" (dict \"value\" .Values.%[1]s.%[2]s.livenessProbe \"context\" $) | nindent 10 }}\n" +
" {{- else }}\n" +
"livenessProbe:\n%[3]s" +
"\n{{- end }}"

const readinessProbe = "\n{{- if .Values.%[1]s.%[2]s.readinessProbe }}\n" +
"readinessProbe: {{- include \"tplvalues.render\" (dict \"value\" .Values.%[1]s.%[2]s.readinessProbe \"context\" $) | nindent 12 }}\n" +
"readinessProbe: {{- include \"tplvalues.render\" (dict \"value\" .Values.%[1]s.%[2]s.readinessProbe \"context\" $) | nindent 10 }}\n" +
" {{- else }}\n" +
"readinessProbe:\n%[3]s" +
"\n{{- end }}"

// ProcessSpecMap adds 'probes' to the Containers in specMap, if they are defined
func ProcessSpecMap(name string, specMap map[string]interface{}, values *helmify.Values, pspec corev1.PodSpec) error {

strContainers := make([]interface{}, len(pspec.Containers))
cs, _, err := unstructured.NestedSlice(specMap, "containers")
if err != nil {
return err
}

err = templateContainers(name, cs, pspec, strContainers, values)
strContainers, err := templateContainers(name, cs, pspec, values)
if err != nil {
return err
}
return unstructured.SetNestedSlice(specMap, strContainers, "containers")

}

func templateContainers(name string, cs []interface{}, pspec corev1.PodSpec, strContainers []interface{}, values *helmify.Values) error {
func templateContainers(name string, cs []interface{}, pspec corev1.PodSpec, values *helmify.Values) ([]interface{}, error) {
strContainers := make([]interface{}, len(pspec.Containers))
for i := range cs {
containerName := strcase.ToLowerCamel(pspec.Containers[i].Name)

content, err := yamlformat.Marshal(cs[i], 0)
if err != nil {
return err
return nil, err
}
strContainers[i] = content
err = setProbesTemplates(name, &(pspec.Containers[i]), &strContainers[i], containerName)
if err != nil {
return err
return nil, err
}
err = setProbeField(name, &(pspec.Containers[i]), values)
if err != nil {
return err
return nil, err
}
}
return nil
return strContainers, nil
}

func setProbesTemplates(name string, container *corev1.Container, strContainers *interface{}, containerName string) error {
Expand Down

0 comments on commit 4f33263

Please sign in to comment.