mirror of
https://github.com/openziti/zrok.git
synced 2025-06-21 02:07:44 +02:00
basic controller configuration validation (#238)
This commit is contained in:
parent
14e0e39b85
commit
ad09adc941
@ -7,8 +7,11 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var controllerCmd *controllerCommand
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(newControllerCommand().cmd)
|
controllerCmd = newControllerCommand()
|
||||||
|
rootCmd.AddCommand(controllerCmd.cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
type controllerCommand struct {
|
type controllerCommand struct {
|
||||||
|
36
cmd/zrok/controllerValidate.go
Normal file
36
cmd/zrok/controllerValidate.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/michaelquigley/cf"
|
||||||
|
"github.com/openziti/zrok/controller"
|
||||||
|
"github.com/openziti/zrok/tui"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
controllerCmd.cmd.AddCommand(newControllerValidateCommand().cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
type controllerValidateCommand struct {
|
||||||
|
cmd *cobra.Command
|
||||||
|
}
|
||||||
|
|
||||||
|
func newControllerValidateCommand() *controllerValidateCommand {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "validate <configPath>",
|
||||||
|
Short: "Validate a zrok controlle configuration document",
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
}
|
||||||
|
command := &controllerValidateCommand{cmd: cmd}
|
||||||
|
cmd.Run = command.run
|
||||||
|
return command
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmd *controllerValidateCommand) run(_ *cobra.Command, args []string) {
|
||||||
|
cfg, err := controller.LoadConfig(args[0])
|
||||||
|
if err != nil {
|
||||||
|
tui.Error("controller config validation failed", err)
|
||||||
|
}
|
||||||
|
logrus.Infof(cf.Dump(cfg, cf.DefaultOptions()))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user