From dc6b0d0f0d9eaad4624aa054c2280b58a810c445 Mon Sep 17 00:00:00 2001
From: Hidde Beydals <hello@hidde.co>
Date: Tue, 16 Mar 2021 13:47:53 +0100
Subject: [PATCH] Use Host from parsed URL instead of Hostname

Regression bug introduced in #1001.

Signed-off-by: Hidde Beydals <hello@hidde.co>
---
 cmd/flux/bootstrap_github.go  | 2 +-
 cmd/flux/bootstrap_gitlab.go  | 2 +-
 cmd/flux/create_secret_git.go | 2 +-
 cmd/flux/create_source_git.go | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/flux/bootstrap_github.go b/cmd/flux/bootstrap_github.go
index e40efd0f..56f62878 100644
--- a/cmd/flux/bootstrap_github.go
+++ b/cmd/flux/bootstrap_github.go
@@ -248,7 +248,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
 		if err != nil {
 			return fmt.Errorf("git URL parse failed: %w", err)
 		}
-		secretOpts.SSHHostname = u.Hostname()
+		secretOpts.SSHHostname = u.Host
 		secretOpts.PrivateKeyAlgorithm = sourcesecret.RSAPrivateKeyAlgorithm
 		secretOpts.RSAKeyBits = 2048
 	}
diff --git a/cmd/flux/bootstrap_gitlab.go b/cmd/flux/bootstrap_gitlab.go
index 15088d31..8acf93aa 100644
--- a/cmd/flux/bootstrap_gitlab.go
+++ b/cmd/flux/bootstrap_gitlab.go
@@ -235,7 +235,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
 		if err != nil {
 			return fmt.Errorf("git URL parse failed: %w", err)
 		}
-		secretOpts.SSHHostname = u.Hostname()
+		secretOpts.SSHHostname = u.Host
 		secretOpts.PrivateKeyAlgorithm = sourcesecret.RSAPrivateKeyAlgorithm
 		secretOpts.RSAKeyBits = 2048
 	}
diff --git a/cmd/flux/create_secret_git.go b/cmd/flux/create_secret_git.go
index b84bcbbd..d24faadc 100644
--- a/cmd/flux/create_secret_git.go
+++ b/cmd/flux/create_secret_git.go
@@ -129,7 +129,7 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
 	}
 	switch u.Scheme {
 	case "ssh":
-		opts.SSHHostname = u.Hostname()
+		opts.SSHHostname = u.Host
 		opts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(secretGitArgs.keyAlgorithm)
 		opts.RSAKeyBits = int(secretGitArgs.rsaBits)
 		opts.ECDSACurve = secretGitArgs.ecdsaCurve.Curve
diff --git a/cmd/flux/create_source_git.go b/cmd/flux/create_source_git.go
index 2ee13daa..e245af6b 100644
--- a/cmd/flux/create_source_git.go
+++ b/cmd/flux/create_source_git.go
@@ -215,7 +215,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
 		}
 		switch u.Scheme {
 		case "ssh":
-			secretOpts.SSHHostname = u.Hostname()
+			secretOpts.SSHHostname = u.Host
 			secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(sourceGitArgs.keyAlgorithm)
 			secretOpts.RSAKeyBits = int(sourceGitArgs.keyRSABits)
 			secretOpts.ECDSACurve = sourceGitArgs.keyECDSACurve.Curve
-- 
GitLab