Skip to content

Commit

Permalink
NETOBSERV-1580 Reuse frontend config (#105)
Browse files Browse the repository at this point in the history
* add mocks to cli

* reuse frontend config

* fix e2e

* update config and fix col display

* pull main config from operator
  • Loading branch information
jpinsonneau authored Dec 13, 2024
1 parent d4a9f3e commit a3ae803
Show file tree
Hide file tree
Showing 14 changed files with 1,528 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .mk/dev.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ flows-mock: build ## Run flow capture using mocks
.PHONY: packets-mock
packets-mock: build ## Run packet capture using mocks
./build/network-observability-cli get-packets --mock true
tput reset
tput reset
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

0 comments on commit a3ae803

Please sign in to comment.