forked from redhat-developer/mapt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check for remote state on backed url and fix config if needed. Fix
redhat-developer#392 Signed-off-by: Adrian Riobo <[email protected]>
- Loading branch information
1 parent
a77ef40
commit 8ef3a41
Showing
211 changed files
with
94,816 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package data | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/s3" | ||
) | ||
|
||
const ( | ||
s3Prefix = "s3://" | ||
s3PathSeparator = "/" | ||
) | ||
|
||
func ValidateS3Path(p string) bool { return strings.HasPrefix(p, s3Prefix) } | ||
|
||
func GetBucketLocationFromS3Path(p string) (*string, error) { | ||
bucket, err := getBucketFromS3Path(p) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return GetBucketLocation(*bucket) | ||
} | ||
|
||
func GetBucketLocation(bucketName string) (*string, error) { | ||
cfg, err := getGlobalConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
client := s3.NewFromConfig(cfg) | ||
output, err := client.GetBucketLocation( | ||
context.Background(), | ||
&s3.GetBucketLocationInput{ | ||
Bucket: &bucketName, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get bucket location: %w", err) | ||
} | ||
region := string(output.LocationConstraint) | ||
return ®ion, nil | ||
} | ||
|
||
func getBucketFromS3Path(p string) (*string, error) { | ||
if !ValidateS3Path(p) { | ||
return nil, fmt.Errorf("this is not a valid s3 path") | ||
} | ||
pWithoutProtocol := strings.TrimPrefix(p, s3Prefix) | ||
pParts := strings.Split(pWithoutProtocol, s3PathSeparator) | ||
return &pParts[0], nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/CHANGELOG.md
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.