Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-1580 Reuse frontend config #105

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reuse frontend config
  • Loading branch information
jpinsonneau committed Dec 13, 2024
commit 3448ecf09de709c26f0cb84e091c58d9dd7366c2
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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