mirror of
https://github.com/openziti/zrok.git
synced 2024-11-23 00:23:48 +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,28 +114,40 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
mdl := newAccessModel(shrToken, endpointUrl.String())
|
if cmd.headless {
|
||||||
logrus.SetOutput(mdl)
|
logrus.Infof("access the zrok share at the followind endpoint: %v", endpointUrl.String())
|
||||||
prg := tea.NewProgram(mdl, tea.WithAltScreen())
|
|
||||||
mdl.prg = prg
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case req := <-cfg.RequestsChan:
|
case req := <-cfg.RequestsChan:
|
||||||
if req != nil {
|
logrus.Infof("%v -> %v %v", req.RemoteAddr, req.Method, req.Path)
|
||||||
prg.Send(req)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
|
||||||
if _, err := prg.Run(); err != nil {
|
} else {
|
||||||
tui.Error("An error occurred", err)
|
mdl := newAccessModel(shrToken, endpointUrl.String())
|
||||||
|
logrus.SetOutput(mdl)
|
||||||
|
prg := tea.NewProgram(mdl, tea.WithAltScreen())
|
||||||
|
mdl.prg = prg
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case req := <-cfg.RequestsChan:
|
||||||
|
if req != nil {
|
||||||
|
prg.Send(req)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if _, err := prg.Run(); err != nil {
|
||||||
|
tui.Error("An error occurred", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
close(cfg.RequestsChan)
|
||||||
|
cmd.destroy(accessResp.Payload.FrontendToken, zrd.Env.ZId, shrToken, zrok, auth)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(cfg.RequestsChan)
|
|
||||||
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,50 +77,84 @@ 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{})
|
||||||
go func() {
|
if !cmd.headless {
|
||||||
mdl = newEnableTuiModel()
|
var mdl enableTuiModel
|
||||||
mdl.msg = "contacting the zrok service..."
|
go func() {
|
||||||
prg = tea.NewProgram(mdl)
|
mdl = newEnableTuiModel()
|
||||||
if _, err := prg.Run(); err != nil {
|
mdl.msg = "contacting the zrok service..."
|
||||||
fmt.Println(err)
|
prg = tea.NewProgram(mdl)
|
||||||
}
|
if _, err := prg.Run(); err != nil {
|
||||||
close(done)
|
fmt.Println(err)
|
||||||
if mdl.quitting {
|
}
|
||||||
os.Exit(1)
|
close(done)
|
||||||
}
|
if mdl.quitting {
|
||||||
}()
|
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)
|
||||||
prg.Send(fmt.Sprintf("the zrok service returned an error: %v\n", err))
|
if !cmd.headless && prg != nil {
|
||||||
prg.Quit()
|
prg.Send(fmt.Sprintf("the zrok service returned an error: %v\n", err))
|
||||||
<-done
|
prg.Quit()
|
||||||
|
} 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)
|
||||||
}
|
}
|
||||||
prg.Send("writing the environment details...")
|
if err != nil {
|
||||||
|
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 {
|
||||||
prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err))
|
if !cmd.headless && prg != nil {
|
||||||
prg.Quit()
|
prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err))
|
||||||
<-done
|
prg.Quit()
|
||||||
|
} 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 {
|
||||||
prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err))
|
if !cmd.headless && prg != nil {
|
||||||
prg.Quit()
|
prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err))
|
||||||
<-done
|
prg.Quit()
|
||||||
|
} 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
prg.Send(fmt.Sprintf("the zrok environment was successfully enabled..."))
|
if !cmd.headless && prg != nil {
|
||||||
prg.Quit()
|
prg.Send(fmt.Sprintf("the zrok environment was successfully enabled..."))
|
||||||
<-done
|
prg.Quit()
|
||||||
|
} 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