Skip to content

Commit

Permalink
Add support for AWS shared credentials file
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Jan 15, 2025
1 parent d0ea741 commit 0dbaea5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/etcd/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,16 @@ func (c *Controller) GetClient(ctx context.Context, etcdS3 *config.EtcdS3) (*Cli
tr.Proxy = http.ProxyURL(u)
}

var creds *credentials.Credentials
if len(etcdS3.AccessKey) == 0 && len(etcdS3.SecretKey) == 0 {
creds = credentials.NewIAM("") // for running on ec2 instance
if _, err := creds.Get(); err != nil {
return nil, errors.Wrap(err, "failed to get IAM credentials")
}
} else {
creds = credentials.NewStaticV4(etcdS3.AccessKey, etcdS3.SecretKey, "")
creds := credentials.NewChainCredentials([]credentials.Provider{
credentials.NewStaticV4(etcdS3.AccessKey, etcdS3.SecretKey, ""),

Check failure on line 203 in pkg/etcd/s3/s3.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot use credentials.NewStaticV4(etcdS3.AccessKey, etcdS3.SecretKey, "") (value of type *"github.com/minio/minio-go/v7/pkg/credentials".Credentials) as "github.com/minio/minio-go/v7/pkg/credentials".Provider value in array or slice literal: *"github.com/minio/minio-go/v7/pkg/credentials".Credentials does not implement "github.com/minio/minio-go/v7/pkg/credentials".Provider (missing method Retrieve)
credentials.NewFileAWSCredentials("", ""),

Check failure on line 204 in pkg/etcd/s3/s3.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot use credentials.NewFileAWSCredentials("", "") (value of type *"github.com/minio/minio-go/v7/pkg/credentials".Credentials) as "github.com/minio/minio-go/v7/pkg/credentials".Provider value in array or slice literal: *"github.com/minio/minio-go/v7/pkg/credentials".Credentials does not implement "github.com/minio/minio-go/v7/pkg/credentials".Provider (missing method Retrieve)
credentials.NewIAM(""),

Check failure on line 205 in pkg/etcd/s3/s3.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot use credentials.NewIAM("") (value of type *"github.com/minio/minio-go/v7/pkg/credentials".Credentials) as "github.com/minio/minio-go/v7/pkg/credentials".Provider value in array or slice literal: *"github.com/minio/minio-go/v7/pkg/credentials".Credentials does not implement "github.com/minio/minio-go/v7/pkg/credentials".Provider (missing method Retrieve)
})

if cval, err := creds.Get(); err != nil {
return nil, errors.Wrap(err, "failed to get credentials")
} else if cval.SignerType == credentials.SignatureAnonymous {
return nil, errors.New("all credential providers failed; cannot use anonymous")
}

opt := minio.Options{
Expand Down

0 comments on commit 0dbaea5

Please sign in to comment.