mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
tui; warning
This commit is contained in:
parent
03172244cc
commit
38318c68e2
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -43,24 +44,24 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
endpointUrl, err := url.Parse("http://" + cmd.bindAddress)
|
endpointUrl, err := url.Parse("http://" + cmd.bindAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("invalid endpoint address", err)
|
tui.Error("invalid endpoint address", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
showError("unable to load zrokdir", err)
|
tui.Error("unable to load zrokdir", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create zrok client", err)
|
tui.Error("unable to create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
accessResp, err := zrok.Share.Access(req, auth)
|
accessResp, err := zrok.Share.Access(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to access", err)
|
tui.Error("unable to access", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -95,7 +96,7 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
frontend, err := privateFrontend.NewHTTP(cfg)
|
frontend, err := privateFrontend.NewHTTP(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create private frontend", err)
|
tui.Error("unable to create private frontend", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -104,7 +105,7 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
|
|
||||||
if err := frontend.Run(); err != nil {
|
if err := frontend.Run(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to run frontend", err)
|
tui.Error("unable to run frontend", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/michaelquigley/cf"
|
"github.com/michaelquigley/cf"
|
||||||
"github.com/openziti-test-kitchen/zrok/endpoints/publicFrontend"
|
"github.com/openziti-test-kitchen/zrok/endpoints/publicFrontend"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -33,7 +34,7 @@ func (self *accessPublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
if err := cfg.Load(args[0]); err != nil {
|
if err := cfg.Load(args[0]); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError(fmt.Sprintf("unable to load configuration '%v'", args[0]), err)
|
tui.Error(fmt.Sprintf("unable to load configuration '%v'", args[0]), err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -42,13 +43,13 @@ func (self *accessPublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
frontend, err := publicFrontend.NewHTTP(cfg)
|
frontend, err := publicFrontend.NewHTTP(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create http frontend", err)
|
tui.Error("unable to create http frontend", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := frontend.Run(); err != nil {
|
if err := frontend.Run(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to run http frontend", err)
|
tui.Error("unable to run http frontend", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
httptransport "github.com/go-openapi/runtime/client"
|
httptransport "github.com/go-openapi/runtime/client"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/environment"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/environment"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -33,19 +34,19 @@ func (cmd *disableCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load zrokdir", err)
|
tui.Error("unable to load zrokdir", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("no environment found; nothing to disable!", nil)
|
tui.Error("no environment found; nothing to disable!", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("could not create zrok client", err)
|
tui.Error("could not create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -60,13 +61,13 @@ func (cmd *disableCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
}
|
}
|
||||||
if err := zrokdir.DeleteEnvironment(); err != nil {
|
if err := zrokdir.DeleteEnvironment(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error removing zrok environment", err)
|
tui.Error("error removing zrok environment", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := zrokdir.DeleteZitiIdentity("backend"); err != nil {
|
if err := zrokdir.DeleteZitiIdentity("backend"); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error removing zrok backend identity", err)
|
tui.Error("error removing zrok backend identity", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("zrok environment '%v' disabled for '%v'\n", zrd.Env.ZId, zrd.Env.Token)
|
fmt.Printf("zrok environment '%v' disabled for '%v'\n", zrd.Env.ZId, zrd.Env.Token)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
httptransport "github.com/go-openapi/runtime/client"
|
httptransport "github.com/go-openapi/runtime/client"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/environment"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/environment"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/shirou/gopsutil/v3/host"
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -65,7 +66,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
resp, err := zrok.Environment.Enable(req, auth)
|
resp, err := zrok.Environment.Enable(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("the zrok service returned an error", err)
|
tui.Error("the zrok service returned an error", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -73,13 +74,13 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}
|
zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}
|
||||||
if err := zrd.Save(); err != nil {
|
if err := zrd.Save(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("there was an error saving the new environment", err)
|
tui.Error("there was an error saving the new environment", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
|
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("there was an error writing the environment file", err)
|
tui.Error("there was an error writing the environment file", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/account"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/account"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/util"
|
"github.com/openziti-test-kitchen/zrok/util"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/openziti/foundation/v2/term"
|
"github.com/openziti/foundation/v2/term"
|
||||||
@ -35,25 +36,25 @@ func (cmd *inviteCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if !util.IsValidEmail(email) {
|
if !util.IsValidEmail(email) {
|
||||||
showError(fmt.Sprintf("'%v' is not a valid email address", email), nil)
|
tui.Error(fmt.Sprintf("'%v' is not a valid email address", email), nil)
|
||||||
}
|
}
|
||||||
confirm, err := term.Prompt("Confirm Email: ")
|
confirm, err := term.Prompt("Confirm Email: ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if confirm != email {
|
if confirm != email {
|
||||||
showError("entered emails do not match... aborting!", nil)
|
tui.Error("entered emails do not match... aborting!", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
showError("error loading zrokdir", err)
|
tui.Error("error loading zrokdir", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error creating zrok api client", err)
|
tui.Error("error creating zrok api client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -64,7 +65,7 @@ func (cmd *inviteCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
_, err = zrok.Account.Invite(req)
|
_, err = zrok.Account.Invite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error creating invitation", err)
|
tui.Error("error creating invitation", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/util"
|
"github.com/openziti-test-kitchen/zrok/util"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/openziti/sdk-golang/ziti"
|
"github.com/openziti/sdk-golang/ziti"
|
||||||
@ -176,7 +177,7 @@ func (l *looper) startup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
l.env = zrd.Env
|
l.env = zrd.Env
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
httptransport "github.com/go-openapi/runtime/client"
|
httptransport "github.com/go-openapi/runtime/client"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -33,19 +34,19 @@ func (cmd *releaseCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load zrokdir", err)
|
tui.Error("unable to load zrokdir", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create zrok client", err)
|
tui.Error("unable to create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ func (cmd *releaseCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
if _, err := zrok.Share.Unshare(req, auth); err != nil {
|
if _, err := zrok.Share.Unshare(req, auth); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error releasing share", err)
|
tui.Error("error releasing share", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/openziti-test-kitchen/zrok/model"
|
"github.com/openziti-test-kitchen/zrok/model"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -39,13 +40,13 @@ func newReserveCommand() *reserveCommand {
|
|||||||
func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
||||||
shareMode := args[0]
|
shareMode := args[0]
|
||||||
if shareMode != "public" && shareMode != "private" {
|
if shareMode != "public" && shareMode != "private" {
|
||||||
showError("invalid sharing mode; expecting 'public' or 'private'", nil)
|
tui.Error("invalid sharing mode; expecting 'public' or 'private'", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
targetEndpoint, err := url.Parse(args[1])
|
targetEndpoint, err := url.Parse(args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("invalid target endpoint URL", err)
|
tui.Error("invalid target endpoint URL", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -56,19 +57,19 @@ func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error loading zrokdir", err)
|
tui.Error("error loading zrokdir", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create zrok client", err)
|
tui.Error("unable to create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@ func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
|||||||
resp, err := zrok.Share.Share(req, auth)
|
resp, err := zrok.Share.Share(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create tunnel", err)
|
tui.Error("unable to create tunnel", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -53,7 +54,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
targetEndpoint, err := url.Parse(args[0])
|
targetEndpoint, err := url.Parse(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("invalid target endpoint URL", err)
|
tui.Error("invalid target endpoint URL", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -66,25 +67,25 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
target = args[0]
|
target = args[0]
|
||||||
|
|
||||||
default:
|
default:
|
||||||
showError(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web}", cmd.backendMode), nil)
|
tui.Error(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web}", cmd.backendMode), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load zrokdir", err)
|
tui.Error("unable to load zrokdir", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zif, err := zrokdir.ZitiIdentityFile("backend")
|
zif, err := zrokdir.ZitiIdentityFile("backend")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load ziti identity configuration", err)
|
tui.Error("unable to load ziti identity configuration", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create zrok client", err)
|
tui.Error("unable to create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -121,7 +122,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
resp, err := zrok.Share.Share(req, auth)
|
resp, err := zrok.Share.Share(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create share", err)
|
tui.Error("unable to create share", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -144,7 +145,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
_, err = cmd.proxyBackendMode(cfg)
|
_, err = cmd.proxyBackendMode(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create proxy backend handler", err)
|
tui.Error("unable to create proxy backend handler", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -158,13 +159,13 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
_, err = cmd.webBackendMode(cfg)
|
_, err = cmd.webBackendMode(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create web backend handler", err)
|
tui.Error("unable to create web backend handler", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
showError("invalid backend mode", nil)
|
tui.Error("invalid backend mode", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("share with others; they will use this command for access: 'zrok access private %v'", resp.Payload.ShrToken)
|
logrus.Infof("share with others; they will use this command for access: 'zrok access private %v'", resp.Payload.ShrToken)
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -55,7 +56,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
targetEndpoint, err := url.Parse(args[0])
|
targetEndpoint, err := url.Parse(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("invalid target endpoint URL", err)
|
tui.Error("invalid target endpoint URL", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -68,25 +69,25 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
target = args[0]
|
target = args[0]
|
||||||
|
|
||||||
default:
|
default:
|
||||||
showError(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web}", cmd.backendMode), nil)
|
tui.Error(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web}", cmd.backendMode), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load zrokdir", nil)
|
tui.Error("unable to load zrokdir", nil)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zif, err := zrokdir.ZitiIdentityFile("backend")
|
zif, err := zrokdir.ZitiIdentityFile("backend")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load ziti identity configuration", err)
|
tui.Error("unable to load ziti identity configuration", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -94,7 +95,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create zrok client", err)
|
tui.Error("unable to create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -123,7 +124,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
resp, err := zrok.Share.Share(req, auth)
|
resp, err := zrok.Share.Share(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create tunnel", err)
|
tui.Error("unable to create tunnel", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -147,7 +148,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
bh, err = cmd.proxyBackendMode(cfg)
|
bh, err = cmd.proxyBackendMode(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create proxy backend handler", err)
|
tui.Error("unable to create proxy backend handler", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -161,13 +162,13 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
bh, err = cmd.webBackendMode(cfg)
|
bh, err = cmd.webBackendMode(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create web backend handler", err)
|
tui.Error("unable to create web backend handler", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
showError("invalid backend mode", nil)
|
tui.Error("invalid backend mode", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("access your zrok share: %v", resp.Payload.FrontendProxyEndpoints[0])
|
logrus.Infof("access your zrok share: %v", resp.Payload.FrontendProxyEndpoints[0])
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/metadata"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/metadata"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/share"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -40,7 +41,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
e, err := url.Parse(cmd.overrideEndpoint)
|
e, err := url.Parse(cmd.overrideEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("invalid override endpoint URL", err)
|
tui.Error("invalid override endpoint URL", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -53,19 +54,19 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("error loading zrokdir", err)
|
tui.Error("error loading zrokdir", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
showError("unable to load environment; did you 'zrok enable'?", nil)
|
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := zrd.Client()
|
zrok, err := zrd.Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create zrok client", err)
|
tui.Error("unable to create zrok client", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -75,7 +76,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
resp, err := zrok.Metadata.GetShareDetail(req, auth)
|
resp, err := zrok.Metadata.GetShareDetail(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to retrieve reserved share", err)
|
tui.Error("unable to retrieve reserved share", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
zif, err := zrokdir.ZitiIdentityFile("backend")
|
zif, err := zrokdir.ZitiIdentityFile("backend")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to load ziti identity configuration", err)
|
tui.Error("unable to load ziti identity configuration", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -105,7 +106,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
if _, err := zrok.Share.UpdateShare(upReq, auth); err != nil {
|
if _, err := zrok.Share.UpdateShare(upReq, auth); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to update backend proxy endpoint", err)
|
tui.Error("unable to update backend proxy endpoint", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -117,7 +118,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
httpProxy, err := proxyBackend.NewBackend(cfg)
|
httpProxy, err := proxyBackend.NewBackend(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to create http backend", err)
|
tui.Error("unable to create http backend", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -125,7 +126,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
go func() {
|
go func() {
|
||||||
if err := httpProxy.Run(); err != nil {
|
if err := httpProxy.Run(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to run http proxy", err)
|
tui.Error("unable to run http proxy", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"os"
|
"os"
|
||||||
@ -33,10 +34,10 @@ func (cmd *statusCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
|
|
||||||
zrd, err := zrokdir.Load()
|
zrd, err := zrokdir.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
showError("unable to load zrokdir", err)
|
tui.Error("unable to load zrokdir", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Config")+":\n\n")
|
_, _ = fmt.Fprintf(os.Stdout, tui.CodeStyle.Render("Config")+":\n\n")
|
||||||
t := table.NewWriter()
|
t := table.NewWriter()
|
||||||
t.SetOutputMirror(os.Stdout)
|
t.SetOutputMirror(os.Stdout)
|
||||||
t.SetStyle(table.StyleColoredDark)
|
t.SetStyle(table.StyleColoredDark)
|
||||||
@ -47,10 +48,10 @@ func (cmd *statusCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "%v: Unable to load your local environment!\n\n", warningLabel)
|
_, _ = fmt.Fprintf(os.Stderr, "%v: Unable to load your local environment!\n\n", tui.WarningLabel)
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", codeStyle.Render("zrok enable"))
|
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", tui.CodeStyle.Render("zrok enable"))
|
||||||
} else {
|
} else {
|
||||||
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Environment")+":\n\n")
|
_, _ = fmt.Fprintf(os.Stdout, tui.CodeStyle.Render("Environment")+":\n\n")
|
||||||
|
|
||||||
t := table.NewWriter()
|
t := table.NewWriter()
|
||||||
t.SetOutputMirror(os.Stdout)
|
t.SetOutputMirror(os.Stdout)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/opentracing/opentracing-go/log"
|
"github.com/opentracing/opentracing-go/log"
|
||||||
"github.com/openziti-test-kitchen/zrok/cmd/zrok/endpointUi"
|
"github.com/openziti-test-kitchen/zrok/cmd/zrok/endpointUi"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"html/template"
|
"html/template"
|
||||||
@ -33,7 +34,7 @@ func newTestEndpointCommand() *testEndpointCommand {
|
|||||||
var err error
|
var err error
|
||||||
if command.t, err = template.ParseFS(endpointUi.FS, "index.gohtml"); err != nil {
|
if command.t, err = template.ParseFS(endpointUi.FS, "index.gohtml"); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to parse index template", err)
|
tui.Error("unable to parse index template", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -47,7 +48,7 @@ func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
http.HandleFunc("/", cmd.serveIndex)
|
http.HandleFunc("/", cmd.serveIndex)
|
||||||
if err := http.ListenAndServe(fmt.Sprintf("%v:%d", cmd.address, cmd.port), nil); err != nil {
|
if err := http.ListenAndServe(fmt.Sprintf("%v:%d", cmd.address, cmd.port), nil); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("unable to start http listener", err)
|
tui.Error("unable to start http listener", err)
|
||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/charmbracelet/lipgloss"
|
|
||||||
"github.com/go-openapi/runtime"
|
"github.com/go-openapi/runtime"
|
||||||
httptransport "github.com/go-openapi/runtime/client"
|
httptransport "github.com/go-openapi/runtime/client"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type backendHandler interface {
|
type backendHandler interface {
|
||||||
@ -20,18 +17,3 @@ func mustGetAdminAuth() runtime.ClientAuthInfoWriter {
|
|||||||
}
|
}
|
||||||
return httptransport.APIKeyAuth("X-TOKEN", "header", adminToken)
|
return httptransport.APIKeyAuth("X-TOKEN", "header", adminToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
var errorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#D90166"))
|
|
||||||
var errorLabel = errorStyle.Render("ERROR")
|
|
||||||
var warningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFA500"))
|
|
||||||
var warningLabel = warningStyle.Render("WARNING")
|
|
||||||
var codeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FFFF"))
|
|
||||||
|
|
||||||
func showError(msg string, err error) {
|
|
||||||
if err != nil {
|
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "%v: %v (%v)\n", errorLabel, msg, strings.TrimSpace(err.Error()))
|
|
||||||
} else {
|
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "%v %v\n", errorLabel, msg)
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/openziti-test-kitchen/zrok/build"
|
"github.com/openziti-test-kitchen/zrok/build"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,5 +28,5 @@ func newVersionCommand() *versionCommand {
|
|||||||
|
|
||||||
func (cmd *versionCommand) run(_ *cobra.Command, _ []string) {
|
func (cmd *versionCommand) run(_ *cobra.Command, _ []string) {
|
||||||
zrokStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#FF00EE"))
|
zrokStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#FF00EE"))
|
||||||
fmt.Println(zrokStyle.Render(" _ \n _____ __ ___ | | __\n|_ / '__/ _ \\| |/ /\n / /| | | (_) | < \n/___|_| \\___/|_|\\_\\") + "\n\n" + codeStyle.Render(build.String()) + "\n")
|
fmt.Println(zrokStyle.Render(" _ \n _____ __ ___ | | __\n|_ / '__/ _ \\| |/ /\n / /| | | (_) | < \n/___|_| \\___/|_|\\_\\") + "\n\n" + tui.CodeStyle.Render(build.String()) + "\n")
|
||||||
}
|
}
|
||||||
|
27
tui/messages.go
Normal file
27
tui/messages.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package tui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/charmbracelet/lipgloss"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#D90166"))
|
||||||
|
var ErrorLabel = ErrorStyle.Render("ERROR")
|
||||||
|
var WarningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFA500"))
|
||||||
|
var WarningLabel = WarningStyle.Render("WARNING")
|
||||||
|
var CodeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FFFF"))
|
||||||
|
|
||||||
|
func Error(msg string, err error) {
|
||||||
|
if err != nil {
|
||||||
|
_, _ = fmt.Fprintf(os.Stderr, "%v: %v (%v)\n", ErrorLabel, msg, strings.TrimSpace(err.Error()))
|
||||||
|
} else {
|
||||||
|
_, _ = fmt.Fprintf(os.Stderr, "%v %v\n", ErrorLabel, msg)
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Warning(msg string, v ...interface{}) {
|
||||||
|
_, _ = fmt.Fprintf(os.Stderr, "%v: "+msg, v...)
|
||||||
|
}
|
@ -2,8 +2,8 @@ package zrokdir
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/tui"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ func checkMetadata() error {
|
|||||||
}
|
}
|
||||||
data, err := os.ReadFile(mf)
|
data, err := os.ReadFile(mf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warnf("unable to read zrokdir metadata; ignoring non-existent: %v", err)
|
tui.Warning("unable to open zrokdir metadata; ignoring")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
m := &Metadata{}
|
m := &Metadata{}
|
||||||
|
Loading…
Reference in New Issue
Block a user