carvel-dev / ytt

YAML templating tool that works on YAML structure instead of text
https://carvel.dev/ytt
Apache License 2.0
1.65k stars 135 forks source link

consider allowing ytt templates to determine file destination for certain YAML documents #54

Closed cppforlife closed 2 years ago

cppforlife commented 5 years ago

An "app" is actually a micro-service in my Kubernetes application My motivation to use ytt is to be able to build all the YAML files on the fly from templates, data and code. I would like to run ytt only once and get all the necessary YAML files for a deployment. At the moment, I'm almost there But I need the separate files So I could have more control over the deployment process WDYT? It would be awesome to have something like this:

#@ load("@ytt:data", "data")
#@ load("@ytt:template", "template")
#@ load("@functions:config.star", "get_app_list")

#@ load("k8s/service.lib.yaml", "k8s_service")
#@ load("k8s/secret.lib.yaml", "k8s_secret")
#@ load("k8s/config-map.lib.yaml", "k8s_config_map")
#@ load("k8s/deployment.lib.yaml", "k8s_deployment")

#@ for app in get_app_list():
#@ output-to-file ("{}.yaml".format(app.name)):
#@ print ("Creating manifests for '{}'".format(app.name))
#@ print ("-- Creating K8s Service")
--- #@ template.replace(k8s_service(app))
#@ print ("-- Creating K8s Secret")
--- #@ template.replace(k8s_secret(app))
#@ print ("-- Creating K8s ConfigMap")
--- #@ template.replace(k8s_config_map(app))
#@ print ("-- Creating K8s Deployment")
--- #@ template.replace(k8s_deployment(app))
#@ end
#@ end

output-to-file ([FILE-NAME]) ... end - just an idea (edited)

via slack

pivotaljohn commented 2 years ago

This issue stale by years. I inlined the salient request to make it discoverable through search. Closing for now. If there is renewed interest, we can re-open.