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

Fix config option for multiple contexts support #129

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .github/workflows/eden_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@
make build-tests
- name: run
run: |
# check separate (non-default) config
./eden config add setup
./eden config set setup --key=eve.accel --value=false
./eden --config setup setup
./eden --config setup start
./eden --config setup eve onboard
./eden --config setup info
./eden --config setup clean

Check failure on line 50 in .github/workflows/eden_setup.yml

View workflow job for this annotation

GitHub Actions / yetus

blanks:end of line
./eden config add setup --arch=arm64
./eden --config setup setup
./eden --config setup clean
Expand Down
16 changes: 8 additions & 8 deletions cmd/adam.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import (
"github.com/spf13/cobra"
)

func newAdamCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newAdamCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var adamCmd = &cobra.Command{
Use: "adam",
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
{
Message: "Basic Commands",
Commands: []*cobra.Command{
newStartAdamCmd(cfg),
newStopAdamCmd(),
newStatusAdamCmd(),
base.newStartAdamCmd(cfg),
base.newStopAdamCmd(),
base.newStatusAdamCmd(),
},
},
}
Expand All @@ -33,7 +33,7 @@ func newAdamCmd(configName, verbosity *string) *cobra.Command {
return adamCmd
}

func newStartAdamCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
func (base baseCmd) newStartAdamCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
var startAdamCmd = &cobra.Command{
Use: "start",
Short: "start adam",
Expand All @@ -55,7 +55,7 @@ func newStartAdamCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
return startAdamCmd
}

func newStopAdamCmd() *cobra.Command {
func (base baseCmd) newStopAdamCmd() *cobra.Command {
var adamRm bool

var stopAdamCmd = &cobra.Command{
Expand All @@ -74,7 +74,7 @@ func newStopAdamCmd() *cobra.Command {
return stopAdamCmd
}

func newStatusAdamCmd() *cobra.Command {
func (base baseCmd) newStatusAdamCmd() *cobra.Command {
var statusAdamCmd = &cobra.Command{
Use: "status",
Short: "status of adam",
Expand Down
8 changes: 5 additions & 3 deletions cmd/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"github.com/thediveo/enumflag"
)

func newDisksCmd() *cobra.Command {
func (base baseCmd) newDisksCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var disksCmd = &cobra.Command{
Use: "disks",
Short: `Manage disks of edge-node`,
Use: "disks",
Short: `Manage disks of edge-node`,
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
6 changes: 3 additions & 3 deletions cmd/edenClean.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
)

func newCleanCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newCleanCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var configDist, vmName string
var currentContext bool
Expand All @@ -20,9 +20,9 @@ func newCleanCmd(configName, verbosity *string) *cobra.Command {
Use: "clean",
Short: "clean harness",
Long: `Clean harness.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
if err := openevec.EdenClean(*cfg, *configName, configDist, vmName, currentContext); err != nil {
if err := openevec.EdenClean(*cfg, *base.configName, configDist, vmName, currentContext); err != nil {
log.Fatalf("Setup eden failed: %s", err)
}
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/spf13/cobra"
)

func newConfigCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newConfigCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var configCmd = &cobra.Command{
Use: "config",
Short: "work with config",
Long: `Work with config.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenController.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"github.com/spf13/cobra"
)

func newControllerCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newControllerCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var controllerMode string

var controllerCmd = &cobra.Command{
Use: "controller",
Short: "interact with controller",
Long: `Interact with controller.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

var edgeNode = &cobra.Command{
Expand Down
6 changes: 4 additions & 2 deletions cmd/edenNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (
"github.com/thediveo/enumflag"
)

func newNetworkCmd() *cobra.Command {
func (base baseCmd) newNetworkCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var networkCmd = &cobra.Command{
Use: "network",
Use: "network",
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
2 changes: 1 addition & 1 deletion cmd/edenPacket.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra"
)

func newPacketCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newPacketCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var packetProjectName string

Expand Down
4 changes: 2 additions & 2 deletions cmd/edenPod.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"github.com/thediveo/enumflag"
)

func newPodCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newPodCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var podCmd = &cobra.Command{
Use: "pod",
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenRol.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/spf13/cobra"
)

func newRolCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newRolCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var rolCmd = &cobra.Command{
Use: "rol",
Short: `Manage devices in Rack Of Labs`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

rolCmd.AddCommand(newRolRentCmd(cfg))
Expand Down
6 changes: 3 additions & 3 deletions cmd/edenSetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
)

func newSetupCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newSetupCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var configDir, softSerial, zedControlURL, ipxeOverride string
var grubOptions []string
Expand All @@ -21,9 +21,9 @@ func newSetupCmd(configName, verbosity *string) *cobra.Command {
Use: "setup",
Short: "setup harness",
Long: `Setup harness.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
if err := openevec.SetupEden(*configName, configDir, softSerial,
if err := openevec.SetupEden(*base.configName, configDir, softSerial,
zedControlURL, ipxeOverride, grubOptions, netboot, installer, *cfg); err != nil {

log.Fatalf("Setup eden failed: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenStart.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"github.com/spf13/cobra"
)

func newStartCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newStartCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var zedControlURL, vmName, tapInterface string

var startCmd = &cobra.Command{
Use: "start",
Short: "start harness",
Long: `Start harness.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
if err := openevec.StartEden(cfg, vmName, zedControlURL, tapInterface); err != nil {
log.Fatalf("Start eden failed: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenStatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
)

func newStatusCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newStatusCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var allConfigs bool
var vmName string
Expand All @@ -19,7 +19,7 @@ func newStatusCmd(configName, verbosity *string) *cobra.Command {
Use: "status",
Short: "status of harness",
Long: `Status of harness.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
if err := openevec.Status(cfg, vmName, allConfigs); err != nil {
log.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenStop.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
)

func newStopCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newStopCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var vmName string
var adamRm, registryRm, redisRm, eServerRm bool
Expand All @@ -20,7 +20,7 @@ func newStopCmd(configName, verbosity *string) *cobra.Command {
Use: "stop",
Short: "stop harness",
Long: `Stop harness.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
eden.StopEden(
adamRm, redisRm,
Expand Down
6 changes: 3 additions & 3 deletions cmd/edenTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
)

func newTestCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newTestCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var tstCfg openevec.TestArgs

Expand All @@ -27,7 +27,7 @@ test <test_dir> -r <regexp> [-t <timewait>] [-v <level>]

`,
Args: cobra.MaximumNArgs(1),
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
PreRunE: func(cmd *cobra.Command, args []string) error {
var err error
if len(args) != 0 {
Expand Down Expand Up @@ -63,7 +63,7 @@ test <test_dir> -r <regexp> [-t <timewait>] [-v <level>]
return fmt.Errorf("Please set the --scenario option or environment variable eden.test-scenario in the EDEN configuration.")
}
tstCfg.ConfigFile = cfg.ConfigFile
tstCfg.Verbosity = *verbosity
tstCfg.Verbosity = *base.verbosity
return nil
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/edenUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
"github.com/spf13/cobra"
)

func newUtilsCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newUtilsCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}

var utilsCmd = &cobra.Command{
Use: "utils",
Short: "Eden utilities",
Long: `Additional utilities for EDEN.`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
6 changes: 4 additions & 2 deletions cmd/edenVolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import (
"github.com/thediveo/enumflag"
)

func newVolumeCmd() *cobra.Command {
func (base baseCmd) newVolumeCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var volumeCmd = &cobra.Command{
Use: "volume",
Use: "volume",
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
4 changes: 2 additions & 2 deletions cmd/eserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"github.com/spf13/cobra"
)

func newEserverCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newEserverCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var eserverCmd = &cobra.Command{
Use: "eserver",
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}

groups := CommandGroups{
Expand Down
4 changes: 2 additions & 2 deletions cmd/eve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/spf13/cobra"
)

func newEveCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newEveCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var eveCmd = &cobra.Command{
Use: "eve",
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
}
groups := CommandGroups{
{
Expand Down
4 changes: 2 additions & 2 deletions cmd/flowlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/thediveo/enumflag"
)

func newNetStatCmd(configName, verbosity *string) *cobra.Command {
func (base baseCmd) newNetStatCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var outputFormat types.OutputFormat
var follow bool
Expand All @@ -20,7 +20,7 @@ func newNetStatCmd(configName, verbosity *string) *cobra.Command {
Short: "Get logs of network packets from a running EVE device",
Long: `Scans the ADAM flow messages for correspondence with regular expressions to show network flow statistics
(TCP and UDP flows with IP addresses, port numbers, counters, whether dropped or accepted)`,
PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity),
PersistentPreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
if err := openevec.EdenNetStat(cfg, outputFormat, follow, logTail, printFields, args); err != nil {
log.Fatalf("Setup eden failed: %s", err)
Expand Down
10 changes: 6 additions & 4 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import (
"github.com/thediveo/enumflag"
)

func newInfoCmd() *cobra.Command {
func (base baseCmd) newInfoCmd() *cobra.Command {
cfg := &openevec.EdenSetupArgs{}
var outputFormat types.OutputFormat
var infoTail uint
var follow bool
var printFields []string

var infoCmd = &cobra.Command{
Use: "info [field:regexp ...]",
Short: "Get information reports from a running EVE device",
Long: ` Scans the ADAM Info for correspondence with regular expressions requests to json fields.`,
Use: "info [field:regexp ...]",
Short: "Get information reports from a running EVE device",
Long: ` Scans the ADAM Info for correspondence with regular expressions requests to json fields.`,
PreRunE: base.preRunViperLoadFunction(cfg),
Run: func(cmd *cobra.Command, args []string) {
if err := openevec.EdenInfo(outputFormat, infoTail, follow, printFields, args); err != nil {
log.Fatal("Eden info failed ", err)
Expand Down
Loading
Loading