Skip to content
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

(CODEMGMT-1350) Fall back to default branch even when overridden #1122

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

Magisus
Copy link
Collaborator

@Magisus Magisus commented Feb 1, 2021

Currently, if a default branch override for a module is specified, if
that branch doesn't exist, r10k will error without checking the module's
normal default branch. This is not desirable, so this commit updates the
fallback logic so that the default branch ref will also be checked, if
the branch override fails to resolve. This makes it more likely that we
will successfully resolve a module, rather than erroring.

Please add all notable changes to the "Unreleased" section of the CHANGELOG in the format:

- Summary of changes. [Issue or PR #](link to issue or PR)

@Magisus Magisus requested a review from a team February 1, 2021 21:55
@Magisus
Copy link
Collaborator Author

Magisus commented Feb 1, 2021

This is an improvement requested in service of CD4PE, so I've used an internal ticket number. If this will mess with any community workflows, please let me know, and we can look into options for backwards compatibility.

@Magisus Magisus force-pushed the default-branch-fallback branch 2 times, most recently from 1ef6fc7 to 0cb719b Compare February 1, 2021 22:08
Copy link
Contributor

@mwaggett mwaggett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to talk to Nick about whether this constitutes a breaking change or not?

msg << "or resolve the default branch override '%{default_override}',"
vars[:default_override] = default_override
end

if default
msg << "or resolve default ref '%{default}'"
vars[:default] = default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't let me comment on the actual line, but do we think the "no default provided" message below will make sense if there's a default override but no actual default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs make clear that there is a "normal default" and a "default override". This is also the language the puppetfile uses for the options themselves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole message becomes: "Could not resolve control repo branch or resolve the default branch override 'override', and no default provided." I think it sounds okay.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey!

spec/unit/module/git_spec.rb Outdated Show resolved Hide resolved
end

context "when default branch override is not resolvable" do
context "and default branch is provided" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test the case where the default branch is provided, but also not resolvable? That feels different from just not providing a default branch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already test default suceeding (proving that we fall back), and elsewhere we test the default failing, demonstrating what that looks like. It feels like it's covered to me. But I can add a case if you think that's not sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the tests in this repo, so if you think it's covered then I trust you.
I was just thinking that the default branch being unresolvable has different consequences depending on whether you use a default_override or not. When using a default_override, the default being unresolvable only matters if the default_override is also unresolvable.

Copy link
Collaborator Author

@Magisus Magisus Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added something for that last case. If the default is not resolvable and the override is, that doesn't matter because we never try it.

mwaggett
mwaggett previously approved these changes Feb 1, 2021
npwalker
npwalker previously approved these changes Feb 2, 2021
Copy link
Contributor

@npwalker npwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@@ -67,10 +67,11 @@ Update a single environment and specify a default branch override:
r10k deploy environment my_working_environment --puppetfile --default-branch-override default_branch_override

This will update the given environment and update all contained modules, overrideing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you change "overrideing" here since you're right next to it.

Currently, if a default branch override for a module is specified, if
that branch doesn't exist, r10k will error without checking the module's
normal default branch. This is not desirable, so this commit updates the
fallback logic so that the default branch ref will also be checked, if
the branch override fails to resolve. This makes it more likely that we
will successfully resolve a module, rather than erroring.
@justinstoller justinstoller merged commit e0bd5fa into puppetlabs:master Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants