Skip to content

Commit 41074e4

Browse files
arschlesAaron Schlesinger
authored andcommitted
ref(build.go): use the new mcCmd utility func
1 parent 6b53e13 commit 41074e4

1 file changed

Lines changed: 5 additions & 29 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -278,44 +278,21 @@ func build(conf *Config, builderKey, gitSha string) error {
278278
if err := os.MkdirAll(configDir, os.ModePerm); err != nil {
279279
return fmt.Errorf("creating minio config file (%s)", err)
280280
}
281-
baseMinioCmd := exec.Command("mc", "-C", configDir, "--quiet")
282-
baseMinioCmd.Stderr = os.Stderr
283281

284282
// $MC_PREFIX config host add "$HTTP_PREFIX://$S3EP" $ACCESS_KEY $ACCESS_SECRET &>/dev/null
285-
configCmd := baseMinioCmd
286-
configCmd.Args = append(
287-
configCmd.Args,
288-
"config",
289-
"host",
290-
"add",
291-
fmt.Sprintf("%s://%s:%s", storage.schema(), storage.host(), storage.port()),
292-
creds.key,
293-
creds.secret,
294-
)
295-
if err := configCmd.Run(); err != nil {
283+
configCmd := mcCmd(configDir, "config", "host", "add", fmt.Sprintf("%s://%s:%s", storage.schema(), storage.host(), storage.port()), creds.key, creds.secret)
284+
if err := run(configCmd); err != nil {
296285
return fmt.Errorf("configuring the minio client (%s)", err)
297286
}
298287

299288
// $MC_PREFIX mb "$HTTP_PREFIX://${S3EP}/git" &>/dev/null
300-
makeBucketCmd := baseMinioCmd
301-
makeBucketCmd.Args = append(
302-
makeBucketCmd.Args,
303-
"mb",
304-
fmt.Sprintf("%s://%s:%s/git", storage.schema(), storage.host(), storage.port()),
305-
)
306-
289+
makeBucketCmd := mcCmd(configDir, "mb", fmt.Sprintf("%s://%s:%s/git", storage.schema(), storage.host(), storage.port()))
307290
// Don't look for errors here. Buckets may already exist
308291
// https://github.com/deis/builder/issues/80 will eliminate this distaste
309292
run(makeBucketCmd)
310293

311294
// $MC_PREFIX cp ${APP_NAME}.tar.gz $TAR_URL &>/dev/null
312-
cpCmd := baseMinioCmd
313-
cpCmd.Args = append(
314-
cpCmd.Args,
315-
"cp",
316-
fmt.Sprintf("%s.tar.gz", appName),
317-
tarURL,
318-
)
295+
cpCmd := mcCmd(configDir, "cp", fmt.Sprintf("%s.tar.gz", appName), tarURL)
319296
cpCmd.Dir = repoDir
320297
if err := run(cpCmd); err != nil {
321298
return fmt.Errorf("copying %s.tar.gz to %s (%s)", appName, tarURL, err)
@@ -404,8 +381,7 @@ func build(conf *Config, builderKey, gitSha string) error {
404381
// fi
405382

406383
// poll the s3 server to ensure the slug exists
407-
lsCmd := baseMinioCmd
408-
lsCmd.Args = append(lsCmd.Args, "ls", pushURL)
384+
lsCmd := mcCmd(configDir, "ls", pushURL)
409385
for {
410386
// for now, assume the error indicates that the slug wasn't there, nothing else
411387
// TODO: implement https://github.com/deis/builder/issues/80, which will clean this up siginficantly

0 commit comments

Comments
 (0)