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

fix: pull secret getting created even when no authentication is selected #927

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (p registryPreProcessor) preprocess(ir irtypes.IR) (irtypes.IR, error) {
desc := fmt.Sprintf("[%s] What type of container registry login do you want to use?", registry)
hints := []string{"Docker login from config mode, will use the default config from your local machine."}
auth := qaengine.FetchSelectAnswer(quesKey, desc, hints, string(defaultOption), authOptions, nil)
createPullSecret := false
switch registryLoginOption(auth) {
case noLogin:
regAuth.Auth = ""
Expand All @@ -143,14 +144,16 @@ func (p registryPreProcessor) preprocess(ir irtypes.IR) (irtypes.IR, error) {
ps := qaengine.FetchStringAnswer(qaKey, fmt.Sprintf("[%s] Enter the name of the pull secret : ", registry), []string{"The pull secret should exist in the namespace where you will be deploying the application."}, "", nil)
imagePullSecrets[registry] = ps
case usernamePasswordLogin:
createPullSecret = true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
createPullSecret = true
createPullSecretFromDockerConfig = true

qaUsernameKey := fmt.Sprintf(common.ConfigImageRegistryUserNameKey, `"`+registry+`"`)
regAuth.Username = qaengine.FetchStringAnswer(qaUsernameKey, fmt.Sprintf("[%s] Enter the username to login into the registry : ", registry), nil, "iamapikey", nil)
qaPasswordKey := fmt.Sprintf(common.ConfigImageRegistryPasswordKey, `"`+registry+`"`)
regAuth.Password = qaengine.FetchPasswordAnswer(qaPasswordKey, fmt.Sprintf("[%s] Enter the password to login into the registry : ", registry), nil, nil)
case dockerConfigLogin:
createPullSecret = true
logrus.Debugf("using the credentials from the docker config.json file")
}
if regAuth != (dockerclitypes.AuthConfig{}) {
if createPullSecret {

// create a valid docker config.json file using the credentials

Expand Down