mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
s3 cache client-side support
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
47
vendor/github.com/aws/aws-sdk-go-v2/config/defaultsmode.go
generated
vendored
Normal file
47
vendor/github.com/aws/aws-sdk-go-v2/config/defaultsmode.go
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
|
||||
)
|
||||
|
||||
const execEnvVar = "AWS_EXECUTION_ENV"
|
||||
|
||||
// DefaultsModeOptions is the set of options that are used to configure
|
||||
type DefaultsModeOptions struct {
|
||||
// The SDK configuration defaults mode. Defaults to legacy if not specified.
|
||||
//
|
||||
// Supported modes are: auto, cross-region, in-region, legacy, mobile, standard
|
||||
Mode aws.DefaultsMode
|
||||
|
||||
// The EC2 Instance Metadata Client that should be used when performing environment
|
||||
// discovery when aws.DefaultsModeAuto is set.
|
||||
//
|
||||
// If not specified the SDK will construct a client if the instance metadata service has not been disabled by
|
||||
// the AWS_EC2_METADATA_DISABLED environment variable.
|
||||
IMDSClient *imds.Client
|
||||
}
|
||||
|
||||
func resolveDefaultsModeRuntimeEnvironment(ctx context.Context, envConfig *EnvConfig, client *imds.Client) (aws.RuntimeEnvironment, error) {
|
||||
getRegionOutput, err := client.GetRegion(ctx, &imds.GetRegionInput{})
|
||||
// honor context timeouts, but if we couldn't talk to IMDS don't fail runtime environment introspection.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return aws.RuntimeEnvironment{}, err
|
||||
default:
|
||||
}
|
||||
|
||||
var imdsRegion string
|
||||
if err == nil {
|
||||
imdsRegion = getRegionOutput.Region
|
||||
}
|
||||
|
||||
return aws.RuntimeEnvironment{
|
||||
EnvironmentIdentifier: aws.ExecutionEnvironmentID(os.Getenv(execEnvVar)),
|
||||
Region: envConfig.Region,
|
||||
EC2InstanceMetadataRegion: imdsRegion,
|
||||
}, nil
|
||||
}
|
Reference in New Issue
Block a user