Skip to content

Commit

Permalink
reuse frontend config
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Oct 17, 2024
1 parent 3663f3f commit f23b184
Show file tree
Hide file tree
Showing 12 changed files with 1,474 additions and 262 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ install-commands: commands ## Generate plugins and add them to /usr/bin/
docs: oc-commands ## Generate asciidoc
./scripts/generate-doc.sh

.PHONY: update-config
update-config: ## Update config from operator repo
./scripts/update-config.sh

.PHONY: release
release: clean ## Generate tar.gz containing krew plugin and display krew updated index
$(MAKE) KREW_PLUGIN=true kubectl-commands
Expand Down
61 changes: 61 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cmd

import (
_ "embed"

"gopkg.in/yaml.v3"
)

type ColumnConfig struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`

Group string `yaml:"group,omitempty" json:"group,omitempty"`
Field string `yaml:"field,omitempty" json:"field,omitempty"`
Fields []string `yaml:"fields,omitempty" json:"fields,omitempty"`
Calculated string `yaml:"calculated,omitempty" json:"calculated,omitempty"`
Tooltip string `yaml:"tooltip,omitempty" json:"tooltip,omitempty"`
DocURL string `yaml:"docURL,omitempty" json:"docURL,omitempty"`
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
Default bool `yaml:"default,omitempty" json:"default,omitempty"`
Width int `yaml:"width,omitempty" json:"width,omitempty"`
Feature string `yaml:"feature" json:"feature"`
}

type FilterConfig struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
Component string `yaml:"component" json:"component"`

Category string `yaml:"category,omitempty" json:"category,omitempty"`
AutoCompleteAddsQuotes bool `yaml:"autoCompleteAddsQuotes,omitempty" json:"autoCompleteAddsQuotes,omitempty"`
Hint string `yaml:"hint,omitempty" json:"hint,omitempty"`
Examples string `yaml:"examples,omitempty" json:"examples,omitempty"`
DocURL string `yaml:"docUrl,omitempty" json:"docUrl,omitempty"`
Placeholder string `yaml:"placeholder,omitempty" json:"placeholder,omitempty"`
}

type FieldConfig struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"`
Description string `yaml:"description" json:"description"`
LokiLabel bool `yaml:"lokiLabel,omitempty" json:"lokiLabel,omitempty"`
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
}

type Config struct {
Columns []*ColumnConfig `yaml:"columns" json:"columns"`
Fields []*FieldConfig `yaml:"fields" json:"fields"`
Filters []*FilterConfig `yaml:"filters,omitempty" json:"filters,omitempty"`
}

var (
//go:embed config.yaml
rawConfig []byte
cfg Config
)

func LoadConfig() error {
err := yaml.Unmarshal(rawConfig, &cfg)
return err
}
Loading

0 comments on commit f23b184

Please sign in to comment.