Skip to content

Commit

Permalink
feat: add SEMAPHORE_CACHE_AWS_PROFILE (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspin authored Jul 4, 2022
1 parent 8d88b8a commit afd0537
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cache-cli/pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package storage

import (
"context"
"fmt"
"os"

"github.com/aws/aws-sdk-go-v2/aws"
awsConfig "github.com/aws/aws-sdk-go-v2/config"
Expand Down Expand Up @@ -32,7 +34,17 @@ func NewS3Storage(options S3StorageOptions) (*S3Storage, error) {
}

func createDefaultS3Storage(s3Bucket, project string, storageConfig StorageConfig) (*S3Storage, error) {
config, err := awsConfig.LoadDefaultConfig(context.TODO())
var config aws.Config
var err error

profile := os.Getenv("SEMAPHORE_CACHE_AWS_PROFILE")
if profile == "" {
config, err = awsConfig.LoadDefaultConfig(context.TODO())
} else {
fmt.Printf("Using '%s' AWS profile.\n", profile)
config, err = awsConfig.LoadDefaultConfig(context.TODO(), awsConfig.WithSharedConfigProfile(profile))
}

if err != nil {
return nil, err
}
Expand Down

0 comments on commit afd0537

Please sign in to comment.