forked from flitnetics/jaeger-objectstorage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
75 lines (63 loc) · 2.78 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package config
import (
lstore "github.com/grafana/loki/pkg/storage"
"github.com/grafana/loki/pkg/storage/stores/shipper/compactor"
"github.com/spf13/viper"
"flag"
"log"
"github.com/cortexproject/cortex/pkg/chunk/aws"
"github.com/cortexproject/cortex/pkg/chunk/azure"
"github.com/cortexproject/cortex/pkg/chunk/gcp"
"github.com/cortexproject/cortex/pkg/chunk/local"
"github.com/cortexproject/cortex/pkg/chunk"
"github.com/grafana/loki/pkg/util/validation"
)
// Configuration describes the options to customize the storage behavior
type Configuration struct {
// TCP host:port or Unix socket depending on Network.
Host string `yaml:"host"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Database string `yaml:"database"`
AWSStorageConfig aws.StorageConfig `yaml:"aws"`
AzureStorageConfig azure.BlobStorageConfig `yaml:"azure"`
GCPStorageConfig gcp.Config `yaml:"bigtable"`
GCSConfig gcp.GCSConfig `yaml:"gcs"`
FSConfig local.FSConfig `yaml:"filesystem"`
StorageConfig string `yaml:"storage_config"`
}
type Config struct {
Target string `yaml:"target,omitempty"`
AuthEnabled bool `yaml:"auth_enabled,omitempty"`
HTTPPrefix string `yaml:"http_prefix"`
StorageConfig lstore.Config `yaml:"storage_config,omitempty"`
ChunkStoreConfig chunk.StoreConfig `yaml:"chunk_store_config,omitempty"`
TableManager chunk.TableManagerConfig `yaml:"table_manager,omitempty"`
SchemaConfig lstore.SchemaConfig `yaml:"schema_config,omitempty"`
LimitsConfig validation.Limits `yaml:"limits_config,omitempty"`
CompactorConfig compactor.Config `yaml:"compactor,omitempty"`
}
func (c *Config) Validate() error {
if err := c.SchemaConfig.Validate(); err != nil {
log.Println("schema: %s", c.SchemaConfig)
log.Println("invalid schema config")
}
if err := c.StorageConfig.Validate(); err != nil {
log.Println("invalid storage config")
}
if err := c.StorageConfig.BoltDBShipperConfig.Validate(); err != nil {
log.Println("invalid boltdb-shipper config")
}
return nil
}
func (c *Config) RegisterFlags(f *flag.FlagSet) {
f.BoolVar(&c.AuthEnabled, "auth.enabled", true, "Set to false to disable auth.")
c.StorageConfig.RegisterFlags(f)
c.ChunkStoreConfig.RegisterFlags(f)
c.SchemaConfig.RegisterFlags(f)
c.TableManager.RegisterFlags(f)
c.LimitsConfig.RegisterFlags(f)
c.CompactorConfig.RegisterFlags(f)
}
// InitFromViper initializes the options struct with values from Viper
func (c *Configuration) InitFromViper(v *viper.Viper) {}