-
Notifications
You must be signed in to change notification settings - Fork 315
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
Template debugging tool #5065
Comments
I mentioned this in #1779 but I vote to name the linter tool |
Not sure if this fits in here or would belong another place, but it would be really cool to be able to stub or fake the gossip data. E.g.: I've been working on a "consul-client" plan which would bind to a "core/consul" cluster. The only way to get that bind info to resolve is to actually build a 3node cluster then run my client plan against it. I would like to be able to see that this:
Actually resolves in the proper format, etc. (I'm still not clear on where to use the |
I want to raise attention to that topic and drop few notes on how it might be implemented. Could you please implement
FLAGS:
Exit code:
Code of this tool can easily be based on Usage example:
port=9999 # overridden port
[sys]
ip = "100.100.100.100"
[bind]
[bind.database]
port = 5432
[bind.database.superuser]
name = "not_a_admin"
password = "not_a_password"
...
hab-plan-render --extra-toml tests/svc.toml .
cat results/hooks/run # see what I got
grep 'db.admin = "not_a_admin" results/config/db.conf || echo "db.admin was not rendered!"
# OR INSPEC TEST
inspec inspec/template_contains_required_values_spec.rb |
I commented on this in Slack, but will leave it here, too:
|
@christophermaier I'd like to take a crack at it! Any advice on where to start? E.g.: how does "render template" function work in "the real world"? |
@qubitrenegade Looks like our configuration logic is a specialization of our hook compilation logic. This work may reveal additional opportunities for refactoring, consolidation, etc. The configuration logic lives in: habitat/components/common/src/templating/config.rs Lines 464 to 536 in 6784490
The templating logic lives in: habitat/components/common/src/templating/mod.rs Lines 82 to 92 in 6784490
The key bit is that both take a "context", which is anything that implements serde's Hopefully that gives you a better idea of how it all gets put together; let me know if you've got any other questions. And thanks for the help! |
I opened PR #6114 as I figured it would be easier to discuss changes. So first thing I did was wire up a I figured it would be easier to render one file and then I can figure out how to render a whole directory. As you might infer from my variable names I was thinking that you'd want to maybe pass the path to a default.toml and some kind of "mock_data.json" file that could mock out the So I kinda cheated and just copied Unfortunately, the way the So I attempted to use the I did this:
Which I'm not sure I entirely understand, but I think does what I expect... sort of... For instance, testing the consul config template with this
I only get:
So I need some way to mock out the running service members. Any thoughts? Also before I get too far, any thoughts on the path I'm going down?/Feedback on code? To test, I did the following:
Thanks! |
Ok, a bit clumsy... but try:
Then: -
or
This should render:
Still haven't figured out how to render for TODO:
|
Helps if you use "alive" not "active" 🦆 |
Now that #6114 is merged, can we close this, or is there more to do? |
Well...
Is my current "todo" list 😁 #6114 is really only a starting point or "MVP"... there's still a bunch I'd like to do (if you're willing to continue to hand-hold me?). So... Maybe it makes sense to have a forum post and gather requirements and generate an overall "feature request list" and generate issues/requirements from that? I think we have a good list of requirements going so far, but that's largely based on how I use Habitat (and how I want to be able to debug habitat...). Is there a way to "assign" those tickets to me? Then I don't have to keep a list of them? Thanks! |
Is this ticket can be closed because we have |
@jsirex Yup, looks like it... thanks for the nudge. |
Currently, it's difficult to know if templated content will behave as you expect until it's actually rendered by a live Supervisor. Unfortunately, this can mean unnecessarily long development and debugging cycles, and increased likelihood of escaped bugs.
In keeping with the general Habitat principle of pushing failure as close to the development phase as possible, it would be great to have a tool that could evaluate template files in a number of ways.
Additionally, it would be nice to have a way to render the file using different input data to ensure it is working generally as expected.
The text was updated successfully, but these errors were encountered: