|
@@ -159,7 +159,7 @@ func TestExecute(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- name: "fromJSON func",
|
|
|
|
|
|
|
+ name: "fromJson func",
|
|
|
tpl: map[string][]byte{
|
|
tpl: map[string][]byte{
|
|
|
"foo": []byte("{{ $var := .secret | fromJson }}{{ $var.foo }}"),
|
|
"foo": []byte("{{ $var := .secret | fromJson }}{{ $var.foo }}"),
|
|
|
},
|
|
},
|
|
@@ -171,7 +171,7 @@ func TestExecute(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- name: "from & toJSON func",
|
|
|
|
|
|
|
+ name: "from & toJson func",
|
|
|
tpl: map[string][]byte{
|
|
tpl: map[string][]byte{
|
|
|
"foo": []byte("{{ $var := .secret | fromJson }}{{ $var.foo | toJson }}"),
|
|
"foo": []byte("{{ $var := .secret | fromJson }}{{ $var.foo | toJson }}"),
|
|
|
},
|
|
},
|
|
@@ -183,6 +183,30 @@ func TestExecute(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
|
|
+ name: "fromJson & toYaml func",
|
|
|
|
|
+ tpl: map[string][]byte{
|
|
|
|
|
+ "foo": []byte("{{ $var := .secret | fromJson | toYaml }}{{ $var }}"),
|
|
|
|
|
+ },
|
|
|
|
|
+ data: map[string][]byte{
|
|
|
|
|
+ "secret": []byte(`{"foo": "bar"}`),
|
|
|
|
|
+ },
|
|
|
|
|
+ expetedData: map[string][]byte{
|
|
|
|
|
+ "foo": []byte(`foo: bar`),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: "fromYaml & toJson func",
|
|
|
|
|
+ tpl: map[string][]byte{
|
|
|
|
|
+ "foo": []byte("{{ $var := .secret | fromYaml | toJson }}{{ $var }}"),
|
|
|
|
|
+ },
|
|
|
|
|
+ data: map[string][]byte{
|
|
|
|
|
+ "secret": []byte(`foo: bar`),
|
|
|
|
|
+ },
|
|
|
|
|
+ expetedData: map[string][]byte{
|
|
|
|
|
+ "foo": []byte(`{"foo":"bar"}`),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
name: "use sprig functions",
|
|
name: "use sprig functions",
|
|
|
tpl: map[string][]byte{
|
|
tpl: map[string][]byte{
|
|
|
"foo": []byte(`{{ .path | ext }}`),
|
|
"foo": []byte(`{{ .path | ext }}`),
|
|
@@ -302,7 +326,7 @@ func TestExecute(t *testing.T) {
|
|
|
expErr: "unable to decode pkcs12",
|
|
expErr: "unable to decode pkcs12",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- name: "fromJSON error",
|
|
|
|
|
|
|
+ name: "fromJson error",
|
|
|
tpl: map[string][]byte{
|
|
tpl: map[string][]byte{
|
|
|
"key": []byte(`{{ "{ # no json # }" | fromJson }}`),
|
|
"key": []byte(`{{ "{ # no json # }" | fromJson }}`),
|
|
|
},
|
|
},
|