Comments (11)
Ah, another option is to create a generated jsonnet_library
which contains all the stamping variables. When build in bazel use this generated library, and for dev tools, use the actual file in the search path.
from rules_jsonnet.
@ashi009 I can introduce new stamping variables through --workspace_status_command
, so for this to be exhaustive we must dynamically generate the .jsonnet
for your library based on these files, which would be kinda bad ass. :)
from rules_jsonnet.
My use case is getting the git branch and hash into labels for rules_k8s.
from rules_jsonnet.
The best I can think of is to use --ext-code buildstamp={...}
to pass in such info, and create a libsonnet package to consume it with {default: 'stamping', info: 'is herer'} + std.extVar('buildstamp')
.
The problem with this approach is that, whenever --ext-code
flag is not presented, the build will fail. Which will probably break all dev tool integrations.
from rules_jsonnet.
rereading your answer, it already says "generate", so sorry for not RTFM. That's be great, I think.
from rules_jsonnet.
@mattmoor I've tried to create such libsonnet
package with stamp variables inside, then it turned out that rules_jsonnet
doesn't know how to handle generated files. Additional -J
flags need to be passed to jsonnet
.
The proposed patch is https://github.com/xreception/rules_jsonnet/commit/d9acfbec8346266d3b0bcd021004a56af6e105c8
from rules_jsonnet.
Awesome! Would you be able to turn that into a PR?
from rules_jsonnet.
One thing I don't like my CL is that, -J .
is not generated from search_paths
, but instead manually pinned to appear before all other -J
flags. The reason for doing this is because the generated file shared the same name as the placeholder file. So unless -J .
appears before the rest, the placeholder file will be used. Which doesn't seem right to me as the placeholder file is not on the transitive dependency graph.
from rules_jsonnet.
I just merged something (hadn't seen this) that might help with this: https://github.com/bazelbuild/rules_jsonnet/pull/37/files
from rules_jsonnet.
What about expanding make variables defined with --define
?
The use case I need to handle is injecting an environment specific domain name when generating ingress.json. It would be nice to run bazel --define fqdn=...
from rules_jsonnet.
I created a separate issue #39 (and matching PR) since stamp variables would be useful anyway.
from rules_jsonnet.
Related Issues (20)
- setup instructions is outdated and does not reference new 0.3.0 release HOT 1
- 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
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.