-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AWS S3: consolidate environment and defaults
* single `api/env/aws.go` * cleanup, comment, and document Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
f6ad143
commit 833ba65
Showing
8 changed files
with
78 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Package env contains environment variables | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package env | ||
|
||
import "os" | ||
|
||
func AwsDefaultRegion() (region string) { | ||
if region = os.Getenv(AWS.Region); region == "" { | ||
// from https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html: | ||
// "Buckets in region `us-east-1` have a LocationConstraint of null." | ||
region = "us-east-1" | ||
} | ||
return region | ||
} | ||
|
||
// use S3_ENDPOINT to globally override the default 'https://s3.amazonaws.com' endpoint | ||
// NOTE: the same can be done on a per-bucket basis, via bucket prop `Extra.AWS.Endpoint` | ||
// (bucket override will always take precedence) | ||
|
||
// ditto non-default profile via "AWS_PROFILE" (the default one is called [default]) | ||
|
||
var ( | ||
AWS = struct { | ||
Endpoint string | ||
Region string | ||
Profile string | ||
}{ | ||
Endpoint: "S3_ENDPOINT", | ||
Region: "AWS_REGION", | ||
Profile: "AWS_PROFILE", | ||
} | ||
) |
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 was deleted.
Oops, something went wrong.
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