From 23ab36d37643dfa87f2c73b48edef14d9a1930b1 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 16 Feb 2023 13:00:33 -0500 Subject: [PATCH 1/6] zrok status --secrets (#243) --- cmd/zrok/status.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cmd/zrok/status.go b/cmd/zrok/status.go index 76f43fb6..3cdccb8b 100644 --- a/cmd/zrok/status.go +++ b/cmd/zrok/status.go @@ -14,7 +14,8 @@ func init() { } type statusCommand struct { - cmd *cobra.Command + secrets bool + cmd *cobra.Command } func newStatusCommand() *statusCommand { @@ -25,6 +26,7 @@ func newStatusCommand() *statusCommand { Args: cobra.ExactArgs(0), } command := &statusCommand{cmd: cmd} + cmd.Flags().BoolVar(&command.secrets, "secrets", false, "Show secrets in status output") cmd.Run = command.run return command } @@ -57,8 +59,22 @@ func (cmd *statusCommand) run(_ *cobra.Command, _ []string) { t.SetOutputMirror(os.Stdout) t.SetStyle(table.StyleColoredDark) t.AppendHeader(table.Row{"Property", "Value"}) - t.AppendRow(table.Row{"Secret Token", zrd.Env.Token}) - t.AppendRow(table.Row{"Ziti Identity", zrd.Env.ZId}) + if cmd.secrets { + t.AppendRow(table.Row{"Secret Token", zrd.Env.Token}) + t.AppendRow(table.Row{"Ziti Identity", zrd.Env.ZId}) + } else { + secretToken := "<>" + if zrd.Env.Token == "" { + secretToken = "<>" + } + t.AppendRow(table.Row{"Secret Token", secretToken}) + + zId := "<>" + if zrd.Env.ZId == "" { + zId = "<>" + } + t.AppendRow(table.Row{"Ziti Identity", zId}) + } t.Render() } _, _ = fmt.Fprintf(os.Stdout, "\n") From a8052ed4182cf9cd08ee3e17ead08d6805b0f094 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 16 Feb 2023 13:02:25 -0500 Subject: [PATCH 2/6] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed404a70..3ff2ceab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.3.2 + +CHANGE: `zrok status` no longer shows secrets (secret token, ziti identity) unless the `--secrets` flag is passed (https://github.com/openziti/zrok/issues/243) + # v0.3.1 CHANGE: Incorporate initial docker image build (https://github.com/openziti/zrok/issues/217) From 388d5168ebea165e0f4ec75e0c5ff2923e859e37 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 16 Feb 2023 13:39:21 -0500 Subject: [PATCH 3/6] changelog lint --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed404a70..76cb174e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,7 +74,7 @@ FIX: Fixed PostgreSQL migration issue where sequences got reset and resulted in FIX: Remove `frontend` instances when `zrok disable`-ing an environment containing them (https://github.com/openziti/zrok/issues/171) -# v0.3.0 +# v0.3.x Series The `v0.2` series was a _proof-of-concept_ implementation for the overall `zrok` architecture and the concept. From ad09adc9412ac9ca4defb68f09e2d357c3883bdd Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 16 Feb 2023 13:51:47 -0500 Subject: [PATCH 4/6] basic controller configuration validation (#238) --- cmd/zrok/controller.go | 5 ++++- cmd/zrok/controllerValidate.go | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 cmd/zrok/controllerValidate.go diff --git a/cmd/zrok/controller.go b/cmd/zrok/controller.go index cf62688d..6e498797 100644 --- a/cmd/zrok/controller.go +++ b/cmd/zrok/controller.go @@ -7,8 +7,11 @@ import ( "github.com/spf13/cobra" ) +var controllerCmd *controllerCommand + func init() { - rootCmd.AddCommand(newControllerCommand().cmd) + controllerCmd = newControllerCommand() + rootCmd.AddCommand(controllerCmd.cmd) } type controllerCommand struct { diff --git a/cmd/zrok/controllerValidate.go b/cmd/zrok/controllerValidate.go new file mode 100644 index 00000000..ad115235 --- /dev/null +++ b/cmd/zrok/controllerValidate.go @@ -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 ", + 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())) +} From 7d56bcc56c8840d044612b321525798bff2bd63d Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 16 Feb 2023 14:11:18 -0500 Subject: [PATCH 5/6] zrok access public validate to validate public frontend configs (#238) --- cmd/zrok/accessPublic.go | 7 ++++-- cmd/zrok/accessPublicValidate.go | 37 ++++++++++++++++++++++++++++++++ cmd/zrok/controllerValidate.go | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 cmd/zrok/accessPublicValidate.go diff --git a/cmd/zrok/accessPublic.go b/cmd/zrok/accessPublic.go index f3353929..a05743f6 100644 --- a/cmd/zrok/accessPublic.go +++ b/cmd/zrok/accessPublic.go @@ -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 { diff --git a/cmd/zrok/accessPublicValidate.go b/cmd/zrok/accessPublicValidate.go new file mode 100644 index 00000000..a7de00d5 --- /dev/null +++ b/cmd/zrok/accessPublicValidate.go @@ -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 ", + 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())) +} diff --git a/cmd/zrok/controllerValidate.go b/cmd/zrok/controllerValidate.go index ad115235..a09d106f 100644 --- a/cmd/zrok/controllerValidate.go +++ b/cmd/zrok/controllerValidate.go @@ -19,7 +19,7 @@ type controllerValidateCommand struct { func newControllerValidateCommand() *controllerValidateCommand { cmd := &cobra.Command{ Use: "validate ", - Short: "Validate a zrok controlle configuration document", + Short: "Validate a zrok controller configuration document", Args: cobra.ExactArgs(1), } command := &controllerValidateCommand{cmd: cmd} From 5dedc90603fcad966030cae62a9d9f78f0e825f7 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 16 Feb 2023 14:13:40 -0500 Subject: [PATCH 6/6] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8f9cb4d..a78a0f80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # v0.3.2 +FEATURE: `zrok controller validate` and `zrok access public validate` will both perform a quick syntax validation on controller and public frontend configuration documents (https://github.com/openziti/zrok/issues/238) + + $ zrok controller validate etc/dev.yml + [ERROR]: controller config validation failed (error loading controller config 'etc/dev.yml': field 'maintenance': field 'registration': field 'expiration_timeout': got [bool], expected [time.Duration]) + CHANGE: `zrok status` no longer shows secrets (secret token, ziti identity) unless the `--secrets` flag is passed (https://github.com/openziti/zrok/issues/243) # v0.3.1