Skip to content

Commit db54c27

Browse files
fix(client): accept multi line config vars.
1 parent 6dfba06 commit db54c27

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

client/cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func ConfigPush(appID string, fileName string) error {
216216
func parseConfig(configVars []string) map[string]interface{} {
217217
configMap := make(map[string]interface{})
218218

219-
regex := regexp.MustCompile("^([A-z_]+[A-z0-9_]*)=(.+)$")
219+
regex := regexp.MustCompile(`^([A-z_]+[A-z0-9_]*)=([\s\S]+)$`)
220220
for _, config := range configVars {
221221
if regex.MatchString(config) {
222222
captures := regex.FindStringSubmatch(config)

tests/config_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import (
1111
)
1212

1313
var (
14-
configListCmd = "config:list --app={{.AppName}}"
15-
configSetCmd = "config:set FOO=讲台 --app={{.AppName}}"
16-
configSet2Cmd = "config:set FOO=10 --app={{.AppName}}"
17-
configSet3Cmd = "config:set POWERED_BY=\"the Deis team\" --app={{.AppName}}"
14+
configListCmd = "config:list --app={{.AppName}}"
15+
configSetCmd = "config:set FOO=讲台 --app={{.AppName}}"
16+
configSet2Cmd = "config:set FOO=10 --app={{.AppName}}"
17+
configSet3Cmd = "config:set POWERED_BY=\"the Deis team\" --app={{.AppName}}"
18+
configSet4Cmd = `config:set FOO="This is a
19+
multiline string" --app={{.AppName}}`
1820
configSetBuildpackCmd = "config:set BUILDPACK_URL=$BUILDPACK_URL --app={{.AppName}}"
1921
configUnsetCmd = "config:unset FOO --app={{.AppName}}"
2022
)
@@ -90,6 +92,8 @@ func configSetTest(t *testing.T, params *utils.DeisTestConfig) {
9092
utils.CheckList(t, appsInfoCmd, params, "(v5)", false)
9193
utils.Execute(t, configSet2Cmd, params, false, "10")
9294
utils.CheckList(t, appsInfoCmd, params, "(v6)", false)
95+
utils.Execute(t, configSet4Cmd, params, false, "")
96+
utils.CheckList(t, appsInfoCmd, params, "(v7)", false)
9397
}
9498

9599
func configPushTest(t *testing.T, params *utils.DeisTestConfig) {
@@ -101,14 +105,14 @@ func configPushTest(t *testing.T, params *utils.DeisTestConfig) {
101105
t.Fatal(err)
102106
}
103107
utils.Execute(t, "config:push --app {{.AppName}}", params, false, "Deis")
104-
utils.CheckList(t, appsInfoCmd, params, "(v7)", false)
108+
utils.CheckList(t, appsInfoCmd, params, "(v8)", false)
105109
if err := utils.Chdir(".."); err != nil {
106110
t.Fatal(err)
107111
}
108112
}
109113

110114
func configUnsetTest(t *testing.T, params *utils.DeisTestConfig) {
111115
utils.Execute(t, configUnsetCmd, params, false, "")
112-
utils.CheckList(t, appsInfoCmd, params, "(v8)", false)
116+
utils.CheckList(t, appsInfoCmd, params, "(v9)", false)
113117
utils.CheckList(t, "run env --app={{.AppName}}", params, "FOO", true)
114118
}

0 commit comments

Comments
 (0)