mirror of
https://github.com/moby/buildkit.git
synced 2026-06-30 19:57:39 +00:00
Problem: can't use anonymous S3 credentials
When trying to use S3 cache with anonymous credentials (for example, for importing publicly available layers), the cache is not used. Solution: enable anonymous credentials According to the API documentation: "If using the `NewFromConfig` constructor you'll need to explicitly set the `Credentials` member to nil, if the external config resolved a credential provider." Signed-off-by: Yurii Rashkovskii <yrashk@gmail.com>
This commit is contained in:
4
cache/remotecache/s3/s3.go
vendored
4
cache/remotecache/s3/s3.go
vendored
@@ -360,6 +360,10 @@ func newS3Client(ctx context.Context, config Config) (*s3Client, error) {
|
||||
client := s3.NewFromConfig(cfg, func(options *s3.Options) {
|
||||
if config.AccessKeyID != "" && config.SecretAccessKey != "" {
|
||||
options.Credentials = credentials.NewStaticCredentialsProvider(config.AccessKeyID, config.SecretAccessKey, config.SessionToken)
|
||||
} else {
|
||||
// Setting `nil` for anonymous credentials as per
|
||||
// https://pkg.go.dev/github.com/aws/aws-sdk-go-v2@v1.17.6/aws#AnonymousCredentials
|
||||
options.Credentials = nil
|
||||
}
|
||||
if config.EndpointURL != "" {
|
||||
options.UsePathStyle = config.UsePathStyle
|
||||
|
||||
Reference in New Issue
Block a user