Keepers d923c4072b
expose s3 endpoint as flag (#87)
Exposes the s3 endpoint option as a cli flag and storage config
property.  Uses the kopia default s3.amazonaws.com as a fallback.
2022-05-27 09:11:26 -06:00

30 lines
632 B
Go

package kopia
import (
"context"
"github.com/kopia/kopia/repo/blob"
"github.com/kopia/kopia/repo/blob/s3"
"github.com/alcionai/corso/pkg/storage"
)
const (
defaultS3Endpoint = "s3.amazonaws.com" // matches kopia's default value
)
func s3BlobStorage(ctx context.Context, cfg storage.S3Config) (blob.Storage, error) {
endpoint := defaultS3Endpoint
if len(cfg.Endpoint) > 0 {
endpoint = cfg.Endpoint
}
opts := s3.Options{
AccessKeyID: cfg.AccessKey,
BucketName: cfg.Bucket,
Endpoint: endpoint,
SecretAccessKey: cfg.SecretKey,
SessionToken: cfg.SessionToken,
}
return s3.New(ctx, &opts)
}