-
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
Implement strip_component source feature #1128
Conversation
f125fc5
to
5f653f8
Compare
This feature allows r10k to be configured to strip a leading component string from a source's environment names. This is useful because it allows e.g. Git branches to include organizational prefixes such as "environment/production", "environment/development", but r10k/Puppet to deploy and use environments named "production", "development" from these branches.
5f653f8
to
3f33dac
Compare
@reidmv What prompted this? My main concern is mostly just around adding yet more configuration for a project that already isn't well-understood and isn't getting a ton of love. |
@mwaggett This was prompted by an internal Slack conversation relating to defining best practices setting customers up for success in the context of CD4PE. Gist of it: trying to define a best practice for Git branch naming in the context of CD4PE, needing to find a way to balance
However, that conversation is ongoing and needs input from the CD4PE product owner because r10k supporting this doesn't actually mean CD4PE supports it. So, totally fine to put this PR "on hold" for awhile while we figure all of that out. |
Thanks, Reid. My initial take is that this is very useful for separating the CD for PE managed branches in git vs the human readable Puppet environments and I'd like to see it implemented. However, it's not a great user setup experience and only something I'd expect professional services to setup for a user. Hopefully in the future we can remove the need for this setting altogether. |
@ccaum totally agree on wanting to make it unnecessary—in r10k land, the Notably, while the motivation for this came from CD4PE, it seems like it could improve OSP workflows too, and may be desirable for that reason even if CD4PE takes the big step forward and doesn't ever need something like this. Thoughts on this as a stand-alone r10k OSP-oriented capability? |
lib/r10k/environment/name.rb
Outdated
@@ -71,8 +71,24 @@ def dirname | |||
|
|||
private | |||
|
|||
def derive_prefix(source,prefix) | |||
def derive_name(name, strip_component) | |||
if strip_component == nil |
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.
Is false
a value you could see users put in here? Should we instead handle "falsey" values?
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.
Yeah, that would make sense. Updated to handle "falsey" instead of nil.
lib/r10k/environment/name.rb
Outdated
else | ||
name | ||
end | ||
rescue TypeError, NoMethodError |
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.
IMO, it's simpler to test the class of the input then doing a rescue afterwards.
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.
Good call. Funny how code structure sometimes reveals developer (my) chronological thought process, and highlights afterthoughts 😅 . Pushing improvement.
72057c9
to
a2fd87c
Compare
a2fd87c
to
76c99a9
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.
+1 Carl likes it so I'm good with it
This feature allows r10k to be configured to strip a leading component string from a source's environment names. This is useful because it allows e.g. Git branches to include organizational prefixes such as "environment/production", "environment/development", but r10k/Puppet to deploy and use environments named "production", "development" from these branches.