From 1849e1768a4208550eb343f53145313f8b662ec5 Mon Sep 17 00:00:00 2001 From: Somtochi Onyekwere Date: Tue, 21 Sep 2021 13:10:46 +0100 Subject: [PATCH] Set username when it isn't default Signed-off-by: Somtochi Onyekwere --- cmd/flux/bootstrap_git.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/flux/bootstrap_git.go b/cmd/flux/bootstrap_git.go index e7130243..f01d925c 100644 --- a/cmd/flux/bootstrap_git.go +++ b/cmd/flux/bootstrap_git.go @@ -171,8 +171,14 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error { secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits) secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve - // Configure repository URL to match auth config for sync. - repositoryURL.User = url.User(gitArgs.username) + // Configure repository URL to match auth config for sync + + // Override existing user when user is not already set + // or when a username was passed in + if repositoryURL.User == nil || gitArgs.username != "git" { + repositoryURL.User = url.User(gitArgs.username) + } + repositoryURL.Scheme = "ssh" if bootstrapArgs.sshHostname != "" { repositoryURL.Host = bootstrapArgs.sshHostname