Skip to content

Commit 1c692c5

Browse files
arschlesAaron Schlesinger
authored andcommitted
fix(build.go,config.go,receive.go): accept fewer config vars
1 parent cfe8294 commit 1c692c5

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func build(conf *Config, etcdClient *etcd.Client) error {
116116
return errGitShaTooShort{sha: gitSha}
117117
}
118118
shortSha := conf.SHA[0:8]
119-
appName := conf.App
119+
appName := conf.App()
120120
//
121121
// cd $(dirname $0) # ensure we are in the root dir
122122
//
@@ -436,8 +436,8 @@ func build(conf *Config, etcdClient *etcd.Client) error {
436436
//
437437

438438
// Ensure that the app config can be gotten from workflow. We don't do anything with this information
439-
if _, err := getAppConfig(conf, builderKey, conf.Username, conf.App); err != nil {
440-
return fmt.Errorf("getting app config for %s (%s)", conf.App, err)
439+
if _, err := getAppConfig(conf, builderKey, conf.Username, appName); err != nil {
440+
return fmt.Errorf("getting app config for %s (%s)", appName, err)
441441
}
442442

443443
// # use Procfile if provided, otherwise try default process types from ./release
@@ -459,7 +459,7 @@ func build(conf *Config, etcdClient *etcd.Client) error {
459459
Sha: conf.SHA,
460460
ReceiveUser: conf.Username,
461461
ReceiveRepo: conf.Repository,
462-
Image: conf.ImageName,
462+
Image: imageName,
463463
Procfile: procType,
464464
Dockerfile: strings.Title(fmt.Sprintf("%t", usingDockerfile)),
465465
}

pkg/gitreceive/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package gitreceive
22

3+
import (
4+
"strings"
5+
)
6+
37
type Config struct {
48
// k8s service discovery env vars
59
WorkflowHost string `envconfig:"deis_workflow_service_host"`
@@ -13,7 +17,14 @@ type Config struct {
1317
Repository string `envconfig:"repository"`
1418
SHA string `envconfing:"sha"`
1519
Username string `envconfig:"username"`
16-
App string `envconfing:"app"`
1720
Fingerprint string `envconfing:"fingerprint"`
1821
PodNamespace string `envconfig:"pod_namespace"`
1922
}
23+
24+
func (c Config) App() string {
25+
li := strings.LastIndex(c.Repository, ".")
26+
if li == -1 {
27+
return c.Repository
28+
}
29+
return c.Repository[0:li]
30+
}

pkg/gitreceive/receive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func receive(conf *Config, newRev string) error {
3838
urlStr := fmt.Sprintf("http://%s:%s/v2/hooks/push", conf.WorkflowHost, conf.WorkflowPort)
3939
bodyMap := map[string]string{
4040
"receive_user": conf.Username,
41-
"receive_repo": conf.App,
41+
"receive_repo": conf.App(),
4242
"sha": conf.SHA,
4343
"fingerprint": conf.Fingerprint,
4444
"ssh_connection": conf.SSHConnection,

0 commit comments

Comments
 (0)