From d158dbdc73db7d64690ba2f308927daddabbbdc2 Mon Sep 17 00:00:00 2001 From: Matt Jadud Date: Mon, 4 Mar 2024 23:11:09 -0500 Subject: [PATCH] Use URI, not Endpoint --- internal/pipes/s3.go | 2 +- internal/vcap/vcap.go | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/internal/pipes/s3.go b/internal/pipes/s3.go index a208cfd..958a776 100644 --- a/internal/pipes/s3.go +++ b/internal/pipes/s3.go @@ -24,7 +24,7 @@ func S3(in_pipe *script.Pipe, "s3", "cp", "--endpoint-url", - up.Endpoint, + up.Uri, "-", fmt.Sprintf("s3://%s/backups/%s-%s_%s.dump", up.Bucket, diff --git a/internal/vcap/vcap.go b/internal/vcap/vcap.go index 1f6ff0f..2452d2f 100644 --- a/internal/vcap/vcap.go +++ b/internal/vcap/vcap.go @@ -2,6 +2,7 @@ package vcap import ( "bytes" + "fmt" "os" "golang.org/x/exp/slices" @@ -66,7 +67,25 @@ func GetS3Credentials(name string) (*structs.CredentialsS3, error) { } for _, instance := range instanceSlice { if instance.Name == name { - return &instance.Credentials, nil + all_looks_good := false + + // We have to have an endpoint, or the two key bits. + if (len(instance.Credentials.AccessKeyId) > 0) && + (len(instance.Credentials.SecretAccessKey) > 0) { + all_looks_good = true + } else if len(instance.Credentials.Uri) > 0 { + all_looks_good = true + } + + if len(instance.Credentials.Region) < 1 { + logging.Logger.Println("BACKUPS region is empty") + os.Exit(-1) + } + if all_looks_good { + return &instance.Credentials, nil + } else { + return nil, fmt.Errorf("BACKUPS no access key or endpoint") + } } }