-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild_type.go
More file actions
44 lines (37 loc) · 972 Bytes
/
build_type.go
File metadata and controls
44 lines (37 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package gitreceive
import (
"fmt"
"github.com/drycc/controller-sdk-go/api"
"os"
)
type buildType string
func (b buildType) String() string {
return string(b)
}
const (
buildTypeSlugbuilder buildType = "slugbuilder"
buildTypeDockerbuilder buildType = "dockerbuilder"
)
func getBuildType(dirName string, config api.Config) buildType {
hasDockerfile := false
if _, err := os.Stat(fmt.Sprintf("%s/Dockerfile", dirName)); err == nil {
hasDockerfile = true
}
hasProcfile := false
if _, err := os.Stat(fmt.Sprintf("%s/Procfile", dirName)); err == nil {
hasProcfile = true
}
if hasDockerfile && hasProcfile {
if bTypeInterface, ok := config.Values["DRYCC_BUILDER"]; ok {
if strType, ok := bTypeInterface.(string); ok {
bType := buildType(strType)
if bType == buildTypeSlugbuilder || bType == buildTypeDockerbuilder {
return bType
}
}
}
} else if hasProcfile {
return buildTypeSlugbuilder
}
return buildTypeDockerbuilder
}