-
Notifications
You must be signed in to change notification settings - Fork 352
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
Add exec
environment source
#1042
Conversation
This looks good to me! Just wondering if there should be accompanying tests. Also, someone more familiar with this codebase should look at this too, since I'm still new to this one. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, thanks @reidmv! If possible let's use the r10k subprocess utility for command execution, simplify format handling if possible, and I'd like to see some basic test coverage for this. Once those concerns are concerned we should be good to merge this.
Expanding on the format handling, I'm mildly opposed to supporting multiple formats without a concrete use case; this is an easy simplification and avoids the mild heuristics that multiple formats entail. For comparison the puppet exec node terminus only supports YAML so we have prior art for supporting a single format. That being said, I don't feel strongly - if there's a compelling case for multiple formats, then we can proceed as-is.
Summary of the above:
- Command execution with
Subprocess
- Format handling simplification (or documentation for multiple format use cases)
- Test coverage
Ping me in the Puppet community Slack if you'd like to discuss this more. Thanks!
d6f8df2
to
5153dd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! There are a couple of nice to have changes (mainly documentation) that would be good to add before merge, but I'm happy with this as-is.
Tracked it down. The test failure is due to an rspec-mocks Ruby 2.7 bug in its |
@adrienthebo ready for review, including bug workaround for rspec-mocks 3.9.1 |
lgtm! did you want to squash any of your commits? |
ad1257a
to
af0ce8c
Compare
Squashed down to three commits. 1) Improve hash source type, 2) add exec source type, and 3) the rspec-mocks test bug workaround. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a hard blocker for error handling, a minor change to YAML parsing, and some optional minor improvements. Let's get the blocker cleared out so we can get this merged, and then can do some refactoring in a followup PR.
9fcac92
to
a933d9b
Compare
Two main improvements being made: - Include logging in hash source type - Split hash source #initialize from #environments - Add validation method for checking environment hashes Logging is being added so that derived classes can use it. Splitting the #initialize logic pertaining to creating environments and and sending it into the #environments method instead allows child classes to better control when (or if) side-effect actions are triggered. The validation method can be used to check if an environments hash is valid. It only performs perfunctory validation today.
This new source type allows r10k to run a command, which should produce a JSON or YAML hash, to enumerate environments that should exist. Similar to Puppet's exec node terminus this becomes an easy extension point to integrate r10k with custom external environment sources.
Co-Authored-By: Adrien Thebo <adrien@lagrange-automation.io>
Applied suggestions from code review, dropped rspec-mocks cli tests workaround, rebased on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Add a new environment source type, exec, to enable simple implementation of external environment sources.
The exec environment source runs an external command which is expected to return on stdout content compatible with the YAML environment source data format. The command may return the data in JSON or YAML form. The exec environment source is similar in purpose to Puppet's exec node terminus, used to implement external node classifiers (ENCs). R10k's exec source type allows the the implementation of external environment sources.
Video demo:
https://youtu.be/npfqRjaIxGo
The video goes for 20 minutes and includes how CD4PE/PE can use R10k with this feature. The R10k-specific part of the demo is presented early on.