Skip to content

Commit f7f3e3c

Browse files
author
Aaron Schlesinger
committed
ref(build.go,run.go): create s3 client and pass into the build func
1 parent 0ff44a1 commit f7f3e3c

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,7 @@ func run(cmd *exec.Cmd) error {
6060
return cmd.Run()
6161
}
6262

63-
func build(conf *Config, builderKey, gitSha string) error {
64-
storage, err := getStorageConfig()
65-
if err != nil {
66-
return err
67-
}
68-
creds, err := getStorageCreds()
69-
if err == errMissingKey || err == errMissingSecret {
70-
return err
71-
}
72-
63+
func build(conf *Config, s3Client *s3.Client, builderKey, gitSha string) error {
7364
repo := conf.Repository
7465
if len(gitSha) <= shortShaIdx {
7566
return errGitShaTooShort{sha: gitSha}

pkg/gitreceive/run.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/deis/builder/pkg/gitreceive/log"
11+
"github.com/deis/builder/pkg/gitreceive/storage"
1112
)
1213

1314
const (
@@ -30,6 +31,12 @@ func Run(conf *Config) error {
3031
return fmt.Errorf("couldn't get builder key from %s (%s)", builderKeyLocation, err)
3132
}
3233
builderKey := string(builderKeyBytes)
34+
35+
s3Client, err := storage.GetClient()
36+
if err != nil {
37+
return fmt.Errorf("configuring S3 client (%s)", err)
38+
}
39+
3340
scanner := bufio.NewScanner(os.Stdin)
3441
for scanner.Scan() {
3542
line := scanner.Text()
@@ -46,7 +53,7 @@ func Run(conf *Config) error {
4653
}
4754
// if we're processing a receive-pack on an existing repo, run a build
4855
if strings.HasPrefix(conf.SSHOriginalCommand, "git-receive-pack") {
49-
if err := build(conf, builderKey, newRev); err != nil {
56+
if err := build(conf, s3Client, builderKey, newRev); err != nil {
5057
return err
5158
}
5259
}

0 commit comments

Comments
 (0)