github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/ruler/rulestore/config.go (about)

     1  package rulestore
     2  
     3  import (
     4  	"flag"
     5  	"reflect"
     6  
     7  	"github.com/grafana/dskit/flagext"
     8  
     9  	"github.com/cortexproject/cortex/pkg/configs/client"
    10  	"github.com/cortexproject/cortex/pkg/ruler/rulestore/configdb"
    11  	"github.com/cortexproject/cortex/pkg/ruler/rulestore/local"
    12  	"github.com/cortexproject/cortex/pkg/storage/bucket"
    13  )
    14  
    15  // Config configures a rule store.
    16  type Config struct {
    17  	bucket.Config `yaml:",inline"`
    18  	ConfigDB      client.Config `yaml:"configdb"`
    19  	Local         local.Config  `yaml:"local"`
    20  }
    21  
    22  // RegisterFlags registers the backend storage config.
    23  func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
    24  	prefix := "ruler-storage."
    25  
    26  	cfg.ExtraBackends = []string{configdb.Name, local.Name}
    27  	cfg.ConfigDB.RegisterFlagsWithPrefix(prefix, f)
    28  	cfg.Local.RegisterFlagsWithPrefix(prefix, f)
    29  	cfg.RegisterFlagsWithPrefix(prefix, f)
    30  }
    31  
    32  // IsDefaults returns true if the storage options have not been set.
    33  func (cfg *Config) IsDefaults() bool {
    34  	defaults := Config{}
    35  	flagext.DefaultValues(&defaults)
    36  
    37  	return reflect.DeepEqual(*cfg, defaults)
    38  }