-
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
(RK-390) Remove hardcoded default for git ref #1275
Conversation
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.
This needs a changelog update.
4dab311
to
cc1b428
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.
This seems alright to me. @reidmv wanna check with you, since this came from your request.
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.
I don't remember the context for this, so I'm reviewing at face value here.
I have some concerns about the UX as given, but I think I understand the objective and I think it should be easy to simplify, unless perhaps there's something I've misunderstood about how this is supposed to work.
Here's my UX concern.
Today, a user might specify a module as follows:
- name: puppetlabs/stdlib
type: git
source: https://github.com/puppetlabs/puppetlabs-stdlib.git
We haven't specified a ref or version at the module level. We want to be able to omit that information, and specify a global default to use. So far so good. It makes sense.
So, in r10k.yaml, what should that setting be called?
I don't really like deploy.default_module_ref
. I think either we're configuring module defaults, or we're configuring git defaults, so this setting belongs either under module.*
somewhere, or git.*
somewhere. I would lean towards making this a git default. So, I think we want the setting to be placed there in r10k.yaml:
# r10k.yaml
---
git:
default_ref: main
Some uses of git will require a ref, but if the utilization permits falling back to a default, this is a good global place to define what that default should be.
If we put the default setting there, I'm back to feeling comfortably like this all more or less makes sense and is reasonably simple.
Next, this PR suggests adding an additional possible per-module setting of default_module_ref
. E.g., a user could legally write:
- name: puppetlabs/stdlib
type: git
source: https://github.com/puppetlabs/puppetlabs-stdlib.git
default_module_ref: main
This seems bad to me. It's confusing, and I'm not sure what the difference here is between this and just writing
- name: puppetlabs/stdlib
type: git
source: https://github.com/puppetlabs/puppetlabs-stdlib.git
ref: main
So, I would prefer that default_module_ref
not be a legal option to pass to an individual module.
I would request two changes:
- Change the setting from
deploy.default_module_ref
togit.default_ref
. - Remove
default_module_ref
as an exposed per-module setting.
Would those adjustments to the user-facing part of this experience still cover the intended use case?
In support of what @reidmv said above, the changes currently causes the following warning for each forge module. This seems like it would be a git-only option.
The error that comes from missing the default ref could be confusing for some users that did not read the changelog. Adding some context to the message can help users identify and correct the issue. Can we update it to say that there is no default branch in 4.0.0+?
This change is only for Another consideration is that we are changing how users should write their Puppetfile. The |
I missed the bit about this new thing being available as a per-module setting, agreed we definitely don't want that: that's what |
This ^^ is incorrect; the puppetfile doc states(emphasis my own):
There's no mention of I do think that @reidmv is correct that this should move over to the git namespace. @jarretlavallee I will fix those incorrect warnings and add it to the puppetfile face. |
Yeah, I was mixing looking at the docs (what should a user do) and looking at the code (what can a user legally do). If I'm reading the code correctly, the fact that we add We already don't intend for people to use this opt themselves per-module; my comment is that we should ensure it isn't possible, even accidentally. |
cc1b428
to
c7de4e9
Compare
Previously r10k fell back to the 'main' ref if no other ref was specified. With this patch, r10k will no longer fall back to that ref, and error when no ref is found. To mitigate breakage relying on the hardcoded ref, a user can set `default_ref` in the r10k config to a ref of their choice, mimicking the old behavior.
c7de4e9
to
921acf4
Compare
set in the r10k config that will become the ref a module uses if not otherwise specified. This | ||
is the lowest priority setting for a module's `ref`. Read [here](../puppetfile.mkd#git) for more info. |
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.
set in the r10k config that will become the ref a module uses if not otherwise specified. This | |
is the lowest priority setting for a module's `ref`. Read [here](../puppetfile.mkd#git) for more info. | |
set in the r10k config, which will be used if a module's `ref` is not otherwise specified. This | |
is the lowest priority setting for a module's `ref`. See the [Puppetfile documentation](../puppetfile.mkd#git) for the recommended way to specify module `ref`s. |
@reidmv and @jarretlavallee I believe I have addressed all your comments, so another review would great, please and thankyou. One thing I didn't implement was adding edit: Oh, actually it's probably really easy to just iterate through the modules during check and just run |
👍 The changes address the majority of my concerns and I have validated the functionality. The |
@jarretlavallee I put in the logic for the check and it is simpler and safe than running |
doc/puppetfile.mkd
Outdated
@@ -135,6 +135,12 @@ operations when updating the repo, which can speed up install times. When | |||
Module versions can also be specified using `:branch` to track a specific | |||
branch reference. | |||
|
|||
In r10k 3.x the default branch was hardcoded to `master`; in 4.x that was | |||
removed. A `default_ref` can be specified in the r10k config to | |||
to mimick that old behavior, but it is recommended to set the ref on a |
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.
to mimick that old behavior, but it is recommended to set the ref on a | |
to mimic that old behavior, but it is recommended to set the ref on a |
@@ -15,11 +22,39 @@ def checker(opts = {}, argv = [], settings = {}) | |||
to receive(:new). | |||
with({ | |||
basedir: "/some/nonexistent/path", | |||
overrides: {modules: {default_ref: 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.
Why do we need to set this explicitly?
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.
The check
code will read it in everytime, so if it is not here, it will error with a mismatch in the argurments passed to new
.
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.
fun
lib/r10k/module/git.rb
Outdated
def validate_ref_defined | ||
if @desired_ref.nil? && @default_ref.nil? && @default_override_ref.nil? | ||
msg = "No ref defined for module #{@name}. Add a ref to the module definition " | ||
msg << "or add a default in the r10k config for git:default_ref." |
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.
msg << "or add a default in the r10k config for git:default_ref." | |
msg << "or set git:default_ref in the r10k.yaml config to configure a global default ref." |
lib/r10k/module/git.rb
Outdated
@@ -147,7 +154,9 @@ def validate_ref(desired, default, default_override) | |||
msg << "or resolve default ref '%{default}'" | |||
vars[:default] = default | |||
else | |||
msg << "and no default provided" | |||
msg << "and no default provided. r10k no longer hardcodes 'master' as the default ref." | |||
msg << "Consider setting this per module in the Puppetfile or setting git:default_ref" |
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.
msg << "Consider setting this per module in the Puppetfile or setting git:default_ref" | |
msg << "Consider setting a ref per module in the Puppetfile or setting git:default_ref" |
Previously r10k fell back to the 'main' ref if no other ref was
specified. With this patch, r10k will no longer fall back to that
ref, and error when no ref is found.
To mitigate breakage relying on the hardcoded ref, a user can
set
default_ref
in the r10k config to a ref of theirchoice, mimicking the old behavior.
Please add all notable changes to the "Unreleased" section of the CHANGELOG in the format: