-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: choose cli default-repo over config file #7144
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
if defaultRepo.Value() != nil && cfg.DefaultRepo != "" { | ||
defaultRepo = NewStringOrUndefined(&cfg.DefaultRepo) | ||
} | ||
|
||
if local && defaultRepo.Value() == 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 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)
}
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.
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?
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 reason I believe this piece of code is not needed is because typically when we call the following function:
skaffold/pkg/skaffold/deploy/util/util.go
Lines 34 to 52 in 1dbc7a2
// 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
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.
sounds good
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 |
There is an open issue #7121. Not your fault!! |
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
Fixes: #7125
Description
Fixes error introducing in pr #6985. Logic was introduced there to give precedence to config value instead of cli.