|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + _ "embed" |
| 5 | + |
| 6 | + "gopkg.in/yaml.v3" |
| 7 | +) |
| 8 | + |
| 9 | +type ColumnConfig struct { |
| 10 | + ID string `yaml:"id" json:"id"` |
| 11 | + Name string `yaml:"name" json:"name"` |
| 12 | + |
| 13 | + Group string `yaml:"group,omitempty" json:"group,omitempty"` |
| 14 | + Field string `yaml:"field,omitempty" json:"field,omitempty"` |
| 15 | + Fields []string `yaml:"fields,omitempty" json:"fields,omitempty"` |
| 16 | + Calculated string `yaml:"calculated,omitempty" json:"calculated,omitempty"` |
| 17 | + Tooltip string `yaml:"tooltip,omitempty" json:"tooltip,omitempty"` |
| 18 | + DocURL string `yaml:"docURL,omitempty" json:"docURL,omitempty"` |
| 19 | + Filter string `yaml:"filter,omitempty" json:"filter,omitempty"` |
| 20 | + Default bool `yaml:"default,omitempty" json:"default,omitempty"` |
| 21 | + Width int `yaml:"width,omitempty" json:"width,omitempty"` |
| 22 | + Feature string `yaml:"feature" json:"feature"` |
| 23 | +} |
| 24 | + |
| 25 | +type FilterConfig struct { |
| 26 | + ID string `yaml:"id" json:"id"` |
| 27 | + Name string `yaml:"name" json:"name"` |
| 28 | + Component string `yaml:"component" json:"component"` |
| 29 | + |
| 30 | + Category string `yaml:"category,omitempty" json:"category,omitempty"` |
| 31 | + AutoCompleteAddsQuotes bool `yaml:"autoCompleteAddsQuotes,omitempty" json:"autoCompleteAddsQuotes,omitempty"` |
| 32 | + Hint string `yaml:"hint,omitempty" json:"hint,omitempty"` |
| 33 | + Examples string `yaml:"examples,omitempty" json:"examples,omitempty"` |
| 34 | + DocURL string `yaml:"docUrl,omitempty" json:"docUrl,omitempty"` |
| 35 | + Placeholder string `yaml:"placeholder,omitempty" json:"placeholder,omitempty"` |
| 36 | +} |
| 37 | + |
| 38 | +type FieldConfig struct { |
| 39 | + Name string `yaml:"name" json:"name"` |
| 40 | + Type string `yaml:"type" json:"type"` |
| 41 | + Description string `yaml:"description" json:"description"` |
| 42 | + LokiLabel bool `yaml:"lokiLabel,omitempty" json:"lokiLabel,omitempty"` |
| 43 | + Filter string `yaml:"filter,omitempty" json:"filter,omitempty"` |
| 44 | +} |
| 45 | + |
| 46 | +type Config struct { |
| 47 | + Columns []*ColumnConfig `yaml:"columns" json:"columns"` |
| 48 | + Fields []*FieldConfig `yaml:"fields" json:"fields"` |
| 49 | + Filters []*FilterConfig `yaml:"filters,omitempty" json:"filters,omitempty"` |
| 50 | +} |
| 51 | + |
| 52 | +var ( |
| 53 | + //go:embed config.yaml |
| 54 | + rawConfig []byte |
| 55 | + cfg Config |
| 56 | +) |
| 57 | + |
| 58 | +func LoadConfig() error { |
| 59 | + err := yaml.Unmarshal(rawConfig, &cfg) |
| 60 | + return err |
| 61 | +} |
0 commit comments