Skip to content

Commit e8f58ec

Browse files
committed
Add missing application credential fields to swift bucket config; use flagext.Secret for secret fields
1 parent 18e6e4d commit e8f58ec

File tree

2 files changed

+48
-37
lines changed

2 files changed

+48
-37
lines changed

pkg/storage/bucket/swift/bucket_client.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@ import (
1111
// NewBucketClient creates a new Swift bucket client
1212
func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) {
1313
bucketConfig := swift.Config{
14-
AuthVersion: cfg.AuthVersion,
15-
AuthUrl: cfg.AuthURL,
16-
Username: cfg.Username,
17-
UserDomainName: cfg.UserDomainName,
18-
UserDomainID: cfg.UserDomainID,
19-
UserId: cfg.UserID,
20-
Password: cfg.Password,
21-
DomainId: cfg.DomainID,
22-
DomainName: cfg.DomainName,
23-
ProjectID: cfg.ProjectID,
24-
ProjectName: cfg.ProjectName,
25-
ProjectDomainID: cfg.ProjectDomainID,
26-
ProjectDomainName: cfg.ProjectDomainName,
27-
RegionName: cfg.RegionName,
28-
ContainerName: cfg.ContainerName,
29-
Retries: cfg.MaxRetries,
30-
ConnectTimeout: model.Duration(cfg.ConnectTimeout),
31-
Timeout: model.Duration(cfg.RequestTimeout),
14+
AuthVersion: cfg.AuthVersion,
15+
AuthUrl: cfg.AuthURL,
16+
Username: cfg.Username,
17+
UserDomainName: cfg.UserDomainName,
18+
UserDomainID: cfg.UserDomainID,
19+
UserId: cfg.UserID,
20+
Password: cfg.Password.Value,
21+
DomainId: cfg.DomainID,
22+
DomainName: cfg.DomainName,
23+
ApplicationCredentialID: cfg.ApplicationCredentialID,
24+
ApplicationCredentialName: cfg.ApplicationCredentialName,
25+
ApplicationCredentialSecret: cfg.ApplicationCredentialSecret.Value,
26+
ProjectID: cfg.ProjectID,
27+
ProjectName: cfg.ProjectName,
28+
ProjectDomainID: cfg.ProjectDomainID,
29+
ProjectDomainName: cfg.ProjectDomainName,
30+
RegionName: cfg.RegionName,
31+
ContainerName: cfg.ContainerName,
32+
Retries: cfg.MaxRetries,
33+
ConnectTimeout: model.Duration(cfg.ConnectTimeout),
34+
Timeout: model.Duration(cfg.RequestTimeout),
3235

3336
// Hard-coded defaults.
3437
ChunkSize: swift.DefaultConfig.ChunkSize,

pkg/storage/bucket/swift/config.go

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@ package swift
33
import (
44
"flag"
55
"time"
6+
7+
"github.com/cortexproject/cortex/pkg/util/flagext"
68
)
79

810
// Config holds the config options for Swift backend
911
type Config struct {
10-
AuthVersion int `yaml:"auth_version"`
11-
AuthURL string `yaml:"auth_url"`
12-
Username string `yaml:"username"`
13-
UserDomainName string `yaml:"user_domain_name"`
14-
UserDomainID string `yaml:"user_domain_id"`
15-
UserID string `yaml:"user_id"`
16-
Password string `yaml:"password"`
17-
DomainID string `yaml:"domain_id"`
18-
DomainName string `yaml:"domain_name"`
19-
ProjectID string `yaml:"project_id"`
20-
ProjectName string `yaml:"project_name"`
21-
ProjectDomainID string `yaml:"project_domain_id"`
22-
ProjectDomainName string `yaml:"project_domain_name"`
23-
RegionName string `yaml:"region_name"`
24-
ContainerName string `yaml:"container_name"`
25-
MaxRetries int `yaml:"max_retries"`
26-
ConnectTimeout time.Duration `yaml:"connect_timeout"`
27-
RequestTimeout time.Duration `yaml:"request_timeout"`
12+
AuthVersion int `yaml:"auth_version"`
13+
AuthURL string `yaml:"auth_url"`
14+
Username string `yaml:"username"`
15+
UserDomainName string `yaml:"user_domain_name"`
16+
UserDomainID string `yaml:"user_domain_id"`
17+
UserID string `yaml:"user_id"`
18+
Password flagext.Secret `yaml:"password"`
19+
DomainID string `yaml:"domain_id"`
20+
DomainName string `yaml:"domain_name"`
21+
ApplicationCredentialID string `yaml:"application_credential_id"`
22+
ApplicationCredentialName string `yaml:"application_credential_name"`
23+
ApplicationCredentialSecret flagext.Secret `yaml:"application_credential_secret"`
24+
ProjectID string `yaml:"project_id"`
25+
ProjectName string `yaml:"project_name"`
26+
ProjectDomainID string `yaml:"project_domain_id"`
27+
ProjectDomainName string `yaml:"project_domain_name"`
28+
RegionName string `yaml:"region_name"`
29+
ContainerName string `yaml:"container_name"`
30+
MaxRetries int `yaml:"max_retries"`
31+
ConnectTimeout time.Duration `yaml:"connect_timeout"`
32+
RequestTimeout time.Duration `yaml:"request_timeout"`
2833
}
2934

3035
// RegisterFlags registers the flags for Swift storage
@@ -40,9 +45,12 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
4045
f.StringVar(&cfg.UserDomainName, prefix+"swift.user-domain-name", "", "OpenStack Swift user's domain name.")
4146
f.StringVar(&cfg.UserDomainID, prefix+"swift.user-domain-id", "", "OpenStack Swift user's domain ID.")
4247
f.StringVar(&cfg.UserID, prefix+"swift.user-id", "", "OpenStack Swift user ID.")
43-
f.StringVar(&cfg.Password, prefix+"swift.password", "", "OpenStack Swift API key.")
48+
f.Var(&cfg.Password, prefix+"swift.password", "OpenStack Swift API key.")
4449
f.StringVar(&cfg.DomainID, prefix+"swift.domain-id", "", "OpenStack Swift user's domain ID.")
4550
f.StringVar(&cfg.DomainName, prefix+"swift.domain-name", "", "OpenStack Swift user's domain name.")
51+
f.StringVar(&cfg.ApplicationCredentialID, prefix+"swift.application-credential-id", "", "OpenStack Swift application credential ID.")
52+
f.StringVar(&cfg.ApplicationCredentialName, prefix+"swift.application-credential-name", "", "OpenStack Swift application credential name.")
53+
f.Var(&cfg.ApplicationCredentialSecret, prefix+"swift.application-credential-secret", "OpenStack Swift application credential secret.")
4654
f.StringVar(&cfg.ProjectID, prefix+"swift.project-id", "", "OpenStack Swift project ID (v2,v3 auth only).")
4755
f.StringVar(&cfg.ProjectName, prefix+"swift.project-name", "", "OpenStack Swift project name (v2,v3 auth only).")
4856
f.StringVar(&cfg.ProjectDomainID, prefix+"swift.project-domain-id", "", "ID of the OpenStack Swift project's domain (v3 auth only), only needed if it differs the from user domain.")

0 commit comments

Comments
 (0)