fix(helm): fixed golint warning due to Json function names

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
pull/3748/head
Arash Deshmeh 8 years ago
parent 5d4b930e51
commit e2f12db239

@ -207,11 +207,11 @@ func ToToml(v interface{}) string {
return b.String() return b.String()
} }
// ToJson takes an interface, marshals it to json, and returns a string. It will // ToJSON takes an interface, marshals it to json, and returns a string. It will
// always return a string, even on marshal error (empty string). // always return a string, even on marshal error (empty string).
// //
// This is designed to be called from a template. // This is designed to be called from a template.
func ToJson(v interface{}) string { func ToJSON(v interface{}) string {
data, err := json.Marshal(v) data, err := json.Marshal(v)
if err != nil { if err != nil {
// Swallow errors inside of a template. // Swallow errors inside of a template.
@ -220,13 +220,13 @@ func ToJson(v interface{}) string {
return string(data) return string(data)
} }
// FromJson converts a JSON document into a map[string]interface{}. // FromJSON converts a JSON document into a map[string]interface{}.
// //
// This is not a general-purpose JSON parser, and will not parse all valid // This is not a general-purpose JSON parser, and will not parse all valid
// JSON documents. Additionally, because its intended use is within templates // JSON documents. Additionally, because its intended use is within templates
// it tolerates errors. It will insert the returned error message string into // it tolerates errors. It will insert the returned error message string into
// m["Error"] in the returned map. // m["Error"] in the returned map.
func FromJson(str string) map[string]interface{} { func FromJSON(str string) map[string]interface{} {
m := map[string]interface{}{} m := map[string]interface{}{}
if err := json.Unmarshal([]byte(str), &m); err != nil { if err := json.Unmarshal([]byte(str), &m); err != nil {

@ -167,7 +167,7 @@ one:
} }
} }
func TestToJson(t *testing.T) { func TestToJSON(t *testing.T) {
expect := `{"foo":"bar"}` expect := `{"foo":"bar"}`
v := struct { v := struct {
Foo string `json:"foo"` Foo string `json:"foo"`
@ -175,12 +175,12 @@ func TestToJson(t *testing.T) {
Foo: "bar", Foo: "bar",
} }
if got := ToJson(v); got != expect { if got := ToJSON(v); got != expect {
t.Errorf("Expected %q, got %q", expect, got) t.Errorf("Expected %q, got %q", expect, got)
} }
} }
func TestFromJson(t *testing.T) { func TestFromJSON(t *testing.T) {
doc := `{ doc := `{
"hello": "world", "hello": "world",
"one": { "one": {
@ -188,7 +188,7 @@ func TestFromJson(t *testing.T) {
} }
} }
` `
dict := FromJson(doc) dict := FromJSON(doc)
if err, ok := dict["Error"]; ok { if err, ok := dict["Error"]; ok {
t.Fatalf("Parse error: %s", err) t.Fatalf("Parse error: %s", err)
} }
@ -210,7 +210,7 @@ func TestFromJson(t *testing.T) {
"three" "three"
] ]
` `
dict = FromJson(doc2) dict = FromJSON(doc2)
if _, ok := dict["Error"]; !ok { if _, ok := dict["Error"]; !ok {
t.Fatal("Expected parser error") t.Fatal("Expected parser error")
} }

@ -79,8 +79,8 @@ func FuncMap() template.FuncMap {
"toToml": chartutil.ToToml, "toToml": chartutil.ToToml,
"toYaml": chartutil.ToYaml, "toYaml": chartutil.ToYaml,
"fromYaml": chartutil.FromYaml, "fromYaml": chartutil.FromYaml,
"toJson": chartutil.ToJson, "toJson": chartutil.ToJSON,
"fromJson": chartutil.FromJson, "fromJson": chartutil.FromJSON,
// This is a placeholder for the "include" function, which is // This is a placeholder for the "include" function, which is
// late-bound to a template. By declaring it here, we preserve the // late-bound to a template. By declaring it here, we preserve the

Loading…
Cancel
Save