Giter Club home page Giter Club logo

Comments (11)

ashi009 avatar ashi009 commented on June 12, 2024 1

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.

mattmoor avatar mattmoor commented on June 12, 2024 1

@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.

jpoehnelt avatar jpoehnelt commented on June 12, 2024

My use case is getting the git branch and hash into labels for rules_k8s.

from rules_jsonnet.

ashi009 avatar ashi009 commented on June 12, 2024

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.

mattmoor avatar mattmoor commented on June 12, 2024

rereading your answer, it already says "generate", so sorry for not RTFM. That's be great, I think.

from rules_jsonnet.

ashi009 avatar ashi009 commented on June 12, 2024

@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.

mattmoor avatar mattmoor commented on June 12, 2024

Awesome! Would you be able to turn that into a PR?

from rules_jsonnet.

ashi009 avatar ashi009 commented on June 12, 2024

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.

sparkprime avatar sparkprime commented on June 12, 2024

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.

mariusgrigoriu avatar mariusgrigoriu commented on June 12, 2024

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.

mariusgrigoriu avatar mariusgrigoriu commented on June 12, 2024

I created a separate issue #39 (and matching PR) since stamp variables would be useful anyway.

from rules_jsonnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.