From 06035a03038f81900ce3f1a68b60f9e4c025da50 Mon Sep 17 00:00:00 2001 From: Pavel Abramov <31950564+uncleDecart@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:16:33 +0200 Subject: [PATCH] Remove config check (#908) - Remove DefaultCobraToViper variable - Remove `configCheck` from `EdenSetup` This is prerequisite to use eden as library Signed-off-by: Pavel Abramov --- cmd/edenSetup.go | 3 ++ pkg/defaults/defaults.go | 90 ---------------------------------------- pkg/openevec/config.go | 2 +- pkg/openevec/eden.go | 4 -- 4 files changed, 4 insertions(+), 95 deletions(-) diff --git a/cmd/edenSetup.go b/cmd/edenSetup.go index 7406d2b5d..acb13fb2f 100644 --- a/cmd/edenSetup.go +++ b/cmd/edenSetup.go @@ -23,6 +23,9 @@ func newSetupCmd(configName, verbosity *string) *cobra.Command { Long: `Setup harness.`, PersistentPreRunE: preRunViperLoadFunction(cfg, configName, verbosity), Run: func(cmd *cobra.Command, args []string) { + if err := openevec.ConfigCheck(*configName); err != nil { + log.Fatalf("Config check failed %s", err) + } if err := openEVEC.SetupEden(*configName, configDir, softSerial, zedControlURL, ipxeOverride, grubOptions, netboot, installer); err != nil { log.Fatalf("Setup eden failed: %s", err) diff --git a/pkg/defaults/defaults.go b/pkg/defaults/defaults.go index 8403548da..ba3fba726 100644 --- a/pkg/defaults/defaults.go +++ b/pkg/defaults/defaults.go @@ -205,94 +205,4 @@ const ( var ( //DefaultQemuHostFwd represents port forward for ssh DefaultQemuHostFwd = map[string]string{strconv.Itoa(DefaultSSHPort): "22"} - //DefaultCobraToViper represents mapping values between cobra (cli) and viper (yml) - DefaultCobraToViper = map[string]string{ - "redis.dist": "redis-dist", - "redis.tag": "redis-tag", - "redis.port": "redis-port", - "redis.force": "redis-force", - - "adam.dist": "adam-dist", - "adam.tag": "adam-tag", - "adam.port": "adam-port", - "adam.domain": "domain", - "adam.ip": "ip", - "adam.eve-ip": "eve-ip", - "adam.force": "adam-force", - "adam.v1": "api-v1", - "adam.redis.adam": "adam-redis-url", - "adam.remote.redis": "adam-redis", - - "registry.tag": "registry-tag", - "registry.port": "registry-port", - "registry.dist": "registry-dist", - - "eve.arch": "eve-arch", - "eve.platform": "eve-platform", - "eve.os": "eve-os", - "eve.accel": "eve-accel", - "eve.hv": "eve-hv", - "eve.serial": "eve-serial", - "eve.pid": "eve-pid", - "eve.log": "eve-log", - "eve.firmware": "eve-firmware", - "eve.repo": "eve-repo", - "eve.registry": "eve-registry", - "eve.tag": "eve-tag", - "eve.hostfwd": "eve-hostfwd", - "eve.dist": "eve-dist", - "eve.base-dist": "eve-base-dist", - "eve.qemu-config": "qemu-config", - "eve.uuid": "uuid", - "eve.image-file": "image-file", - "eve.dtb-part": "dtb-part", - "eve.config-part": "config-part", - "eve.base-version": "os-version", - "eve.devmodel": "devmodel", - "eve.devmodelfile": "devmodel-file", - "eve.telnet-port": "eve-telnet-port", - "eve.cpu": "cpus", - "eve.ram": "memory", - "eve.tpm": "tpm", - "eve.disks": "eve-disks", - - "eve.custom-installer.path": "custom-installer-path", - "eve.custom-installer.format": "custom-installer-format", - - "eve.bootstrap-file": "eve-bootstrap-file", - "eve.usbnetconf-file": "eve-usbnetconf-file", - - "eve.qemu.monitor-port": "qemu-monitor-port", - "eve.qemu.netdev-socket-port": "qemu-netdev-socket-port", - - "eden.images.dist": "image-dist", - "eden.images.docker": "docker-yml", - "eden.images.vm": "vm-yml", - "eden.download": "download", - "eden.eserver.ip": "eserver-ip", - "eden.eserver.port": "eserver-port", - "eden.eserver.tag": "eserver-tag", - "eden.eserver.force": "eserver-force", - "eden.certs-dist": "certs-dist", - "eden.bin-dist": "bin-dist", - "eden.ssh-key": "ssh-key", - "eden.test-bin": "prog", - "eden.test-scenario": "scenario", - - "config": "config", - - "sdn.disable": "sdn-disable", - "sdn.source-dir": "sdn-source-dir", - "sdn.config-dir": "sdn-config-dir", - "sdn.image-file": "sdn-image-file", - "sdn.linuxkit-bin": "sdn-linuxkit-bin", - "sdn.cpu": "sdn-cpu", - "sdn.ram": "sdn-ram", - "sdn.pid": "sdn-pid", - "sdn.console-log": "sdn-console-log", - "sdn.telnet-port": "sdn-telnet-port", - "sdn.ssh-port": "sdn-ssh-port", - "sdn.mgmt-port": "sdn-mgmt-port", - "sdn.network-model": "sdn-network-model", - } ) diff --git a/pkg/openevec/config.go b/pkg/openevec/config.go index 39a0b8162..5a8f0194b 100644 --- a/pkg/openevec/config.go +++ b/pkg/openevec/config.go @@ -315,7 +315,7 @@ func resolvePath(v reflect.Value) { } } -func configCheck(configName string) error { +func ConfigCheck(configName string) error { configFile := utils.GetConfig(configName) configSaved := utils.ResolveAbsPath(fmt.Sprintf("%s-%s", configName, defaults.DefaultConfigSaved)) diff --git a/pkg/openevec/eden.go b/pkg/openevec/eden.go index b0bfabad7..0f41b64e4 100644 --- a/pkg/openevec/eden.go +++ b/pkg/openevec/eden.go @@ -53,10 +53,6 @@ func (openEVEC *OpenEVEC) SetupEden(configName, configDir, softSerial, zedContro cfg := *openEVEC.cfg - if err := configCheck(configName); err != nil { - return err - } - if netboot && installer { return fmt.Errorf("please use netboot or installer flag, not both") }