mirror of
https://github.com/openziti/zrok.git
synced 2025-06-25 04:02:15 +02:00
better 'zrok config unset' supporting defaultFrontend; also properly extensible (#663)
This commit is contained in:
parent
bb8bb0a377
commit
e3dec09284
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openziti/zrok/environment"
|
"github.com/openziti/zrok/environment"
|
||||||
"github.com/openziti/zrok/environment/env_core"
|
|
||||||
"github.com/openziti/zrok/tui"
|
"github.com/openziti/zrok/tui"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"os"
|
"os"
|
||||||
@ -36,18 +35,25 @@ func (cmd *configUnsetCommand) run(_ *cobra.Command, args []string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if env.Config() != nil {
|
||||||
|
cfg := env.Config()
|
||||||
switch configName {
|
switch configName {
|
||||||
case "apiEndpoint":
|
case "apiEndpoint":
|
||||||
if err := env.SetConfig(&env_core.Config{}); err != nil {
|
cfg.ApiEndpoint = ""
|
||||||
tui.Error("unable to save config", err)
|
|
||||||
}
|
|
||||||
fmt.Println("zrok configuration updated")
|
|
||||||
if env.IsEnabled() {
|
if env.IsEnabled() {
|
||||||
fmt.Printf("\n[%v]: because you have a %v-d environment, you won't see your config change until you run %v first!\n\n", tui.WarningLabel, tui.Code.Render("zrok enable"), tui.Code.Render("zrok disable"))
|
fmt.Printf("\n[%v]: because you have a %v-d environment, you won't see your config change until you run %v first!\n\n", tui.WarningLabel, tui.Code.Render("zrok enable"), tui.Code.Render("zrok disable"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "defaultFrontend":
|
||||||
|
cfg.DefaultFrontend = ""
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Printf("unknown config name '%v'\n", configName)
|
fmt.Printf("unknown config name '%v'\n", configName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
if err := env.SetConfig(cfg); err != nil {
|
||||||
|
tui.Error("unable to save config", err)
|
||||||
|
}
|
||||||
|
fmt.Println("zrok configuration updated")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user