I'm trying to split a method definition from the schema. This is a case loosely inspired by the official how-to. If the following code is present in the same file, it works well. However if I'm splitting the method definition into a separate file the following way, it results in an error.
svc.yaml
:
#@ load("@ytt:data", "data")
---
apiVersion: v1
kind: Service
metadata:
labels: #@ labels(with_version=True)
name: #@ data.values.promOperatorName
namespace: #@ data.values.namespace
spec:
clusterIP: None
ports:
- name: http
port: 8080
targetPort: http
selector: #@ labels()
labels.yaml
:
#@ load("@ytt:data", "data")
#@ def labels(with_version=False):
app.kubernetes.io/component: controller
app.kubernetes.io/name: prometheus-operator
#@ if with_version:
app.kubernetes.io/version: 0.53.1
#@ end
#@ end
Applied via: ytt -f labels.yaml -f svc.yaml -f data.yaml
this yields
ytt: Error:
- undefined: labels
svc.yaml:7 | labels: #@ labels(with_version=True)
- undefined: labels
svc.yaml:16 | selector: #@ labels()
Apparently the def labels()
method definition is not picked-up during processing.
ytt version 0.38.0