Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions util/config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func UnmarshalLocalFile(path string, obj interface{}) error {
// UnmarshalRemoteFile retrieves JSON or YAML through a GET request.
// The caller is responsible for checking error return values.
func UnmarshalRemoteFile(url string, obj interface{}) error {
data, err := readRemoteFile(url)
data, err := ReadRemoteFile(url)
if err == nil {
err = unmarshalObject(data, obj)
}
Expand All @@ -61,7 +61,7 @@ func UnmarshalRemoteFile(url string, obj interface{}) error {

// ReadRemoteFile issues a GET request to retrieve the contents of the specified URL as a byte array.
// The caller is responsible for checking error return values.
func readRemoteFile(url string) ([]byte, error) {
func ReadRemoteFile(url string) ([]byte, error) {
var data []byte
resp, err := http.Get(url)
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion util/config/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestUnmarshalRemoteFile(t *testing.T) {
address := <-c
t.Logf("Listening at address: %s", address)

data, err := readRemoteFile("http://" + address)
data, err := ReadRemoteFile("http://" + address)
if string(data) != sentinel {
t.Errorf("Test data did not match (err = %v)! Expected %q and received %q", err, sentinel, string(data))
}
Expand Down
10 changes: 9 additions & 1 deletion util/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package helm
import (
"fmt"
"io/ioutil"
"net/url"
"os/exec"
"path"
"strings"
Expand All @@ -12,6 +13,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/util/config"
"github.com/argoproj/argo-cd/util/kube"
)

Expand Down Expand Up @@ -80,7 +82,13 @@ func (h *helm) GetParameters(valuesFiles []string) ([]*argoappv1.ComponentParame
}
values := append([]string{out})
for _, file := range valuesFiles {
fileValues, err := ioutil.ReadFile(path.Join(h.path, file))
var fileValues []byte
parsedURL, err := url.ParseRequestURI(file)
if err == nil && (parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
fileValues, err = config.ReadRemoteFile(file)
} else {
fileValues, err = ioutil.ReadFile(path.Join(h.path, file))
}
if err != nil {
return nil, fmt.Errorf("failed to read value file %s: %s", file, err)
}
Expand Down
10 changes: 10 additions & 0 deletions util/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ func TestHelmTemplateValues(t *testing.T) {
assert.Equal(t, int32(3), *dep.Spec.Replicas)
}
}
}

func TestHelmTemplateValuesURL(t *testing.T) {
h := NewHelmApp("./testdata/redis")
valuesFiles := []string{"https://raw.githubusercontent.com/argoproj/argo-cd/master/util/helm/testdata/redis/values-production.yaml"}
objs, err := h.Template("test", "", valuesFiles, nil)
assert.Nil(t, err)
assert.Equal(t, 8, len(objs))
params, err := h.GetParameters(valuesFiles)
assert.NoError(t, err)
assert.True(t, len(params) > 0)
}

func TestHelmGetParams(t *testing.T) {
Expand Down