Skip to content

Commit

Permalink
Merge pull request helm#11214 from d-d-up/fix_special_string
Browse files Browse the repository at this point in the history
fix special string in the filename
  • Loading branch information
hickeyma authored Aug 11, 2022
2 parents d9f776b + ece46c1 commit 4cd966f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/cli/values/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ func readFile(filePath string, p getter.Providers) ([]byte, error) {
if strings.TrimSpace(filePath) == "-" {
return ioutil.ReadAll(os.Stdin)
}
u, _ := url.Parse(filePath)
u, err := url.Parse(filePath)
if err != nil {
return nil, err
}

// FIXME: maybe someone handle other protocols like ftp.
g, err := p.ByScheme(u.Scheme)
Expand Down
11 changes: 11 additions & 0 deletions pkg/cli/values/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package values
import (
"reflect"
"testing"

"helm.sh/helm/v3/pkg/getter"
)

func TestMergeValues(t *testing.T) {
Expand Down Expand Up @@ -75,3 +77,12 @@ func TestMergeValues(t *testing.T) {
t.Errorf("Expected a map with different keys to merge properly with another map. Expected: %v, got %v", expectedMap, testMap)
}
}

func TestReadFile(t *testing.T) {
var p getter.Providers
filePath := "%a.txt"
_, err := readFile(filePath, p)
if err == nil {
t.Errorf("Expected error when has special strings")
}
}

0 comments on commit 4cd966f

Please sign in to comment.