Comments (8)
current thinking is to mark overlay documents with @data/values
as well
#@ load("@ytt:overlay", "overlay")
#@ load("@github.com:blah", "blah")
#@data/values
#@overlay/match ...
---
#@overlay/match missing_ok=True
key: foo
#@overlay/match missing_ok=True
blah: #@ blah.something
not sure though how to indicate it's an overlay if @overlay/match
doesnt take any args.
marking overlays with data/values helps to identify which files should be templated to obtain data.values.
from ytt.
after chatting extensively with @nimakaviani we've come to the following solution to this problem that we are planning to implement as a first cut:
- multiple
@data/values
could be specified - data/values are overlayed on top of another, with following ordering rules:
- follow -f order provided on the command line from left to right
- if -f specifies a directory, then use existing alpha numeric file name order
ill try to implement first cut of this tomorrow. example from the issue description would look something like this:
ytt -f template.yml -f envs/values.yml -f envs/aws/values.yml -f envs/aws/dev/values.yml
from ytt.
v0.13.0 is shipped: https://github.com/k14s/ytt/releases/tag/v0.13.0. it implements above comment.
from ytt.
@nimakaviani and i earlier on were discussing offering ability to specify overlay configuration for data/values. it could look something like this:
values.yml
#@data/values
---
val1: one
val2: two
aws/dev/values.yml
#@ load("@ytt:data", "data")
#@overlay/match by=data.values_document
---
val1: two
#@overlay/remove
val2:
which would ultimately result in @data/values
:
val1: two
before processing rest of the templates.
wdyt? it sounds like it would allow you to
from ytt.
reminder to self: ordering of overlays was in question here.
from ytt.
Some comments from Slack moved into here for discussion purposes:
The way i’d assumed it would work at the beginning was that i could “name” my various data files. Example: my globals file would declare #@data/globals
and my app config file would declare #@data/myapp
, and in the templates i could #@ load("@ytt:data", "globals")
and #@ load("@ytt:data", "myapp")
as needed, with the order of loading determining overlay order behaviour
having non-overlapping files would, in this implementation, be straightforward. in case of overlapping configs, this allows the user to modify order-of-overwriting on a template-by-template case
benefit of having one automatic way to merge data/values is that from the templates perspecive data comss from one place instead of leaking notion of global vs app into templates
True. You could even circumvent the entire problem by just preventing overlaying in those cases completely: make the #@ load("@ytt:data", "globals")
and #@ load("@ytt:data", "myapp")
statements inject the values directly into a sub-namespace so you’d have to call data.values.globals.x
or data.values.myapp.x
explicitly. then you’d have to specify in your templates on a statement-by-statement basis how you want overwriting, ex with default(data.values.globals.x, data.values.myapp.x)
(sorry if the syntax is wrong, not familiar with ytt syntax yet).
IMHO, there are two general approaches to solve decomposition of value files:
- Handle overlays explicitly, either via order-of-imports, additional CLI arguments, special annotations, dedicated functions (ex.
merge(values.globals, values.myapp)
) or otherwise. Upside: this solves both decomposition and overlaying with one stroke, which makes it easy for users. Downside: Users must be aware of the behaviour or risk running into surprises. - Explicitly don't handle overlaying, only focus on decomposition. This could be done by injecting the different value files into different namespaces based on their declaration (ex. declaring a file with
#@data/myglobals
and loading it with#@ load("@ytt:data", "myglobals")
injects the values of this file intovalues.myglobals
). Upsides: This is a somewhat natural behaviour based on imports in programming languages that people may naturally expect. Downsides: As it doesn't handle overlaying on a per-template or per-deployment level, users must explicitly use something likeIF value.myglobals.x THEN value.myglobals.x ELSE value.myapp.x
each time in case they want to have overlay behaviour.
from ytt.
Any progress on getting values from multiple files via namespaces as suggested in this comment above? I actually think this is rather more useful that the current implementation which seems to be somewhat redundant with overlays?
from ytt.
@SaschaSchlemmer
Any progress on getting values from multiple files via namespaces as suggested in this comment above? I
we have no plans at the moment to change how data values are ingested. we currently support usage of any number of data values files (or other variations like env vars, etc.) per this doc description: https://github.com/k14s/ytt/blob/develop/docs/ytt-data-values.md#splitting-data-values-into-multiple-files
I actually think this is rather more useful that the current implementation which seems to be somewhat redundant with overlays?
key thing to data values is that they are commonly modified, overriden by various "layers" (common, dev, prod, etc.) so there need to be a mechanism for merging them. overlays provide that mechanism. with regard to separation them into "namespaces" you can easily achieve that by adding top level keys under data values and nesting child keys under those. in that regard ytt allows you, the user, to structure data values in whatever way it makes sense.
from ytt.
Related Issues (20)
- Are you using ytt?
- Sign `ytt` binaries while releasing them HOT 1
- Provide error on duplicate YAML keys in strict mode? HOT 3
- Reference Data in Data Values HOT 3
- Support default value for `any` type HOT 6
- Timestamp-like strings lose quote HOT 6
- Add an optional boolean to not escape html during json encoding HOT 1
- bash subshell file descriptors produce nothing HOT 11
- Output full path in errors for a given file HOT 3
- Update copyright headers
- Export validation annotations in openapi schema HOT 1
- Add support for jsonschema export similar to openapi-v3 HOT 5
- Docs site is unavailable HOT 2
- Trailing comment affecting `yamlfmt.Printer` HOT 2
- Overlaying list on schema renders incorrectly HOT 6
- Schema validation does not work on first key in list dict HOT 3
- Sorry, but I just can't figure it out with overlays HOT 3
- Diagnosing low performance HOT 9
- Unable to install v0.49.1 by using carvel-dev/setup-action@v2 in GitHub Actions HOT 5
- Can an overlay change a function definition? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ytt.