Skip to content

Commit 042ef60

Browse files
author
Matthew Fisher
committed
fix(builder): properly escape backticks in envvars
for real this time!
1 parent f5e6b10 commit 042ef60

4 files changed

Lines changed: 7 additions & 13 deletions

File tree

builder/bin/get-app-values.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ func main() {
2626
os.Exit(1)
2727
}
2828

29+
var retVal string
2930
for _, value := range values {
30-
fmt.Println(value)
31+
retVal = fmt.Sprintf("%s%s", retVal, value)
3132
}
33+
fmt.Println(retVal)
3234
}

builder/image/templates/builder

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ usage() {
2727
echo "Usage: $0 <user> <repo> <sha>"
2828
}
2929

30-
parse-string(){
31-
# helper to avoid the single quote escape
32-
# occurred in command substitution
33-
local args=() idx=0 IFS=' ' c
34-
for c; do printf -v args[idx++] '%s ' "$c"; done
35-
printf "%s\n" "${args[*]}"
36-
}
37-
3830
if [ $# -ne $ARGS ]; then
3931
usage
4032
exit 1
@@ -113,7 +105,7 @@ if [ ! -f Dockerfile ]; then
113105
BUILD_OPTS+=' deis/slugbuilder'
114106

115107
# build the application and attach to the process
116-
JOB=$(eval '$(parse-string "${BUILD_OPTS[@]}")' )
108+
JOB=$(${BUILD_OPTS[@]})
117109
docker attach $JOB
118110

119111
# copy out the compiled slug

builder/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func ParseControllerConfig(bytes []byte) ([]string, error) {
105105

106106
retVal := []string{}
107107
for k, v := range controllerConfig.Values {
108-
retVal = append(retVal, fmt.Sprintf(" -e %s=\"%v\"", k, v))
108+
retVal = append(retVal, fmt.Sprintf(" -e %s='%v'", k, v))
109109
}
110110
return retVal, nil
111111
}

builder/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ func TestParseControllerConfigGood(t *testing.T) {
163163
t.Errorf("expected 2, got %d", len(config))
164164
}
165165

166-
if !stringInSlice(config, " -e CAR=\"star\"") {
167-
t.Error("expected ' -e CAR=\"star\"' in slice")
166+
if !stringInSlice(config, " -e CAR='star'") {
167+
t.Error("expected ' -e CAR='star'' in slice")
168168
}
169169
}
170170

0 commit comments

Comments
 (0)