Skip to content

Commit 6bfc438

Browse files
feat: [AH-1598]: fix issue with pkg url in go push flow
1 parent 4f2b077 commit 6bfc438

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

cmd/ar/command/push_go.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
client "github.com/harness/harness-cli/internal/api/ar"
1515
pkgclient "github.com/harness/harness-cli/internal/api/ar_pkg"
1616
"github.com/harness/harness-cli/module/ar/packages/gopkg"
17+
"github.com/harness/harness-cli/util"
1718
"github.com/harness/harness-cli/util/common/auth"
1819
"github.com/harness/harness-cli/util/common/errors"
1920
p "github.com/harness/harness-cli/util/common/progress"
@@ -32,9 +33,9 @@ func NewPushGoCmd(c *client.ClientWithResponses) *cobra.Command {
3233
Args: cobra.ExactArgs(2),
3334
PreRun: func(cmd *cobra.Command, args []string) {
3435
if pkgURL != "" {
35-
config.Global.Registry.PkgURL = pkgURL
36+
config.Global.Registry.PkgURL = util.GetPkgUrl(pkgURL)
3637
} else {
37-
config.Global.Registry.PkgURL = config.Global.APIBaseURL
38+
config.Global.Registry.PkgURL = util.GetPkgUrl(config.Global.APIBaseURL)
3839
}
3940
},
4041
RunE: func(cmd *cobra.Command, args []string) error {

util/utils.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@ func ProgressBar(current, total int, width int) string {
111111

112112
return fmt.Sprintf("%s %.1f%%", bar, percentage*100)
113113
}
114+
115+
// GetPkgUrl returns the URL for the packages
116+
func GetPkgUrl(url string) string {
117+
if !strings.Contains(url, "://") {
118+
url = "https://" + url
119+
}
120+
return url
121+
}

0 commit comments

Comments
 (0)