mirror of
https://github.com/openziti/zrok.git
synced 2025-05-31 15:16:41 +02:00
zrok access public validate to validate public frontend configs (#238)
This commit is contained in:
parent
ad09adc941
commit
7d56bcc56c
@ -9,8 +9,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var accessPublicCmd *accessPublicCommand
|
||||
|
||||
func init() {
|
||||
accessCmd.AddCommand(newAccessPublicCommand().cmd)
|
||||
accessPublicCmd = newAccessPublicCommand()
|
||||
accessCmd.AddCommand(accessPublicCmd.cmd)
|
||||
}
|
||||
|
||||
type accessPublicCommand struct {
|
||||
@ -29,7 +32,7 @@ func newAccessPublicCommand() *accessPublicCommand {
|
||||
return command
|
||||
}
|
||||
|
||||
func (self *accessPublicCommand) run(_ *cobra.Command, args []string) {
|
||||
func (cmd *accessPublicCommand) run(_ *cobra.Command, args []string) {
|
||||
cfg := publicFrontend.DefaultConfig()
|
||||
if len(args) == 1 {
|
||||
if err := cfg.Load(args[0]); err != nil {
|
||||
|
37
cmd/zrok/accessPublicValidate.go
Normal file
37
cmd/zrok/accessPublicValidate.go
Normal file
@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/cf"
|
||||
"github.com/openziti/zrok/endpoints/publicFrontend"
|
||||
"github.com/openziti/zrok/tui"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
accessPublicCmd.cmd.AddCommand(newAccessPublicValidateCommand().cmd)
|
||||
}
|
||||
|
||||
type accessPublicValidateCommand struct {
|
||||
cmd *cobra.Command
|
||||
}
|
||||
|
||||
func newAccessPublicValidateCommand() *accessPublicValidateCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "validate <configPath>",
|
||||
Short: "Validate a zrok access public configuration document",
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
command := &accessPublicValidateCommand{cmd: cmd}
|
||||
cmd.Run = command.run
|
||||
return command
|
||||
}
|
||||
|
||||
func (cmd *accessPublicValidateCommand) run(_ *cobra.Command, args []string) {
|
||||
cfg := publicFrontend.DefaultConfig()
|
||||
if err := cfg.Load(args[0]); err != nil {
|
||||
tui.Error(fmt.Sprintf("unable to load configuration '%v'", args[0]), err)
|
||||
}
|
||||
logrus.Infof(cf.Dump(cfg, cf.DefaultOptions()))
|
||||
}
|
@ -19,7 +19,7 @@ type controllerValidateCommand struct {
|
||||
func newControllerValidateCommand() *controllerValidateCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "validate <configPath>",
|
||||
Short: "Validate a zrok controlle configuration document",
|
||||
Short: "Validate a zrok controller configuration document",
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
command := &controllerValidateCommand{cmd: cmd}
|
||||
|
Loading…
x
Reference in New Issue
Block a user