Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/codingconcepts/setcfg into …
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
codingconcepts committed Oct 5, 2021
2 parents af71eb5 + 12ab848 commit 1745557
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/input-single.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a: ~a~
2 changes: 1 addition & 1 deletion setcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func addAdhocFields(envParsed map[interface{}]interface{}, adhoc *flagStrings) e
}

func parseAdhocKeyValue(field string) (string, string, error) {
parts := strings.Split(field, "=")
parts := strings.SplitN(field, "=", 2)
if len(parts) < 2 {
return "", "", fmt.Errorf("adhoc fields must be in the format of key=value")
}
Expand Down
8 changes: 8 additions & 0 deletions setcfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ func TestParse(t *testing.T) {
},
exp: "a: bye\n",
},
{
name: "single level adhoc placeholder has trailing equals sign",
input: "password: ~password~",
adhocFields: &flagStrings{
"password=cGFzc3dvcmQxMjM0Cg==",
},
exp: "password: cGFzc3dvcmQxMjM0Cg==\n",
},
{
name: "multi level with a matching placeholder - map",
input: "a:\n b:\n c: ~c~",
Expand Down

0 comments on commit 1745557

Please sign in to comment.