Skip to content

Commit 06c1b71

Browse files
author
Aaron Schlesinger
committed
fix(pkg/gitreceive): create and use a storage.Client
The client includes the endpoint as well as the actual client library. The build func uses the endpoint
1 parent 7c8dc9b commit 06c1b71

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/deis/builder/pkg/gitreceive/storage"
1717
"github.com/deis/builder/pkg/sys"
1818
"github.com/deis/pkg/log"
19-
s3 "github.com/minio/minio-go"
2019
"gopkg.in/yaml.v2"
2120

2221
"k8s.io/kubernetes/pkg/api"
@@ -42,7 +41,7 @@ func run(cmd *exec.Cmd) error {
4241
return cmd.Run()
4342
}
4443

45-
func build(conf *Config, s3Client *s3.Client, kubeClient *client.Client, fs sys.FS, env sys.Env, builderKey, rawGitSha string) error {
44+
func build(conf *Config, s3Client *storage.Client, kubeClient *client.Client, fs sys.FS, env sys.Env, builderKey, rawGitSha string) error {
4645
repo := conf.Repository
4746
gitSha, err := git.NewSha(rawGitSha)
4847
if err != nil {
@@ -64,7 +63,7 @@ func build(conf *Config, s3Client *s3.Client, kubeClient *client.Client, fs sys.
6463
return fmt.Errorf("unable to create tmpdir %s (%s)", buildDir, err)
6564
}
6665

67-
slugBuilderInfo := storage.NewSlugBuilderInfo(s3Client.Endpoint, conf.Bucket, appName, slugName, gitSha)
66+
slugBuilderInfo := storage.NewSlugBuilderInfo(s3Client.Endpoint.URLStr, conf.Bucket, appName, slugName, gitSha)
6867

6968
// Get the application config from the controller, so we can check for a custom buildpack URL
7069
appConf, err := getAppConfig(conf, builderKey, conf.Username, appName)

pkg/gitreceive/storage/client.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ import (
55
s3 "github.com/minio/minio-go"
66
)
77

8+
type Client struct {
9+
*s3.Client
10+
Endpoint *Endpoint
11+
}
12+
813
// GetClient returns a S3 API compatible storage client
14+
<<<<<<< 7c8dc9bdf6ffed171ed952661229ae2b8590cef7
915
func GetClient(regionStr string, fs sys.FS, env sys.Env) (*s3.Client, error) {
1016
auth, err := getAuth(fs)
17+
=======
18+
func GetClient(regionStr string) (*Client, error) {
19+
auth, err := getAuth()
20+
>>>>>>> fix(pkg/gitreceive): create and use a storage.Client
1121
if err != nil {
1222
return nil, err
1323
}
@@ -17,5 +27,9 @@ func GetClient(regionStr string, fs sys.FS, env sys.Env) (*s3.Client, error) {
1727
return nil, err
1828
}
1929

20-
return s3.New(endpoint, auth.accessKeyID, auth.accessKeySecret, false), nil
30+
s3Client, err := s3.New(endpoint.URLStr, auth.accessKeyID, auth.accessKeySecret, false)
31+
if err != nil {
32+
return nil, err
33+
}
34+
return &Client{Client: s3Client, Endpoint: endpoint}, nil
2135
}

0 commit comments

Comments
 (0)