Skip to content

Commit 53204c1

Browse files
author
Matthew Fisher
committed
fix(builder): parse release info correctly
Release info was being parsed improperly. We should only fall back to the Procfile if we cannot find any default process types from the release info.
1 parent 1e8c17b commit 53204c1

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

builder/image/templates/builder

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ else
149149
RELEASE_INFO="{}"
150150
fi
151151

152-
if [ -f $TMP_DIR/Procfile ]; then
153-
# update release info with data from the Procfile
154-
RELEASE_INFO=$(cat $TMP_DIR/Procfile | /app/bin/yaml2json-procfile)
152+
if [ "$RELEASE_INFO" == "{}" ]; then
153+
if [ -f $TMP_DIR/Procfile ]; then
154+
# fall back to Procfile if there's no default process types
155+
# FIXME: refactor into slugbuilder
156+
RELEASE_INFO=$(cat $TMP_DIR/Procfile | /app/bin/yaml2json-procfile)
157+
fi
155158
fi
156159

157160
puts-step "Launching... "

builder/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ParseReleaseVersion(bytes []byte) (int, error) {
7171

7272
func GetDefaultType(bytes []byte) (string, error) {
7373
type YamlTypeMap struct {
74-
DefaultProcessTypes ProcessType
74+
DefaultProcessTypes ProcessType `default_process_types`
7575
}
7676

7777
var p YamlTypeMap
@@ -80,7 +80,7 @@ func GetDefaultType(bytes []byte) (string, error) {
8080
return "", err
8181
}
8282

83-
retVal, err := json.Marshal(&p)
83+
retVal, err := json.Marshal(&p.DefaultProcessTypes)
8484

8585
if err != nil {
8686
return "", err

builder/utils_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ default_process_types:
121121
if err != nil {
122122
t.Error(err)
123123
}
124-
if defaultType == "" {
125-
t.Error("default type cannot be empty")
124+
if defaultType != `{"web":"while true; do echo hello; sleep 1; done"}` && string(data) != "" {
125+
t.Errorf("incorrect default type, got %s", defaultType)
126+
}
127+
if string(data) == "" && defaultType != "{}" {
128+
t.Errorf("incorrect default type, got %s", defaultType)
126129
}
127130
}
128131
}

0 commit comments

Comments
 (0)