-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect included yaml files which are also targets #127
Comments
https://pypi.org/project/Templer/ has a slightly different approach, calling it dynamic context. |
And of course Ansible has jinja variables in yaml transparently https://docs.ansible.com/ansible-container/container_yml/template.html & https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html The 'problem' with that approach is that any transparent system would need to choose one template language for the yaml variables. We could choose one which is very basic, but IMO "jinja" would not be a good choice. It would need to be a cut down version of jinja, which offers no loop control -- only https://github.com/kblomqvist/yasha is a bit like templer, and offers https://bitbucket.org/djarvis/yamlp uses https://docs.helm.sh/chart_template_guide/ has flow control using go template language. https://docs.docker.com/compose/compose-file/#variable-substitution uses bash syntax https://puppet.com/docs/puppet/5.0/hiera_interpolation.html uses python syntax. Most of the time the "need" is only to reference other yaml values. e.g. cookiecutter:
postgresql_version: 10
image:
name: django-mobans-pg-image
version: 0.1
maintainer: [email protected]
parent: postgres:{{ cookiecutter.postgresql_version }}-alpine
... https://stackoverflow.com/questions/4150782/use-yaml-with-variables is another great example. It would be really nice if yaml provided something like this (string interpolation) natively. I dont see anything in the yaml 1.3 RFCs which might provide something suitable. I notice ruamel has already begun work on 1.3 https://pypi.org/project/yaml-1.3/ https://github.com/arthurlacoste/tampax uses https://github.com/metakirby5/whizkers & https://github.com/metakirby5/zenbu use https://github.com/grasmash/yaml-expander uses Using https://pypi.org/project/HiYaPyCo/ for loading the yaml is another possible approach - it solves quite a few features needed for moban, but it also means we cant solve them ourselves. The approach I like the best is to define custom yaml constructor, which will be feasible for most tools to build with their yaml parser, or achieve with post-processing. https://stackoverflow.com/a/23212501 with answer expanded at https://stackoverflow.com/a/30679992 . It is the approach used here, for https://pypi.org/project/pypyr/#substitutions We could define |
If a mobanfile has a target which is also part of the mobanfile yaml file system, moban should generate that file first if the file is missing, and re-run whenever the generated yaml file is modified.
e.g.
A.yaml
includes:This will allow the yaml data to be built dynamically using templates, either to bootstrap a project with default values based on other input values, or for changes to values to be propagated into other yaml variables which can then be used.
Or, it allows yaml values to contain variables.
e.g. mobanfile:
gen_derived_data.jj2:
(very simplified)
In a single case, that could be achieved by putting the logic for
copyright_string
into the template logic for each template which needs it. Or improved by using a re-usable macro included into each template.However the use case I have is a large collections of data is needed as inputs, and throughout the string values are constants which will infrequently change.
Another fun experiment is making the mobanfile also a template. This allows a repo to be 100% controlled by an upstream repo.
e.g. mobanfile
If the upstream
gen_moban_file.jj2
adds a new file which needs to be deployed, the mobanfile would be updated. Currently the user then needs to runmoban
again for the new file to be generated. The user might forget to do that.The text was updated successfully, but these errors were encountered: