github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/storage/bucket/swift/config.go (about)

     1  package swift
     2  
     3  import (
     4  	"flag"
     5  	"time"
     6  )
     7  
     8  // Config holds the config options for Swift backend
     9  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"`
    28  }
    29  
    30  // RegisterFlags registers the flags for Swift storage
    31  func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
    32  	cfg.RegisterFlagsWithPrefix("", f)
    33  }
    34  
    35  // RegisterFlagsWithPrefix registers the flags for Swift storage with the provided prefix
    36  func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
    37  	f.IntVar(&cfg.AuthVersion, prefix+"swift.auth-version", 0, "OpenStack Swift authentication API version. 0 to autodetect.")
    38  	f.StringVar(&cfg.AuthURL, prefix+"swift.auth-url", "", "OpenStack Swift authentication URL")
    39  	f.StringVar(&cfg.Username, prefix+"swift.username", "", "OpenStack Swift username.")
    40  	f.StringVar(&cfg.UserDomainName, prefix+"swift.user-domain-name", "", "OpenStack Swift user's domain name.")
    41  	f.StringVar(&cfg.UserDomainID, prefix+"swift.user-domain-id", "", "OpenStack Swift user's domain ID.")
    42  	f.StringVar(&cfg.UserID, prefix+"swift.user-id", "", "OpenStack Swift user ID.")
    43  	f.StringVar(&cfg.Password, prefix+"swift.password", "", "OpenStack Swift API key.")
    44  	f.StringVar(&cfg.DomainID, prefix+"swift.domain-id", "", "OpenStack Swift user's domain ID.")
    45  	f.StringVar(&cfg.DomainName, prefix+"swift.domain-name", "", "OpenStack Swift user's domain name.")
    46  	f.StringVar(&cfg.ProjectID, prefix+"swift.project-id", "", "OpenStack Swift project ID (v2,v3 auth only).")
    47  	f.StringVar(&cfg.ProjectName, prefix+"swift.project-name", "", "OpenStack Swift project name (v2,v3 auth only).")
    48  	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.")
    49  	f.StringVar(&cfg.ProjectDomainName, prefix+"swift.project-domain-name", "", "Name of the OpenStack Swift project's domain (v3 auth only), only needed if it differs from the user domain.")
    50  	f.StringVar(&cfg.RegionName, prefix+"swift.region-name", "", "OpenStack Swift Region to use (v2,v3 auth only).")
    51  	f.StringVar(&cfg.ContainerName, prefix+"swift.container-name", "", "Name of the OpenStack Swift container to put chunks in.")
    52  	f.IntVar(&cfg.MaxRetries, prefix+"swift.max-retries", 3, "Max retries on requests error.")
    53  	f.DurationVar(&cfg.ConnectTimeout, prefix+"swift.connect-timeout", 10*time.Second, "Time after which a connection attempt is aborted.")
    54  	f.DurationVar(&cfg.RequestTimeout, prefix+"swift.request-timeout", 5*time.Second, "Time after which an idle request is aborted. The timeout watchdog is reset each time some data is received, so the timeout triggers after X time no data is received on a request.")
    55  }