mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 19:38:57 +00:00
iam instance profile
This commit is contained in:
parent
637de0149c
commit
3b2648bd5e
@ -14,6 +14,7 @@ import (
|
|||||||
"restic/errors"
|
"restic/errors"
|
||||||
|
|
||||||
"github.com/minio/minio-go"
|
"github.com/minio/minio-go"
|
||||||
|
"github.com/minio/minio-go/pkg/credentials"
|
||||||
|
|
||||||
"restic/debug"
|
"restic/debug"
|
||||||
)
|
)
|
||||||
@ -38,9 +39,24 @@ func open(cfg Config) (*Backend, error) {
|
|||||||
minio.MaxRetry = int(cfg.MaxRetries)
|
minio.MaxRetry = int(cfg.MaxRetries)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := minio.New(cfg.Endpoint, cfg.KeyID, cfg.Secret, !cfg.UseHTTP)
|
var client *minio.Client
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, errors.Wrap(err, "minio.New")
|
|
||||||
|
if cfg.KeyID == "" || cfg.Secret == "" {
|
||||||
|
debug.Log("iam")
|
||||||
|
creds := credentials.NewIAM("")
|
||||||
|
client, err = minio.NewWithCredentials(cfg.Endpoint, creds, !cfg.UseHTTP, "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "minio.NewWithCredentials")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug.Log("key, secret")
|
||||||
|
client, err = minio.New(cfg.Endpoint, cfg.KeyID, cfg.Secret, !cfg.UseHTTP)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "minio.New")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sem, err := backend.NewSemaphore(cfg.Connections)
|
sem, err := backend.NewSemaphore(cfg.Connections)
|
||||||
|
Loading…
Reference in New Issue
Block a user