mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 16:54:23 +01:00
config unset; config set tweaks (#188)
This commit is contained in:
parent
4deec984ac
commit
2e635ba37d
@ -58,5 +58,7 @@ func (cmd *configSetCommand) run(_ *cobra.Command, args []string) {
|
|||||||
if zrd.Env != nil && configName == "apiEndpoint" {
|
if zrd.Env != nil && configName == "apiEndpoint" {
|
||||||
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"))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("zrok configuration not changed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
62
cmd/zrok/configUnset.go
Normal file
62
cmd/zrok/configUnset.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/openziti/zrok/tui"
|
||||||
|
"github.com/openziti/zrok/zrokdir"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
configCmd.AddCommand(newConfigUnsetCommand().cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
type configUnsetCommand struct {
|
||||||
|
cmd *cobra.Command
|
||||||
|
}
|
||||||
|
|
||||||
|
func newConfigUnsetCommand() *configUnsetCommand {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "unset <configName>",
|
||||||
|
Short: "Unset a value from the environment config",
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
}
|
||||||
|
command := &configUnsetCommand{cmd: cmd}
|
||||||
|
cmd.Run = command.run
|
||||||
|
return command
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmd *configUnsetCommand) run(_ *cobra.Command, args []string) {
|
||||||
|
configName := args[0]
|
||||||
|
|
||||||
|
zrd, err := zrokdir.Load()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
modified := false
|
||||||
|
switch configName {
|
||||||
|
case "apiEndpoint":
|
||||||
|
if zrd.Cfg != nil && zrd.Cfg.ApiEndpoint != "" {
|
||||||
|
zrd.Cfg.ApiEndpoint = ""
|
||||||
|
modified = true
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
fmt.Printf("unknown config name '%v'\n", configName)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if modified {
|
||||||
|
if err := zrd.Save(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println("zrok configuration updated")
|
||||||
|
if zrd.Env != nil && configName == "apiEndpoint" {
|
||||||
|
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"))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("zrok configuration not changed")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user