mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 16:13:47 +01:00
Merge branch 'main' into websockets
This commit is contained in:
commit
4ccff8c1d5
@ -1,5 +1,9 @@
|
|||||||
# v0.3.2
|
# v0.3.2
|
||||||
|
|
||||||
|
CHANGE: Include missing `--headless` flag for `zrok enable` and `zrok access private` (https://github.com/openziti/zrok/issues/246)
|
||||||
|
|
||||||
|
CHANGE: Fix for `zrok enable` error path handling (https://github.com/openziti/zrok/issues/244)
|
||||||
|
|
||||||
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)
|
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
|
$ zrok controller validate etc/dev.yml
|
||||||
|
@ -24,8 +24,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type accessPrivateCommand struct {
|
type accessPrivateCommand struct {
|
||||||
cmd *cobra.Command
|
|
||||||
bindAddress string
|
bindAddress string
|
||||||
|
headless bool
|
||||||
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAccessPrivateCommand() *accessPrivateCommand {
|
func newAccessPrivateCommand() *accessPrivateCommand {
|
||||||
@ -35,6 +36,7 @@ func newAccessPrivateCommand() *accessPrivateCommand {
|
|||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
}
|
}
|
||||||
command := &accessPrivateCommand{cmd: cmd}
|
command := &accessPrivateCommand{cmd: cmd}
|
||||||
|
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
cmd.Flags().StringVarP(&command.bindAddress, "bind", "b", "127.0.0.1:9191", "The address to bind the private frontend")
|
cmd.Flags().StringVarP(&command.bindAddress, "bind", "b", "127.0.0.1:9191", "The address to bind the private frontend")
|
||||||
return command
|
return command
|
||||||
@ -112,6 +114,16 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if cmd.headless {
|
||||||
|
logrus.Infof("access the zrok share at the followind endpoint: %v", endpointUrl.String())
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case req := <-cfg.RequestsChan:
|
||||||
|
logrus.Infof("%v -> %v %v", req.RemoteAddr, req.Method, req.Path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
mdl := newAccessModel(shrToken, endpointUrl.String())
|
mdl := newAccessModel(shrToken, endpointUrl.String())
|
||||||
logrus.SetOutput(mdl)
|
logrus.SetOutput(mdl)
|
||||||
prg := tea.NewProgram(mdl, tea.WithAltScreen())
|
prg := tea.NewProgram(mdl, tea.WithAltScreen())
|
||||||
@ -134,6 +146,8 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
|
|
||||||
close(cfg.RequestsChan)
|
close(cfg.RequestsChan)
|
||||||
cmd.destroy(accessResp.Payload.FrontendToken, zrd.Env.ZId, shrToken, zrok, auth)
|
cmd.destroy(accessResp.Payload.FrontendToken, zrd.Env.ZId, shrToken, zrok, auth)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *accessPrivateCommand) destroy(frotendName, envZId, shrToken string, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) {
|
func (cmd *accessPrivateCommand) destroy(frotendName, envZId, shrToken string, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) {
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
user2 "os/user"
|
user2 "os/user"
|
||||||
"time"
|
"time"
|
||||||
@ -23,6 +24,7 @@ func init() {
|
|||||||
|
|
||||||
type enableCommand struct {
|
type enableCommand struct {
|
||||||
description string
|
description string
|
||||||
|
headless bool
|
||||||
cmd *cobra.Command
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ func newEnableCommand() *enableCommand {
|
|||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
}
|
}
|
||||||
command := &enableCommand{cmd: cmd}
|
command := &enableCommand{cmd: cmd}
|
||||||
|
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
|
||||||
cmd.Flags().StringVarP(&command.description, "description", "d", "<user>@<hostname>", "Description of this environment")
|
cmd.Flags().StringVarP(&command.description, "description", "d", "<user>@<hostname>", "Description of this environment")
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
return command
|
return command
|
||||||
@ -74,8 +77,9 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var prg *tea.Program
|
var prg *tea.Program
|
||||||
var mdl enableTuiModel
|
|
||||||
var done = make(chan struct{})
|
var done = make(chan struct{})
|
||||||
|
if !cmd.headless {
|
||||||
|
var mdl enableTuiModel
|
||||||
go func() {
|
go func() {
|
||||||
mdl = newEnableTuiModel()
|
mdl = newEnableTuiModel()
|
||||||
mdl.msg = "contacting the zrok service..."
|
mdl.msg = "contacting the zrok service..."
|
||||||
@ -88,36 +92,69 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
} else {
|
||||||
|
logrus.Infof("contacting the zrok service...")
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := zrok.Environment.Enable(req, auth)
|
resp, err := zrok.Environment.Enable(req, auth)
|
||||||
//Switch on err type (401, 400, 500, etc...)
|
//Switch on err type (401, 400, 500, etc...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
|
if !cmd.headless && prg != nil {
|
||||||
prg.Send(fmt.Sprintf("the zrok service returned an error: %v\n", err))
|
prg.Send(fmt.Sprintf("the zrok service returned an error: %v\n", err))
|
||||||
prg.Quit()
|
prg.Quit()
|
||||||
<-done
|
} else {
|
||||||
|
logrus.Errorf("the zrok service returned an error: %v", err)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
}
|
||||||
cmd.endpointError(zrd.ApiEndpoint())
|
cmd.endpointError(zrd.ApiEndpoint())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
prg.Send("writing the environment details...")
|
prg.Send("writing the environment details...")
|
||||||
|
}
|
||||||
apiEndpoint, _ := zrd.ApiEndpoint()
|
apiEndpoint, _ := zrd.ApiEndpoint()
|
||||||
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 !cmd.headless && prg != nil {
|
||||||
prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err))
|
prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err))
|
||||||
prg.Quit()
|
prg.Quit()
|
||||||
<-done
|
} else {
|
||||||
|
logrus.Errorf("there was an error saving the new environment: %v", err)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
|
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
|
||||||
|
if !cmd.headless && prg != nil {
|
||||||
prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err))
|
prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err))
|
||||||
prg.Quit()
|
prg.Quit()
|
||||||
<-done
|
} else {
|
||||||
|
logrus.Errorf("there was an error writing the environment: %v", err)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !cmd.headless && prg != nil {
|
||||||
prg.Send(fmt.Sprintf("the zrok environment was successfully enabled..."))
|
prg.Send(fmt.Sprintf("the zrok environment was successfully enabled..."))
|
||||||
prg.Quit()
|
prg.Quit()
|
||||||
<-done
|
} else {
|
||||||
|
logrus.Infof("the zrok environment was successfully enabled...")
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *enableCommand) endpointError(apiEndpoint, _ string) {
|
func (cmd *enableCommand) endpointError(apiEndpoint, _ string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user