Comments (7)
@mariusgrigoriu Just started out with using jsonnet for kubernetes manifests and we would have similar requirements in regard to ingress host names. I am a fan of having everything checked into the repository so my idea was making use of --code-file/file
(not implemented here yet but see google/jsonnet#110 for usage) and then define it as something like:
jsonnet_to_json(
name = "k8s",
src = "k8s.jsonnet",
outs = ["k8s.json"],
file = select({
"//common/config:namespace_dev": {"fqdn": ":fqdn_dev.txt"},
"//common/config:namespace_something": {"fqdn": ":fqdn_something.txt"},
}),
)
So one would run e.g. bazel build :k8s --define namespace=dev
and that would then make it select the right checked in file which contains the fqdn.
Your approach is of course total valid as well and my thought of approach has it's own drawbacks but since I just thought of that yesterday/today and wanted to look into it in the near future I thought I'd mention it here.
from rules_jsonnet.
I think that approach is better if you have a limited number of environments. In our case, the name is dynamically generated from earlier in the build process. Each pipeline run spins up a whole cluster with a unique name. Normally I'd use stamp variables for something like that, but I'm integrating with a complicated make system while incrementally converting to Bazel. (I'm also new to Bazel so I'm sure there are better ways of accomplishing this that I don't know about.)
from rules_jsonnet.
Is this backwards incompatible for people who were previously using $ in that string and expecting it to be passed through to Jsonnet?
from rules_jsonnet.
A $ alone should be fine, however
from rules_jsonnet.
Are strings usually interpolated like that in Bazel? If not is it usually documented which ones have it / don't have it, and is there any kind of standard about that?
from rules_jsonnet.
Only certain arguments are substituted like that. The convention is to document when it happens. The most common example is the genrule: https://docs.bazel.build/versions/master/be/general.html#genrule.cmd
It seems to me that if jsonnet takes variables on the command line, then it would be handy to extend that type of capability all the way out by allowing variables to be passed in from the bazel command line.
That said, for my uses, I'm starting to generate a .libsonnet with variables that will be imported into various templates, but this feature might still be handy.
from rules_jsonnet.
Merged in #40
Thank you.
from rules_jsonnet.
Related Issues (20)
- Update links to JsonNet - https://jsonnet.org HOT 1
- Issue with new bazel_skylib? Error: 'list' value has no field or method '_values' HOT 9
- Add ability to switch progress_message off.
- doc: describe how to import external dependencies HOT 5
- Support Top-Level arguments in non-file mode HOT 1
- Bazel 5 breaking issue: jsonnet_to_json rule break because the underlying Bazel rule doesn't use Depsets.
- Please do a new release to support Bazel 5 HOT 5
- compatibility with jrsonnet
- Using external libraries that depend on other libraries HOT 2
- Support import_prefix and strip_import_prefix attrs in jsonnet_library HOT 2
- incorrect version linked? HOT 1
- yaml_stream is not working
- Unified diff output in jsonnet_to_json_test
- Add rules_jsonnet to the bzlmod registry HOT 1
- Flag --incompatible_config_setting_private_default_visibility will break rules_jsonnet in Bazel 7.0 HOT 3
- no matching toolchains found for types HOT 1
- extra_args is undocumented
- Flag --incompatible_disable_starlark_host_transitions will break rules_jsonnet in Bazel 7.0 HOT 2
- bazel 6.0.0 breakage? HOT 2
- Document all available attributes
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 rules_jsonnet.