Skip to content

Commit dd02221

Browse files
arschlesAaron Schlesinger
authored andcommitted
fix(build.go,config.go,receive.go,run.go): remove SHA from config
because it’s fetched from stdin, not the env
1 parent 9e0bd1d commit dd02221

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (e errGitShaTooShort) Error() string {
2929
return fmt.Sprintf("git sha %s was too short", e.sha)
3030
}
3131

32-
func build(conf *Config, etcdClient *etcd.Client) error {
32+
func build(conf *Config, etcdClient *etcd.Client, gitSha string) error {
3333
// TODO: replace etcd usage here with something else. See https://github.com/deis/builder/issues/81
3434
builderKey, err := getBuilderKey(etcdClient)
3535
if err != nil {
@@ -111,11 +111,10 @@ func build(conf *Config, etcdClient *etcd.Client) error {
111111
// SHORT_SHA=${GIT_SHA:0:8}
112112
// APP_NAME="${REPO%.*}"
113113
repo := conf.Repository
114-
gitSha := conf.SHA
115114
if len(gitSha) <= shortShaIdx {
116115
return errGitShaTooShort{sha: gitSha}
117116
}
118-
shortSha := conf.SHA[0:8]
117+
shortSha := gitSha[0:8]
119118
appName := conf.App()
120119
//
121120
// cd $(dirname $0) # ensure we are in the root dir
@@ -456,7 +455,7 @@ func build(conf *Config, etcdClient *etcd.Client) error {
456455
log.Info("Launching...")
457456

458457
buildHook := &pkg.BuildHook{
459-
Sha: conf.SHA,
458+
Sha: gitSha,
460459
ReceiveUser: conf.Username,
461460
ReceiveRepo: conf.Repository,
462461
Image: imageName,

pkg/gitreceive/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type Config struct {
1515
SSHConnection string `envconfig:"SSH_CONNECTION" required:"true"`
1616
SSHOriginalCommand string `envconfig:"SSH_ORIGINAL_COMMAND" required:"true"`
1717
Repository string `envconfig:"REPOSITORY" required:"true"`
18-
SHA string `envconfig:"SHA" required:"true"`
1918
Username string `envconfig:"USERNAME" required:"true"`
2019
Fingerprint string `envconfig:"FINGERPRINT" required:"true"`
2120
PodNamespace string `envconfig:"POD_NAMESPACE" required:"true"`

pkg/gitreceive/receive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func (e errInvalidHTTPStatusCode) Error() string {
3434
return fmt.Sprintf("expected status code %d, got %d", e.expected, e.actual)
3535
}
3636

37-
func receive(conf *Config, newRev string) error {
37+
func receive(conf *Config, gitSha 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,
4141
"receive_repo": conf.App(),
42-
"sha": conf.SHA,
42+
"sha": gitSha,
4343
"fingerprint": conf.Fingerprint,
4444
"ssh_connection": conf.SSHConnection,
4545
"ssh_original_command": conf.SSHOriginalCommand,

pkg/gitreceive/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Run(conf *Config) error {
6969
if err := receive(conf, newRev); err != nil {
7070
return err
7171
}
72-
if err := build(conf, etcdClient); err != nil {
72+
if err := build(conf, etcdClient, newRev); err != nil {
7373
return err
7474
}
7575
}

0 commit comments

Comments
 (0)