Skip to content

Commit

Permalink
zrokdir -> environment (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Jul 10, 2023
1 parent 917ba12 commit ea71493
Show file tree
Hide file tree
Showing 35 changed files with 132 additions and 132 deletions.
6 changes: 3 additions & 3 deletions cmd/zrok/accessPrivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/openziti/zrok/endpoints/proxy"
"github.com/openziti/zrok/endpoints/tcpTunnel"
"github.com/openziti/zrok/endpoints/udpTunnel"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/rest_client_zrok"
"github.com/openziti/zrok/rest_client_zrok/share"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"net/url"
Expand Down Expand Up @@ -48,9 +48,9 @@ func newAccessPrivateCommand() *accessPrivateCommand {
func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
shrToken := args[0]

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
tui.Error("unable to load zrokdir", err)
tui.Error("error loading environment", err)
}

if zrd.Env == nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zrok/adminCreateFrontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package main
import (
"os"

"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -35,7 +35,7 @@ func (cmd *adminCreateFrontendCommand) run(_ *cobra.Command, args []string) {
publicName := args[1]
urlTemplate := args[2]

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/zrok/adminCreateIdentity.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/zrokdir"
"github.com/openziti/zrok/environment"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
Expand Down Expand Up @@ -32,7 +32,7 @@ func newAdminCreateIdentity() *adminCreateIdentity {
func (cmd *adminCreateIdentity) run(_ *cobra.Command, args []string) {
name := args[0]

zif, err := zrokdir.ZitiIdentityFile(name)
zif, err := environment.ZitiIdentityFile(name)
if err != nil {
panic(err)
}
Expand All @@ -41,7 +41,7 @@ func (cmd *adminCreateIdentity) run(_ *cobra.Command, args []string) {
os.Exit(1)
}

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand All @@ -59,7 +59,7 @@ func (cmd *adminCreateIdentity) run(_ *cobra.Command, args []string) {
panic(err)
}

if err := zrokdir.SaveZitiIdentity(name, resp.Payload.Cfg); err != nil {
if err := environment.SaveZitiIdentity(name, resp.Payload.Cfg); err != nil {
panic(err)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/zrok/adminDeleteFrontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/zrokdir"
"github.com/openziti/zrok/environment"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand All @@ -30,7 +30,7 @@ func newAdminDeleteFrontendCommand() *adminDeleteFrontendCommand {
func (cmd *adminDeleteFrontendCommand) run(_ *cobra.Command, args []string) {
feToken := args[0]

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/zrok/adminGenerate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
"fmt"
"github.com/jaevor/go-nanoid"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/zrokdir"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -43,9 +43,9 @@ func (cmd *adminGenerateCommand) run(_ *cobra.Command, args []string) {
}
}

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
logrus.Error("error loading zrokdir", err)
logrus.Error("error loading environment", err)
}

zrok, err := zrd.Client()
Expand Down
4 changes: 2 additions & 2 deletions cmd/zrok/adminListFrontends.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/zrokdir"
"github.com/openziti/zrok/environment"
"github.com/spf13/cobra"
"os"
"time"
Expand All @@ -31,7 +31,7 @@ func newAdminListFrontendsCommand() *adminListFrontendsCommand {
}

func (cmd *adminListFrontendsCommand) run(_ *cobra.Command, _ []string) {
zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zrok/adminUpdateFrontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/zrokdir"
"github.com/openziti/zrok/environment"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -38,7 +38,7 @@ func (cmd *adminUpdateFrontendCommand) run(_ *cobra.Command, args []string) {
panic("must specify at least one of public name or url template")
}

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zrok/configGet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"github.com/openziti/zrok/zrokdir"
"github.com/openziti/zrok/environment"
"github.com/spf13/cobra"
)

Expand All @@ -28,7 +28,7 @@ func newConfigGetCommand() *configGetCommand {
func (cmd *configGetCommand) run(_ *cobra.Command, args []string) {
configName := args[0]

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/zrok/configSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/url"
"os"

"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/spf13/cobra"
)

Expand All @@ -33,7 +33,7 @@ func (cmd *configSetCommand) run(_ *cobra.Command, args []string) {
configName := args[0]
value := args[1]

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand All @@ -42,7 +42,7 @@ func (cmd *configSetCommand) run(_ *cobra.Command, args []string) {
switch configName {
case "apiEndpoint":
if zrd.Cfg == nil {
zrd.Cfg = &zrokdir.Config{}
zrd.Cfg = &environment.Config{}
}
ok, err := isFullyValidUrl(value)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zrok/configUnset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/openziti/zrok/environment"
"github.com/spf13/cobra"
"os"
)
Expand All @@ -30,7 +30,7 @@ func newConfigUnsetCommand() *configUnsetCommand {
func (cmd *configUnsetCommand) run(_ *cobra.Command, args []string) {
configName := args[0]

zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/zrok/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/spf13/cobra"
)

Expand All @@ -27,12 +27,12 @@ func newConsoleCommand() *consoleCommand {
}

func (cmd *consoleCommand) run(_ *cobra.Command, _ []string) {
zrd, err := zrokdir.Load()
env, err := environment.Load()
if err != nil {
tui.Error("unable to load zrokdir", err)
tui.Error("unable to load environment", err)
}

apiEndpoint, _ := zrd.ApiEndpoint()
apiEndpoint, _ := env.ApiEndpoint()
if err := openBrowser(apiEndpoint); err != nil {
tui.Error(fmt.Sprintf("unable to open '%v'", apiEndpoint), err)
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/zrok/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package main

import (
"fmt"
httptransport "github.com/go-openapi/runtime/client"
"github.com/openziti/zrok/rest_client_zrok/environment"
httpTransport "github.com/go-openapi/runtime/client"
"github.com/openziti/zrok/environment"
restEnvironment "github.com/openziti/zrok/rest_client_zrok/environment"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand All @@ -31,10 +31,10 @@ func newDisableCommand() *disableCommand {
}

func (cmd *disableCommand) run(_ *cobra.Command, _ []string) {
zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
if !panicInstead {
tui.Error("unable to load zrokdir", err)
tui.Error("unable to load environment", err)
}
panic(err)
}
Expand All @@ -50,22 +50,22 @@ func (cmd *disableCommand) run(_ *cobra.Command, _ []string) {
}
panic(err)
}
auth := httptransport.APIKeyAuth("X-TOKEN", "header", zrd.Env.Token)
req := environment.NewDisableParams()
auth := httpTransport.APIKeyAuth("X-TOKEN", "header", zrd.Env.Token)
req := restEnvironment.NewDisableParams()
req.Body = &rest_model_zrok.DisableRequest{
Identity: zrd.Env.ZId,
}
_, err = zrok.Environment.Disable(req, auth)
if err != nil {
logrus.Warnf("share cleanup failed (%v); will clean up local environment", err)
}
if err := zrokdir.DeleteEnvironment(); err != nil {
if err := environment.DeleteEnvironment(); err != nil {
if !panicInstead {
tui.Error("error removing zrok environment", err)
}
panic(err)
}
if err := zrokdir.DeleteZitiIdentity("backend"); err != nil {
if err := environment.DeleteZitiIdentity("backend"); err != nil {
if !panicInstead {
tui.Error("error removing zrok backend identity", err)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/zrok/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
httptransport "github.com/go-openapi/runtime/client"
"github.com/openziti/zrok/rest_client_zrok/environment"
"github.com/openziti/zrok/environment"
restEnvironment "github.com/openziti/zrok/rest_client_zrok/environment"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/zrokdir"
"github.com/shirou/gopsutil/v3/host"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -42,7 +42,7 @@ func newEnableCommand() *enableCommand {
}

func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
tui.Error("error creating service client", err)
}
auth := httptransport.APIKeyAuth("X-TOKEN", "header", token)
req := environment.NewEnableParams()
req := restEnvironment.NewEnableParams()
req.Body = &rest_model_zrok.EnableRequest{
Description: cmd.description,
Host: hostDetail,
Expand Down Expand Up @@ -117,7 +117,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
prg.Send("writing the environment details...")
}
apiEndpoint, _ := zrd.ApiEndpoint()
zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}
zrd.Env = &environment.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}
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))
Expand All @@ -131,7 +131,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
}
os.Exit(1)
}
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
if err := environment.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.Quit()
Expand Down
6 changes: 3 additions & 3 deletions cmd/zrok/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/rest_client_zrok/account"
"github.com/openziti/zrok/rest_client_zrok/metadata"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/tui"
"github.com/openziti/zrok/util"
"github.com/openziti/zrok/zrokdir"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -42,9 +42,9 @@ func newInviteCommand() *inviteCommand {
}

func (cmd *inviteCommand) run(_ *cobra.Command, _ []string) {
zrd, err := zrokdir.Load()
zrd, err := environment.Load()
if err != nil {
tui.Error("error loading zrokdir", err)
tui.Error("error loading environment", err)
}

zrok, err := zrd.Client()
Expand Down
Loading

0 comments on commit ea71493

Please sign in to comment.