Skip to content

Commit

Permalink
fix(config): Handle newlines in YAMPL_VALUE env
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 26, 2024
1 parent 812db1d commit 3c0bb1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/config/values_hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"bufio"
"os"
"strings"
)

Expand Down Expand Up @@ -29,6 +30,10 @@ func FixStringToStringNewlines(s []string) []string {
result = append(result, arg)
}
}
envName := EnvPrefix + strings.ToUpper(ValueFlag)
if env := os.Getenv(envName); env != "" {
_ = os.Setenv(envName, strings.ReplaceAll(env, "\n", ","))
}
return result
}

Expand Down
7 changes: 7 additions & 0 deletions internal/config/values_hack_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package config

import (
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func TestFixStringToStringNewlines(t *testing.T) {
t.Run("env", func(t *testing.T) {
t.Setenv("YAMPL_VALUE", "a=a\nb=b")
FixStringToStringNewlines([]string{})
assert.Equal(t, "a=a,b=b", os.Getenv("YAMPL_VALUE"))
})

type args struct {
s []string
}
Expand Down

0 comments on commit 3c0bb1e

Please sign in to comment.