The error occurs because the $input_deployment_name variable passed to the Helm template function is of the wrong type. Here's a breakdown and solution:
Cause of the Error
-
Type Mismatch:
- The
lookup function expects $input_deployment_name to be a string (the name of the Deployment).
- Instead, it received an
interface{} (a generic type), which likely means the variable holds a map or object instead of a simple string.
-
Root Cause:
- The
$passingValues_dict dictionary (passed to the include function) contains a non-string value for input_deployment_name.
- This often happens when the value is accidentally sourced from a YAML object (e.g.,
.Values.deployment instead of .Values.deployment.name).
Solution
1. Check the Value Source
In your template where $passingValues_dict is defined (likely in public-magnolia.deployment.yml), verify the source of input_deployment_name. Ensure it references a string, not a map/object.
Incorrect (passing an object):
{{- $passingValues_dict := dict
"input_deployment_name" .Values.deployment # .Values.deployment is an OBJECT/MAP!
}}
Correct (passing a string):
{{- $passingValues_dict := dict
"input_deployment_name" .Values.deployment.name # Explicit string value
}}
2. Debug the Value
Add debug output before the failing include to inspect the type:
{{- printf "Type of input_deployment_name: %s" (typeOf $passingValues_dict.input_deployment_name) | fail }}
This will halt execution and show the variable type during helm install/upgrade.
3. Explicitly Convert to String (If Needed)
If the value is a complex type but contains a string field (e.g., a Kubernetes object), extract the name:
{{- $deploymentName := $input_deployment_name.metadata.name | default "" -}}
{{- get (lookup "apps/v1" "Deployment" $input_namespace $deploymentName).spec.template.metadata.annotations ... }}