-
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.
environment names are constants (part two)
Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
5ba9180
commit a9afcfa
Showing
11 changed files
with
57 additions
and
79 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 |
---|---|---|
@@ -1,35 +1,28 @@ | ||
// Package env contains environment variables | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
* Copyright (c) 2024-2025, 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 | ||
Inventory string | ||
}{ | ||
Endpoint: "S3_ENDPOINT", | ||
Region: "AWS_REGION", | ||
Profile: "AWS_PROFILE", | ||
} | ||
const ( | ||
AWSEndpoint = "S3_ENDPOINT" | ||
AWSRegion = "AWS_REGION" | ||
AWSProfile = "AWS_PROFILE" | ||
) | ||
|
||
func AwsDefaultRegion() (region string) { | ||
if region = os.Getenv(AWSRegion); 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 | ||
} |
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 |
---|---|---|
@@ -1,41 +1,25 @@ | ||
// Package env contains environment variables | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
* Copyright (c) 2024-2025, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package env | ||
|
||
// To populate OCI_PRIVATE_KEY with the contents of a PrivateKey .PEM file: | ||
// | ||
// export OCI_PRIVATE_KEY=$(cat ~/.oci/prikey.pem) | ||
|
||
var ( | ||
OCI = struct { | ||
TenancyOCID string | ||
CompartmentOCID string | ||
UserOCID string | ||
Region string | ||
Fingerprint string | ||
PrivateKey string | ||
MaxPageSize string | ||
MaxDownloadSegmentSize string | ||
MultiPartDownloadThreshold string | ||
MultiPartDownloadMaxThreads string | ||
MaxUploadSegmentSize string | ||
MultiPartUploadThreshold string | ||
MultiPartUploadMaxThreads string | ||
}{ | ||
TenancyOCID: "OCI_TENANCY_OCID", | ||
CompartmentOCID: "OCI_COMPARTMENT_OCID", | ||
UserOCID: "OCI_USER_OCID", | ||
Region: "OCI_REGION", | ||
Fingerprint: "OCI_FINGERPRINT", | ||
PrivateKey: "OCI_PRIVATE_KEY", | ||
MaxPageSize: "OCI_MAX_PAGE_SIZE", | ||
MaxDownloadSegmentSize: "OCI_MAX_DOWNLOAD_SEGMENT_SIZE", | ||
MultiPartDownloadThreshold: "OCI_MULTI_PART_DOWNLOAD_THRESHOLD", | ||
MultiPartDownloadMaxThreads: "OCI_MULTI_PART_DOWNLOAD_MAX_THREADS", | ||
MaxUploadSegmentSize: "OCI_MAX_UPLOAD_SEGMENT_SIZE", | ||
MultiPartUploadThreshold: "OCI_MULTI_PART_UPLOAD_THRESHOLD", | ||
MultiPartUploadMaxThreads: "OCI_MULTI_PART_UPLOAD_MAX_THREADS", | ||
} | ||
const ( | ||
OCITenancyOCID = "OCI_TENANCY_OCID" | ||
OCICompartmentOCID = "OCI_COMPARTMENT_OCID" | ||
OCIUserOCID = "OCI_USER_OCID" | ||
OCIRegion = "OCI_REGION" | ||
OCIFingerprint = "OCI_FINGERPRINT" | ||
OCIPrivateKey = "OCI_PRIVATE_KEY" | ||
OCIMaxPageSize = "OCI_MAX_PAGE_SIZE" | ||
OCIMaxDownloadSegmentSize = "OCI_MAX_DOWNLOAD_SEGMENT_SIZE" | ||
OCIMultiPartDownloadThreshold = "OCI_MULTI_PART_DOWNLOAD_THRESHOLD" | ||
OCIMultiPartDownloadMaxThreads = "OCI_MULTI_PART_DOWNLOAD_MAX_THREADS" | ||
OCIMaxUploadSegmentSize = "OCI_MAX_UPLOAD_SEGMENT_SIZE" | ||
OCIMultiPartUploadThreshold = "OCI_MULTI_PART_UPLOAD_THRESHOLD" | ||
OCIMultiPartUploadMaxThreads = "OCI_MULTI_PART_UPLOAD_MAX_THREADS" | ||
) |
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
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