From b1fa3be97041390363497770506ecf2d6b4b41ec Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 13 Nov 2022 20:14:16 +0100 Subject: [PATCH] Fix garage mc not getting default secret key set correctly --- entrypoint/src/cmd/entrypoint/garage.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/entrypoint/src/cmd/entrypoint/garage.go b/entrypoint/src/cmd/entrypoint/garage.go index ce346d4..4401ded 100644 --- a/entrypoint/src/cmd/entrypoint/garage.go +++ b/entrypoint/src/cmd/entrypoint/garage.go @@ -36,15 +36,12 @@ var subCmdGarageMC = subCmd{ s3APIAddr := hostBootstrap.ChooseGaragePeer().S3APIAddr() - if *keyID == "" || *keySecret == "" { + if *keyID == "" { + *keyID = hostBootstrap.Garage.GlobalBucketS3APICredentials.ID + } - if *keyID == "" { - *keyID = hostBootstrap.Garage.GlobalBucketS3APICredentials.ID - } - - if *keySecret == "" { - *keyID = hostBootstrap.Garage.GlobalBucketS3APICredentials.Secret - } + if *keySecret == "" { + *keySecret = hostBootstrap.Garage.GlobalBucketS3APICredentials.Secret } args := flags.Args() @@ -56,13 +53,15 @@ var subCmdGarageMC = subCmd{ args = append([]string{"mc"}, args...) var ( + mcHostVar = fmt.Sprintf( + "MC_HOST_garage=http://%s:%s@%s", + *keyID, *keySecret, s3APIAddr, + ) + binPath = filepath.Join(envAppDirPath, "bin/mc") cliEnv = append( os.Environ(), - fmt.Sprintf( - "MC_HOST_garage=http://%s:%s@%s", - *keyID, *keySecret, s3APIAddr, - ), + mcHostVar, // The garage docs say this is necessary, though nothing bad // seems to happen if we leave it out *shrug*