-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Description
Hi,
I am interested in creating a feature request for being able to determine which folder a file is in. Helm already has pretty similar functionality to this built-in with {{ Template.BasePath }} which tells you the path to your file. I think that having something similar with {{ Template.BaseFolder }} could buy users a lot of advantages when it comes to creating reusable code. I can provide a pretty quick example below.
If my directory was formatted as follows..
Chart.yaml
values.yaml
README.md
templates/
backend/
deployment.yaml
frontend/
deployment.yamlThen I could setup my one deployment like this and have 2 unique deployments
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ Template.BaseFolder }}-deployment
labels:
{{- include "chart.labels" . | indent 4 }}
app: {{ Template.BaseFolder }}
spec:
replicas: {{ .Values.frontend.replicaCount }} # even this could be templated using index and setting your values.yaml up. But that is a little overkill
selector:
matchLabels:
app: {{ Template.BaseFolder }}
template:
metadata:
labels:
{{- include "chart.labels" . | indent 8 }}
app: {{ Template.BaseFolder }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
....Then the output of these 2 deployments would be
frontend-deployment
backend-deployment
It should look something like the following from a python perspective
{{ Template.BasePath}}.split('/')[-2]
Metadata
Metadata
Assignees
Labels
No labels