Skip to content

fix: choose cli default-repo over config file #7144

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

Merged
merged 2 commits into from
Mar 3, 2022
Merged

fix: choose cli default-repo over config file #7144

merged 2 commits into from
Mar 3, 2022

Conversation

tomasmota
Copy link
Contributor

Fixes: #7125

Description
Fixes error introducing in pr #6985. Logic was introduced there to give precedence to config value instead of cli.

@tomasmota tomasmota requested a review from a team as a code owner February 27, 2022 20:47
@codecov
Copy link

codecov bot commented Feb 27, 2022

Codecov Report

Merging #7144 (7dc6bc4) into main (290280e) will decrease coverage by 2.09%.
The diff coverage is 56.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7144      +/-   ##
==========================================
- Coverage   70.48%   68.39%   -2.10%     
==========================================
  Files         515      560      +45     
  Lines       23150    26253    +3103     
==========================================
+ Hits        16317    17955    +1638     
- Misses       5776     7061    +1285     
- Partials     1057     1237     +180     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/deploy.go 52.00% <ø> (-1.85%) ⬇️
cmd/skaffold/app/cmd/dev.go 84.61% <0.00%> (ø)
cmd/skaffold/app/cmd/render.go 36.66% <0.00%> (-4.72%) ⬇️
cmd/skaffold/skaffold.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/inspect_tests.go 62.50% <14.28%> (-1.14%) ⬇️
cmd/skaffold/app/cmd/lsp.go 28.12% <28.12%> (ø)
cmd/skaffold/app/cmd/fix.go 68.85% <40.00%> (-7.62%) ⬇️
cmd/skaffold/app/cmd/lint.go 42.85% <42.85%> (ø)
cmd/skaffold/app/cmd/find_configs.go 48.88% <50.00%> (+0.24%) ⬆️
cmd/skaffold/app/skaffold.go 76.19% <70.00%> (-8.43%) ⬇️
... and 217 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1dbc7a2...7dc6bc4. Read the comment docs.

if defaultRepo.Value() != nil && cfg.DefaultRepo != "" {
defaultRepo = NewStringOrUndefined(&cfg.DefaultRepo)
}

if local && defaultRepo.Value() == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

is cfg.DefaultRepo being checked somewhere else? Otherwise I think the author intended this to say:

if defaultRepo.Value() == nil && cfg.DefaultRepo != "" {
		defaultRepo = NewStringOrUndefined(&cfg.DefaultRepo)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I don't pass in the flag, but have it in my config, it is still being picked up without that piece of code. I would assume that implies that it is checked somewhere else, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

the reason I believe this piece of code is not needed is because typically when we call the following function:

// ApplyDefaultRepo applies the default repo to a given image tag.
func ApplyDefaultRepo(globalConfig string, defaultRepo *string, tag string) (string, error) {
repo, err := config.GetDefaultRepo(globalConfig, defaultRepo)
if err != nil {
return "", fmt.Errorf("getting default repo: %w", err)
}
multiLevel, err := config.GetMultiLevelRepo(globalConfig)
if err != nil {
return "", fmt.Errorf("getting multi-level repo support: %w", err)
}
newTag, err := docker.SubstituteDefaultRepoIntoImage(repo, multiLevel, tag)
if err != nil {
return "", fmt.Errorf("applying default repo to %q: %w", tag, err)
}
return newTag, nil
}

We grab the value from the config and compare things then. This is how things usually worked before these few lines were added I believe

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label Mar 1, 2022
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Mar 1, 2022
@tomasmota
Copy link
Contributor Author

Could the PR actually have broken something in that test? I'm not familiar with kaniko, so I'd have a hard time debugging this

@tejal29
Copy link
Contributor

tejal29 commented Mar 2, 2022

There is an open issue #7121. Not your fault!!

Copy link
Contributor

@gsquared94 gsquared94 left a comment

Choose a reason for hiding this comment

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

lgtm

@gsquared94 gsquared94 merged commit 9030c7c into GoogleContainerTools:main Mar 3, 2022
@tomasmota tomasmota deleted the fix-default-repo branch March 3, 2022 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The --default-repo flag no longer seems to be respected in 1.36.0
5 participants