Skip to content

Commit

Permalink
fix protocal name
Browse files Browse the repository at this point in the history
  • Loading branch information
xh4n3 committed Jan 13, 2020
1 parent b081da8 commit 1167f06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 7 additions & 5 deletions cmd/helmpush/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type (
}
)

const Protocol = "acr://"

var (
v2settings v2environment.EnvSettings
settings = cli.New()
Expand Down Expand Up @@ -95,8 +97,8 @@ func newPushCmd(args []string) *cobra.Command {

p.out = cmd.OutOrStdout()

// If there are 4 args, this is likely being used as a downloader for cm:// protocol
if len(args) == 4 && strings.HasPrefix(args[3], "cm://") {
// If there are 4 args, this is likely being used as a downloader for acr:// protocol
if len(args) == 4 && strings.HasPrefix(args[3], Protocol) {
p.setFieldsFromEnv()
return p.download(args[3])
}
Expand Down Expand Up @@ -274,12 +276,12 @@ func (p *pushCmd) push() error {
password = p.password
}

// in case the repo is stored with cm:// protocol, remove it
// in case the repo is stored with acr:// protocol, remove it
var url string
if p.useHTTP {
url = strings.Replace(repo.Config.URL, "cm://", "http://", 1)
url = strings.Replace(repo.Config.URL, Protocol, "http://", 1)
} else {
url = strings.Replace(repo.Config.URL, "cm://", "https://", 1)
url = strings.Replace(repo.Config.URL, Protocol, "https://", 1)
}

client, err := cm.NewClient(
Expand Down
8 changes: 5 additions & 3 deletions cmd/helmpush/main_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Modifications copyright (C) 2019 Alibaba Group Holding Limited / Yuning Xie (xyn1016@gmail.com)

package main

import (
Expand Down Expand Up @@ -123,17 +125,17 @@ func TestPushCmd(t *testing.T) {
t.Error("expecting error with bad response body, instead got nil")
}

// cm:// downloader
// acr:// downloader
statusCode = 200
os.Setenv("HELM_REPO_USE_HTTP", "true")
downloaderBaseURL := strings.Replace(ts.URL, "http://", "cm://", 1)
downloaderBaseURL := strings.Replace(ts.URL, "http://", Protocol, 1)

// fails with no file path
args = []string{"", "", "", downloaderBaseURL}
cmd = newPushCmd(args)
err = cmd.RunE(cmd, args)
if err == nil {
t.Error("expecting error with bad cm:// url, instead got nil")
t.Error("expecting error with bad acr:// url, instead got nil")
}

// index.yaml
Expand Down

0 comments on commit 1167f06

Please sign in to comment.