From fdbc3274dd808fe7661b45d56291fefce2d0657f Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 9 Apr 2024 14:26:12 -0400 Subject: [PATCH] Do some CLI tidying. Fixes #1921 * Remove version, use, install and upgrade commands * Replace version with command which outputs CLI version * Remove redundant version commands * Remove ziti fabric add/remove-identity commands * Remove lots of unused code * Remove 'ziti tunnel enroll' command, which is replaced by 'ziti edge enroll' --- ziti/cmd/cmd.go | 13 +- ziti/{tunnel => cmd/common}/version.go | 2 +- ziti/cmd/fabric/add_identity.go | 80 ---- ziti/cmd/fabric/remove_identity.go | 68 ---- ziti/cmd/fabric/root.go | 1 - ziti/cmd/install/common_install.go | 240 ------------ ziti/cmd/install/install.go | 108 ------ ...tall_terraform_provider_edge_controller.go | 97 ----- ziti/cmd/install/install_ziti_ALL.go | 126 ------- ziti/cmd/install/install_ziti_controller.go | 96 ----- ziti/cmd/install/install_ziti_edge_tunnel.go | 100 ----- ziti/cmd/install/install_ziti_prox_c.go | 99 ----- ziti/cmd/install/install_ziti_router.go | 96 ----- ziti/cmd/install/install_ziti_tunnel.go | 96 ----- ziti/cmd/install/upgrade.go | 77 ---- ziti/cmd/install/upgrade_ziti.go | 93 ----- ziti/cmd/install/upgrade_ziti_controller.go | 47 --- ziti/cmd/install/upgrade_ziti_edge_tunnel.go | 46 --- ziti/cmd/install/upgrade_ziti_prox_c.go | 46 --- ziti/cmd/install/upgrade_ziti_router.go | 47 --- ziti/cmd/install/upgrade_ziti_tunnel.go | 47 --- ziti/cmd/install/use.go | 161 -------- ziti/cmd/install/version.go | 277 -------------- ziti/cmd/table/padding.go | 65 ---- ziti/cmd/table/table.go | 101 ----- ziti/cmd/templates/templater.go | 11 +- ziti/controller/root.go | 9 +- ziti/controller/version.go | 33 -- ziti/internal/log/log.go | 12 - ziti/router/root.go | 7 +- ziti/router/version.go | 33 -- ziti/tunnel/root.go | 16 +- ziti/util/colors.go | 24 -- ziti/util/commands.go | 12 - ziti/util/dirs.go | 126 ------- ziti/util/files.go | 198 ---------- ziti/util/pickers.go | 103 ----- ziti/util/rest.go | 353 ------------------ ziti/util/session.go | 66 ---- ziti/util/strings.go | 129 ------- ziti/util/suggestions.go | 129 ------- zititest/go.mod | 14 +- zititest/go.sum | 28 +- 43 files changed, 50 insertions(+), 3482 deletions(-) rename ziti/{tunnel => cmd/common}/version.go (98%) delete mode 100644 ziti/cmd/fabric/add_identity.go delete mode 100644 ziti/cmd/fabric/remove_identity.go delete mode 100644 ziti/cmd/install/common_install.go delete mode 100644 ziti/cmd/install/install.go delete mode 100644 ziti/cmd/install/install_terraform_provider_edge_controller.go delete mode 100644 ziti/cmd/install/install_ziti_ALL.go delete mode 100644 ziti/cmd/install/install_ziti_controller.go delete mode 100644 ziti/cmd/install/install_ziti_edge_tunnel.go delete mode 100644 ziti/cmd/install/install_ziti_prox_c.go delete mode 100644 ziti/cmd/install/install_ziti_router.go delete mode 100644 ziti/cmd/install/install_ziti_tunnel.go delete mode 100644 ziti/cmd/install/upgrade.go delete mode 100644 ziti/cmd/install/upgrade_ziti.go delete mode 100644 ziti/cmd/install/upgrade_ziti_controller.go delete mode 100644 ziti/cmd/install/upgrade_ziti_edge_tunnel.go delete mode 100644 ziti/cmd/install/upgrade_ziti_prox_c.go delete mode 100644 ziti/cmd/install/upgrade_ziti_router.go delete mode 100644 ziti/cmd/install/upgrade_ziti_tunnel.go delete mode 100644 ziti/cmd/install/use.go delete mode 100644 ziti/cmd/install/version.go delete mode 100644 ziti/cmd/table/padding.go delete mode 100644 ziti/cmd/table/table.go delete mode 100644 ziti/controller/version.go delete mode 100644 ziti/router/version.go delete mode 100644 ziti/util/colors.go delete mode 100644 ziti/util/session.go delete mode 100644 ziti/util/strings.go delete mode 100644 ziti/util/suggestions.go diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 64fd9fa1e..21a809753 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -31,7 +31,6 @@ import ( "github.com/openziti/ziti/ziti/cmd/demo" "github.com/openziti/ziti/ziti/cmd/edge" "github.com/openziti/ziti/ziti/cmd/fabric" - "github.com/openziti/ziti/ziti/cmd/install" "github.com/openziti/ziti/ziti/cmd/pki" "github.com/openziti/ziti/ziti/cmd/templates" c "github.com/openziti/ziti/ziti/constants" @@ -143,18 +142,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com opsCommands.AddCommand(NewCmdLogFormat(out, err)) opsCommands.AddCommand(NewUnwrapIdentityFileCommand(out, err)) - installCommands := []*cobra.Command{ - install.NewCmdInstall(out, err), - install.NewCmdUpgrade(out, err), - install.NewCmdUse(out, err), - install.NewCmdVersion(out, err), - } - groups := templates.CommandGroups{ - { - Message: "Installing Ziti components:", - Commands: installCommands, - }, { Message: "Working with Ziti resources:", Commands: []*cobra.Command{ @@ -197,6 +185,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com cmd.Version = version.GetVersion() cmd.SetVersionTemplate("{{printf .Version}}\n") cmd.AddCommand(NewCmdArt(out, err)) + cmd.AddCommand(common.NewVersionCmd()) return cmd } diff --git a/ziti/tunnel/version.go b/ziti/cmd/common/version.go similarity index 98% rename from ziti/tunnel/version.go rename to ziti/cmd/common/version.go index 947ac932a..a4abc8c55 100644 --- a/ziti/tunnel/version.go +++ b/ziti/cmd/common/version.go @@ -14,7 +14,7 @@ limitations under the License. */ -package tunnel +package common import ( "fmt" diff --git a/ziti/cmd/fabric/add_identity.go b/ziti/cmd/fabric/add_identity.go deleted file mode 100644 index 90007f08e..000000000 --- a/ziti/cmd/fabric/add_identity.go +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package fabric - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - "github.com/openziti/ziti/ziti/util" - "github.com/spf13/cobra" -) - -type addIdentityOptions struct { - common.CommonOptions - caCert string - clientCert string - clientKey string - readOnly bool -} - -func newAddIdentityCmd(p common.OptionsProvider) *cobra.Command { - options := &addIdentityOptions{ - CommonOptions: p(), - } - - cmd := &cobra.Command{ - Use: "add-identity ", - Short: "adds a fabric identity for connecting to the Ziti Controller", - Args: cobra.ExactArgs(1), - RunE: options.run, - } - - cmd.Flags().StringVarP(&common.CliIdentity, "cli-identity", "i", "", "Specify the saved identity you want the CLI to use when connect to the controller with") - cmd.Flags().StringVar(&options.caCert, "ca-cert", "", "additional root certificates used by the Ziti Controller") - cmd.Flags().StringVar(&options.clientCert, "client-cert", "", "client certificate used to authenticate to the Ziti Controller") - cmd.Flags().StringVar(&options.clientKey, "client-key", "", "client certificate key used to authenticate to the Ziti Controller") - cmd.Flags().BoolVar(&options.readOnly, "read-only", false, "marks this login as read-only. Note: this is not a guarantee that nothing can be changed on the server. Care should still be taken!") - - for _, required := range []string{"ca-cert", "client-cert", "client-key"} { - if err := cmd.MarkFlagRequired(required); err != nil { - panic(err) - } - } - - return cmd -} - -func (o *addIdentityOptions) run(_ *cobra.Command, args []string) error { - config, configFile, err := util.LoadRestClientConfig() - if err != nil { - return err - } - - id := config.GetIdentity() - - loginIdentity := &util.RestClientFabricIdentity{ - Url: args[0], - CaCert: o.caCert, - ClientCert: o.clientCert, - ClientKey: o.clientKey, - ReadOnly: o.readOnly, - } - - o.Printf("Saving identity '%v' to %v\n", id, configFile) - config.FabricIdentities[id] = loginIdentity - - return util.PersistRestClientConfig(config) -} diff --git a/ziti/cmd/fabric/remove_identity.go b/ziti/cmd/fabric/remove_identity.go deleted file mode 100644 index 9d4895ce4..000000000 --- a/ziti/cmd/fabric/remove_identity.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package fabric - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/util" - "github.com/spf13/cobra" -) - -// removeIdentityOptions are the flags for removeIdentity commands -type removeIdentityOptions struct { - common.CommonOptions -} - -// newRemoveIdentityCmd creates the command -func newRemoveIdentityCmd(p common.OptionsProvider) *cobra.Command { - options := &removeIdentityOptions{ - CommonOptions: p(), - } - - cmd := &cobra.Command{ - Use: "remove-identity", - Short: "remove an identity for a Ziti Controller instance", - Args: cobra.ExactArgs(0), - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{}, - } - - // allow interspersing positional args and flags - cmd.Flags().SetInterspersed(true) - cmd.Flags().StringVarP(&common.CliIdentity, "cli-identity", "i", "", "Specify the saved identity you want the CLI to use when connect to the controller with") - - return cmd -} - -// Run implements this command -func (o *removeIdentityOptions) Run() error { - config, configFile, err := util.LoadRestClientConfig() - if err != nil { - return err - } - - id := config.GetIdentity() - o.Printf("Removing fabric identity '%v' from %v\n", id, configFile) - delete(config.FabricIdentities, id) - return util.PersistRestClientConfig(config) -} diff --git a/ziti/cmd/fabric/root.go b/ziti/cmd/fabric/root.go index 8078ad537..14f32e159 100644 --- a/ziti/cmd/fabric/root.go +++ b/ziti/cmd/fabric/root.go @@ -31,7 +31,6 @@ import ( func NewFabricCmd(p common.OptionsProvider) *cobra.Command { fabricCmd := util.NewEmptyParentCmd("fabric", "Manage the Fabric components of a Ziti network using the Ziti Fabric REST and WebSocket APIs") - fabricCmd.AddCommand(newAddIdentityCmd(p), newRemoveIdentityCmd(p)) fabricCmd.AddCommand(newCreateCommand(p), newListCmd(p), newUpdateCommand(p), newDeleteCmd(p)) fabricCmd.AddCommand(newInspectCmd(p)) fabricCmd.AddCommand(newDbCmd(p)) diff --git a/ziti/cmd/install/common_install.go b/ziti/cmd/install/common_install.go deleted file mode 100644 index c67e91f3e..000000000 --- a/ziti/cmd/install/common_install.go +++ /dev/null @@ -1,240 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/blang/semver" - "github.com/openziti/ziti/common/getziti" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/openziti/ziti/ziti/util" - "gopkg.in/resty.v1" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" -) - -func isBinaryInstalled(d string) bool { - binDir, err := util.BinaryLocation() - if err == nil { - exists, err := util.FileExists(filepath.Join(binDir, d)) - if err == nil && exists { - return true - } - } - // log.Warnf("%s not found\n", d) - return false -} - -func (o *InstallOptions) deleteInstalledBinary(d string) bool { - binDir, err := util.BinaryLocation() - if err == nil { - exists, err := util.FileExists(filepath.Join(binDir, d)) - if err == nil && exists { - err = os.Remove(filepath.Join(binDir, d)) - if err != nil { - log.Warnf("Error attempting to delete %s: %s \n", d, err) - return false - } - return true - } - } - return false -} - -func (o *InstallOptions) shouldInstallBinary(binDir string, name string) (fileName string, download bool, err error) { - fileName = name - download = false - if runtime.GOOS == "windows" { - fileName += ".exe" - } - pgmPath, err := exec.LookPath(fileName) - if err == nil { - log.Warnf("%s is already available on your PATH at %s\n", util.ColorInfo(fileName), util.ColorInfo(pgmPath)) - return - } - - // lets see if its been installed but just is not on the PATH - exists, err := util.FileExists(filepath.Join(binDir, fileName)) - if err != nil { - return - } - if exists { - log.Warnf("Please add %s to your PATH\n", util.ColorInfo(binDir)) - return - } - download = true - return -} - -func (o *InstallOptions) getLatestZitiAppVersion(branch string, zitiApp string) (semver.Version, error) { - return util.GetLatestVersionFromArtifactory(o.Verbose, o.Staging, branch, zitiApp) -} - -func (o *InstallOptions) getLatestZitiAppVersionForBranch(branch string, zitiApp string) (semver.Version, error) { - return util.GetLatestVersionFromArtifactory(o.Verbose, o.Staging, branch, zitiApp) -} - -func (o *InstallOptions) getLatestTerraformProviderVersion(branch string, provider string) (semver.Version, error) { - return util.GetLatestTerraformProviderVersionFromArtifactory(branch, provider) -} - -func (o *InstallOptions) getLatestGitHubReleaseVersion(zitiApp string) (semver.Version, error) { - var result semver.Version - release, err := getziti.GetHighestVersionGitHubReleaseInfo(zitiApp, o.Verbose) - if release != nil { - result = release.SemVer - } - return result, err -} - -func (o *InstallOptions) getCurrentZitiSnapshotList() ([]string, error) { - children, err := util.GetCurrentSnapshotListFromArtifactory(o.Verbose) - - list := make([]string, 0) - list = append(list, "main") - - for _, v := range children { - str := strings.Replace(v.URI, "/", "", -1) - list = append(list, str) - } - - return list, err -} - -func (o *InstallOptions) installZitiApp(branch string, zitiApp string, upgrade bool, version string) error { - binDir, err := util.BinaryLocation() - if err != nil { - return err - } - binary := zitiApp - fileName := binary - if !upgrade { - f, flag, err := o.shouldInstallBinary(binDir, binary) - if err != nil || !flag { - return err - } - fileName = f - } - var latestVersion semver.Version - - if version != "" { - - if strings.Contains(version, "*") { - latestVersion, err = util.GetLatestSemanticVersionFromArtifactory(o.Verbose, o.Staging, branch, binary, version) - if err != nil { - return err - } - version = latestVersion.String() - } else { - latestVersion, err = semver.Make(version) - if err != nil { - return err - } - } - } - - fullPath := filepath.Join(binDir, fileName) - ext := ".tar.gz" - tarFile := fullPath + ext - - repoUrl := util.GetArtifactoryPath(o.Staging, binary, branch) + "/" + version + "/" + zitiApp + ext - - log.Infof("Attempting to download %s to %s", repoUrl, tarFile) - - err = util.DownloadArtifactoryFile(repoUrl, tarFile) - if err != nil { - return err - } - - log.Infof("Attempting to extract %s to %s", tarFile, fileName) - err = util.UnTargz(tarFile, binDir, []string{binary, fileName}) - if err != nil { - return err - } - err = os.Remove(tarFile) - if err != nil { - return err - } - log.Infof("Successfully installed '%s' version '%s' from branch '%s'\n", zitiApp, latestVersion, branch) - return os.Chmod(fullPath, 0755) -} - -func (o *InstallOptions) installTerraformProvider(branch string, provider string, upgrade bool, version string) error { - resty.SetDebug(o.Verbose) - binDir, err := util.TerraformProviderBinaryLocation() - if err != nil { - return err - } - latestVersion, err := util.GetLatestTerraformProviderVersionFromArtifactory(branch, provider) - if err != nil { - return err - } - if version != "" { - latestVersion, err = semver.Make(version) - if err != nil { - return err - } - } - - fullPath := filepath.Join(binDir, c.TERRAFORM_PROVIDER_PREFIX+provider) - ext := ".tar.gz" - tarFile := fullPath + ext - - repoUrl := util.GetTerraformProviderArtifactoryPath(provider, branch) + "/" + version + "/" + c.TERRAFORM_PROVIDER_PREFIX + provider + "_v" + version + ext - - log.Infof("Attempting to download %s to %s", repoUrl, tarFile) - - err = util.DownloadArtifactoryFile(repoUrl, tarFile) - if err != nil { - return err - } - fileToExtract := c.TERRAFORM_PROVIDER_PREFIX + provider + "_v" + version - if runtime.GOOS == "windows" { - fileToExtract += ".exe" - } - log.Infof("Attempting to extract file: '%s'\n", fileToExtract) - err = util.UnTargz(tarFile, binDir, []string{fileToExtract}) - if err != nil { - return err - } - err = os.Remove(tarFile) - if err != nil { - return err - } - log.Infof("Successfully installed Terraform Provider '%s' version '%s' from branch '%s'\n", provider, latestVersion, branch) - fileToChmod := fullPath + "_v" + version - if runtime.GOOS == "windows" { - fileToChmod += ".exe" - } - return os.Chmod(fileToChmod, 0755) -} - -func (o *InstallOptions) FindVersionAndInstallGitHubRelease(upgrade bool, zitiApp string, zitiAppGitHub string, version string) error { - binDir, err := util.BinaryLocation() - if err != nil { - return err - } - if !upgrade { - if _, download, err := o.shouldInstallBinary(binDir, zitiApp); err != nil || !download { - return err - } - } - return getziti.FindVersionAndInstallGitHubRelease(zitiApp, zitiAppGitHub, runtime.GOOS, runtime.GOARCH, binDir, version, o.Verbose) -} diff --git a/ziti/cmd/install/install.go b/ziti/cmd/install/install.go deleted file mode 100644 index 1873aa1b6..000000000 --- a/ziti/cmd/install/install.go +++ /dev/null @@ -1,108 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "fmt" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - "github.com/openziti/ziti/ziti/util" - "io" - "os" - "os/exec" - "strings" - - "github.com/spf13/cobra" -) - -// InstallOptions are the flags for delete commands -type InstallOptions struct { - common.CommonOptions -} - -var ( - install_long = templates.LongDesc(` - Install the Ziti platform binaries. -`) - - install_example = templates.Examples(` - # install the Ziti router - ziti install ziti-router - `) -) - -// GetCommandOutput evaluates the given command and returns the trimmed output -func (options *InstallOptions) GetCommandOutput(dir string, name string, args ...string) (string, error) { - os.Setenv("PATH", util.PathWithBinary()) - e := exec.Command(name, args...) - if dir != "" { - e.Dir = dir - } - data, err := e.CombinedOutput() - text := string(data) - text = strings.TrimSpace(text) - if err != nil { - return "", fmt.Errorf("command failed '%s %s': %s %s", name, strings.Join(args, " "), text, err) - } - return text, err -} - -// NewCmdInstall creates the command -func NewCmdInstall(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallOptions{ - common.CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "install [flags]", - Short: "Installs a Ziti component/app", - Long: install_long, - Example: install_example, - Aliases: []string{"install"}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{"up"}, - Hidden: true, - } - - cmd.AddCommand(NewCmdInstallZitiALL(out, errOut)) - - cmd.AddCommand(NewCmdInstallZitiController(out, errOut)) - cmd.AddCommand(NewCmdInstallZitiRouter(out, errOut)) - cmd.AddCommand(NewCmdInstallZitiTunnel(out, errOut)) - cmd.AddCommand(NewCmdInstallZitiEdgeTunnel(out, errOut)) - cmd.AddCommand(NewCmdInstallZitiProxC(out, errOut)) - - cmd.AddCommand(NewCmdInstallTerraformProviderEdgeController(out, errOut)) - - options.AddCommonFlags(cmd) - - return cmd -} - -// Run implements this command -func (o *InstallOptions) Run() error { - return o.Cmd.Help() -} diff --git a/ziti/cmd/install/install_terraform_provider_edge_controller.go b/ziti/cmd/install/install_terraform_provider_edge_controller.go deleted file mode 100644 index 46e80b165..000000000 --- a/ziti/cmd/install/install_terraform_provider_edge_controller.go +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "io" - - "github.com/blang/semver" - "github.com/spf13/cobra" -) - -var ( - installTerraformProviderEdgeControllerLong = templates.LongDesc(` - Installs the Terraform Provider for the Ziti Edge Controller -`) - - installTerraformProviderEdgeControllerExample = templates.Examples(` - # Install the Terraform Provider for the Ziti Edge Controller - ziti install terraform-provider-edgecontroller - `) -) - -// InstallTerraformProviderEdgeControllerOptions the options for the upgrade ziti-tunnel command -type InstallTerraformProviderEdgeControllerOptions struct { - InstallOptions - - Version string - Branch string -} - -// NewCmdInstallTerraformProviderEdgeController defines the command -func NewCmdInstallTerraformProviderEdgeController(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallTerraformProviderEdgeControllerOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "terraform-provider-edgecontroller", - Short: "Installs the Terraform Provider for the Ziti Edge Controller", - Aliases: []string{"tpec"}, - Long: installTerraformProviderEdgeControllerLong, - Example: installTerraformProviderEdgeControllerExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - cmd.Flags().StringVarP(&options.Branch, "branch", "b", "master", "The specific version to install") - cmd.Flags().BoolVarP(&options.Verbose, "verbose", "", false, "Enable verbose logging") - return cmd -} - -// Run implements the command -func (o *InstallTerraformProviderEdgeControllerOptions) Run() error { - newVersion, err := o.getLatestTerraformProviderVersion(o.Branch, c.TERRAFORM_PROVIDER_EDGE_CONTROLLER) - if err != nil { - return err - } - - if o.Version != "" { - newVersion, err = semver.Make(o.Version) - if err != nil { - return err - } - } - - log.Infoln("Attempting to install Terraform Provider '" + c.TERRAFORM_PROVIDER_EDGE_CONTROLLER + "' version: " + newVersion.String()) - - return o.installTerraformProvider(o.Branch, c.TERRAFORM_PROVIDER_EDGE_CONTROLLER, false, newVersion.String()) -} diff --git a/ziti/cmd/install/install_ziti_ALL.go b/ziti/cmd/install/install_ziti_ALL.go deleted file mode 100644 index 54b4c4f83..000000000 --- a/ziti/cmd/install/install_ziti_ALL.go +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "io" - - "github.com/blang/semver" - "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/spf13/cobra" -) - -var ( - installZitiALLLong = templates.LongDesc(` - Installs all Ziti apps that have not been installed already -`) - - installZitiALLExample = templates.Examples(` - # Install all the Ziti apps - ziti install all - `) -) - -// InstallZitiALLOptions the options for the upgrade ziti-channel command -type InstallZitiALLOptions struct { - InstallOptions - - Version string -} - -// NewCmdInstallZitiALL defines the command -func NewCmdInstallZitiALL(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallZitiALLOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "all", - Short: "Installs all the Ziti apps that have not been installed already", - Aliases: []string{"*"}, - Long: installZitiALLLong, - Example: installZitiALLExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.AddCommonFlags(cmd) - return cmd -} - -func (o *InstallZitiALLOptions) install(zitiApp string) error { - - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), zitiApp) - if err != nil { - return err - } - - if o.Version != "" { - newVersion, err = semver.Make(o.Version) - if err != nil { - return err - } - } - - log.Infoln("Attempting to install '" + zitiApp + "' version: " + newVersion.String()) - - return o.installZitiApp(version.GetBranch(), zitiApp, false, newVersion.String()) -} - -// Run implements the command -func (o *InstallZitiALLOptions) Run() error { - err := o.install(c.ZITI_CONTROLLER) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - err = o.install(c.ZITI_PROX_C) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - err = o.install(c.ZITI_ROUTER) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - err = o.install(c.ZITI_TUNNEL) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - err = o.install(c.ZITI_EDGE_TUNNEL) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - return nil -} diff --git a/ziti/cmd/install/install_ziti_controller.go b/ziti/cmd/install/install_ziti_controller.go deleted file mode 100644 index f7d82b6a5..000000000 --- a/ziti/cmd/install/install_ziti_controller.go +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - "io" - - "github.com/blang/semver" - "github.com/openziti/ziti/common/version" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/spf13/cobra" -) - -var ( - installZitiControllerLong = templates.LongDesc(` - Installs the Ziti Controller app if it has not been installed already -`) - - installZitiControllerExample = templates.Examples(` - # Install the Ziti Controller app - ziti install ziti-controller - `) -) - -// InstallZitiControllerOptions the options for the upgrade ziti-controller command -type InstallZitiControllerOptions struct { - InstallOptions - - Version string -} - -// NewCmdInstallZitiController defines the command -func NewCmdInstallZitiController(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallZitiControllerOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-controller", - Short: "Installs the Ziti Controller app - if it has not been installed already", - Aliases: []string{"controller"}, - Long: installZitiControllerLong, - Example: installZitiControllerExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.AddCommonFlags(cmd) - return cmd -} - -// Run implements the command -func (o *InstallZitiControllerOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_CONTROLLER) - if err != nil { - return err - } - - if o.Version != "" { - newVersion, err = semver.Make(o.Version) - if err != nil { - return err - } - } - - log.Infoln("Attempting to install '" + c.ZITI_CONTROLLER + "' version: " + newVersion.String()) - - return o.installZitiApp(version.GetBranch(), c.ZITI_CONTROLLER, false, newVersion.String()) -} diff --git a/ziti/cmd/install/install_ziti_edge_tunnel.go b/ziti/cmd/install/install_ziti_edge_tunnel.go deleted file mode 100644 index 74725f3b3..000000000 --- a/ziti/cmd/install/install_ziti_edge_tunnel.go +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/blang/semver" - "github.com/openziti/ziti/common/getziti" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/spf13/cobra" - "io" - "strings" -) - -var ( - installZitiEdgeTunnelLong = templates.LongDesc(` - Installs the Ziti Edge Tunnel app if it has not been installed already -`) - - installZitiEdgeTunnelExample = templates.Examples(` - # Install the Ziti Edge Tunnel app - ziti install ziti-edge-tunnel - `) -) - -// InstallZitiEdgeTunnelOptions the options for the upgrade ziti-edge-tunnel command -type InstallZitiEdgeTunnelOptions struct { - InstallOptions - - Version string -} - -// NewCmdInstallZitiEdgeTunnel defines the command -func NewCmdInstallZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallZitiEdgeTunnelOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-edge-tunnel", - Short: "Installs the Ziti Edge Tunnel app - if it has not been installed already", - Aliases: []string{"edge-tunnel"}, - Long: installZitiEdgeTunnelLong, - Example: installZitiEdgeTunnelExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.AddCommonFlags(cmd) - return cmd -} - -// Run implements the command -func (o *InstallOptions) installZitiEdgeTunnel(targetVersion string) error { - var newVersion semver.Version - - if targetVersion != "" { - newVersion = semver.MustParse(strings.TrimPrefix(targetVersion, "v")) - } else { - v, err := getziti.GetLatestGitHubReleaseVersion(c.ZITI_EDGE_TUNNEL_GITHUB, o.Verbose) - if err != nil { - return err - } - newVersion = v - } - - log.Infoln("Attempting to install '" + c.ZITI_EDGE_TUNNEL + "' version: " + newVersion.String()) - return o.FindVersionAndInstallGitHubRelease(false, c.ZITI_EDGE_TUNNEL, c.ZITI_EDGE_TUNNEL_GITHUB, newVersion.String()) -} - -// Run implements the command -func (o *InstallZitiEdgeTunnelOptions) Run() error { - return o.installZitiEdgeTunnel(o.Version) -} diff --git a/ziti/cmd/install/install_ziti_prox_c.go b/ziti/cmd/install/install_ziti_prox_c.go deleted file mode 100644 index ec79a4bb2..000000000 --- a/ziti/cmd/install/install_ziti_prox_c.go +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/blang/semver" - "github.com/openziti/ziti/common/getziti" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/spf13/cobra" - "io" - "strings" -) - -var ( - installZitiProxCLong = templates.LongDesc(` - Installs the Ziti ProxC app if it has not been installed already -`) - - installZitiProxCExample = templates.Examples(` - # Install the Ziti ProxC app - ziti install ziti-prox-c - `) -) - -// InstallZitiProxCOptions the options for the upgrade ziti-prox-c command -type InstallZitiProxCOptions struct { - InstallOptions - - Version string -} - -// NewCmdInstallZitiProxC defines the command -func NewCmdInstallZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallZitiProxCOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-prox-c", - Short: "Installs the Ziti ProxC app - if it has not been installed already", - Aliases: []string{"proxc"}, - Long: installZitiProxCLong, - Example: installZitiProxCExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.AddCommonFlags(cmd) - return cmd -} - -func (o *InstallOptions) installZitiProxC(targetVersion string) error { - var newVersion semver.Version - - if targetVersion != "" { - newVersion = semver.MustParse(strings.TrimPrefix(targetVersion, "v")) - } else { - v, err := getziti.GetLatestGitHubReleaseVersion(c.ZITI_SDK_C_GITHUB, o.Verbose) - if err != nil { - return err - } - newVersion = v - } - - log.Infoln("Attempting to install '" + c.ZITI_PROX_C + "' version: " + newVersion.String()) - return o.FindVersionAndInstallGitHubRelease(false, c.ZITI_PROX_C, c.ZITI_SDK_C_GITHUB, newVersion.String()) -} - -// Run implements the command -func (o *InstallZitiProxCOptions) Run() error { - return o.installZitiProxC(o.Version) -} diff --git a/ziti/cmd/install/install_ziti_router.go b/ziti/cmd/install/install_ziti_router.go deleted file mode 100644 index bb18bdfcd..000000000 --- a/ziti/cmd/install/install_ziti_router.go +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "io" - - "github.com/blang/semver" - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -var ( - installZitiRouterLong = templates.LongDesc(` - Installs the Ziti Router app if it has not been installed already -`) - - installZitiRouterExample = templates.Examples(` - # Install the Ziti Router app - ziti install ziti-router - `) -) - -// InstallZitiRouterOptions the options for the upgrade ziti-router command -type InstallZitiRouterOptions struct { - InstallOptions - - Version string -} - -// NewCmdInstallZitiRouter defines the command -func NewCmdInstallZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallZitiRouterOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-router", - Short: "Installs the Ziti Router app - if it has not been installed already", - Aliases: []string{"router"}, - Long: installZitiRouterLong, - Example: installZitiRouterExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.AddCommonFlags(cmd) - return cmd -} - -// Run implements the command -func (o *InstallZitiRouterOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_ROUTER) - if err != nil { - return err - } - - if o.Version != "" { - newVersion, err = semver.Make(o.Version) - if err != nil { - return err - } - } - - log.Infoln("Attempting to install '" + c.ZITI_ROUTER + "' version: " + newVersion.String()) - - return o.installZitiApp(version.GetBranch(), c.ZITI_ROUTER, false, newVersion.String()) -} diff --git a/ziti/cmd/install/install_ziti_tunnel.go b/ziti/cmd/install/install_ziti_tunnel.go deleted file mode 100644 index f411ae8ad..000000000 --- a/ziti/cmd/install/install_ziti_tunnel.go +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "io" - - "github.com/blang/semver" - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -var ( - installZitiTunnelLong = templates.LongDesc(` - Installs the Ziti Tunnel app if it has not been installed already -`) - - installZitiTunnelExample = templates.Examples(` - # Install the Ziti Tunnel app - ziti install ziti-tunnel - `) -) - -// InstallZitiTunnelOptions the options for the upgrade ziti-tunnel command -type InstallZitiTunnelOptions struct { - InstallOptions - - Version string -} - -// NewCmdInstallZitiTunnel defines the command -func NewCmdInstallZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallZitiTunnelOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-tunnel", - Short: "Installs the Ziti Tunnel app - if it has not been installed already", - Aliases: []string{"tunnel"}, - Long: installZitiTunnelLong, - Example: installZitiTunnelExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.AddCommonFlags(cmd) - return cmd -} - -// Run implements the command -func (o *InstallZitiTunnelOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_TUNNEL) - if err != nil { - return err - } - - if o.Version != "" { - newVersion, err = semver.Make(o.Version) - if err != nil { - return err - } - } - - log.Infoln("Attempting to install '" + c.ZITI_TUNNEL + "' version: " + newVersion.String()) - - return o.installZitiApp(version.GetBranch(), c.ZITI_TUNNEL, false, newVersion.String()) -} diff --git a/ziti/cmd/install/upgrade.go b/ziti/cmd/install/upgrade.go deleted file mode 100644 index f681b93ad..000000000 --- a/ziti/cmd/install/upgrade.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - "io" - - "github.com/spf13/cobra" -) - -// UpgradeOptions are the flags for delete commands -type UpgradeOptions struct { - common.CommonOptions -} - -var ( - upgrade_long = templates.LongDesc(` - Upgrade the Ziti platform binaries. -`) - - upgrade_example = templates.Examples(` - # upgrade the command line tool - ziti upgrade cli - `) -) - -// NewCmdUpgrade creates the command -func NewCmdUpgrade(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeOptions{ - common.CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "upgrade [flags]", - Short: "Upgrades a Ziti component/app", - Long: upgrade_long, - Example: upgrade_example, - Aliases: []string{"bump"}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{"up"}, - Hidden: true, - } - - cmd.AddCommand(NewCmdUpgradeZiti(out, errOut)) - - return cmd -} - -// Run implements this command -func (o *UpgradeOptions) Run() error { - return o.Cmd.Help() -} diff --git a/ziti/cmd/install/upgrade_ziti.go b/ziti/cmd/install/upgrade_ziti.go deleted file mode 100644 index 916c835ea..000000000 --- a/ziti/cmd/install/upgrade_ziti.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "io" - - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -var ( - upgradeCLILong = templates.LongDesc(` - Upgrades the Ziti command line tools if there is a newer release -`) - - upgradeCLIExample = templates.Examples(` - # Upgrades the Ziti CLI tools - ziti upgrade cli - `) -) - -// UpgradeZitiOptions the options for the create spring command -type UpgradeZitiOptions struct { - InstallOptions - - Version string -} - -// NewCmdUpgradeZiti defines the command -func NewCmdUpgradeZiti(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti", - Short: "Upgrades the ziti CLI - if there is a new version available", - Aliases: []string{"z", "cli"}, - Long: upgradeCLILong, - Example: upgradeCLIExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.AddCommonFlags(cmd) - return cmd -} - -// Run implements the command -func (o *UpgradeZitiOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI) - if err != nil { - return err - } - - newVersionStr := newVersion.String() - - if o.Version != "" { - newVersionStr = o.Version - } - - o.deleteInstalledBinary(c.ZITI) - - return o.installZitiApp(version.GetBranch(), c.ZITI, true, newVersionStr) -} diff --git a/ziti/cmd/install/upgrade_ziti_controller.go b/ziti/cmd/install/upgrade_ziti_controller.go deleted file mode 100644 index ed2a3720b..000000000 --- a/ziti/cmd/install/upgrade_ziti_controller.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/common/version" - c "github.com/openziti/ziti/ziti/constants" -) - -// UpgradeZitiControllerOptions the options for the upgrade ziti-controller command -type UpgradeZitiControllerOptions struct { - InstallOptions - - Version string -} - -// Run implements the command -func (o *UpgradeZitiControllerOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_CONTROLLER) - if err != nil { - return err - } - - newVersionStr := newVersion.String() - - if o.Version != "" { - newVersionStr = o.Version - } - - o.deleteInstalledBinary(c.ZITI_CONTROLLER) - - return o.installZitiApp(version.GetBranch(), c.ZITI_CONTROLLER, true, newVersionStr) -} diff --git a/ziti/cmd/install/upgrade_ziti_edge_tunnel.go b/ziti/cmd/install/upgrade_ziti_edge_tunnel.go deleted file mode 100644 index 1794669a1..000000000 --- a/ziti/cmd/install/upgrade_ziti_edge_tunnel.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - c "github.com/openziti/ziti/ziti/constants" -) - -// UpgradeZitiEdgeTunnelOptions the options for the upgrade ziti-edge-tunnel command -type UpgradeZitiEdgeTunnelOptions struct { - InstallOptions - - Version string -} - -// Run implements the command -func (o *UpgradeZitiEdgeTunnelOptions) Run() error { - newVersion, err := o.getLatestGitHubReleaseVersion(c.ZITI_EDGE_TUNNEL_GITHUB) - if err != nil { - return err - } - - newVersionStr := newVersion.String() - - if o.Version != "" { - newVersionStr = o.Version - } - - o.deleteInstalledBinary(c.ZITI_EDGE_TUNNEL) - - return o.FindVersionAndInstallGitHubRelease(true, c.ZITI_EDGE_TUNNEL, c.ZITI_EDGE_TUNNEL_GITHUB, newVersionStr) -} diff --git a/ziti/cmd/install/upgrade_ziti_prox_c.go b/ziti/cmd/install/upgrade_ziti_prox_c.go deleted file mode 100644 index 620ac1cf3..000000000 --- a/ziti/cmd/install/upgrade_ziti_prox_c.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - c "github.com/openziti/ziti/ziti/constants" -) - -// UpgradeZitiProxCOptions the options for the upgrade ziti-prox-c command -type UpgradeZitiProxCOptions struct { - InstallOptions - - Version string -} - -// Run implements the command -func (o *UpgradeZitiProxCOptions) Run() error { - newVersion, err := o.getLatestGitHubReleaseVersion(c.ZITI_SDK_C_GITHUB) - if err != nil { - return err - } - - newVersionStr := newVersion.String() - - if o.Version != "" { - newVersionStr = o.Version - } - - o.deleteInstalledBinary(c.ZITI_PROX_C) - - return o.FindVersionAndInstallGitHubRelease(true, c.ZITI_PROX_C, c.ZITI_SDK_C_GITHUB, newVersionStr) -} diff --git a/ziti/cmd/install/upgrade_ziti_router.go b/ziti/cmd/install/upgrade_ziti_router.go deleted file mode 100644 index e584f694c..000000000 --- a/ziti/cmd/install/upgrade_ziti_router.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/common/version" - c "github.com/openziti/ziti/ziti/constants" -) - -// UpgradeZitiRouterOptions the options for the upgrade ziti-router command -type UpgradeZitiRouterOptions struct { - InstallOptions - - Version string -} - -// Run implements the command -func (o *UpgradeZitiRouterOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_ROUTER) - if err != nil { - return err - } - - newVersionStr := newVersion.String() - - if o.Version != "" { - newVersionStr = o.Version - } - - o.deleteInstalledBinary(c.ZITI_ROUTER) - - return o.installZitiApp(version.GetBranch(), c.ZITI_ROUTER, true, newVersionStr) -} diff --git a/ziti/cmd/install/upgrade_ziti_tunnel.go b/ziti/cmd/install/upgrade_ziti_tunnel.go deleted file mode 100644 index 254a2d27c..000000000 --- a/ziti/cmd/install/upgrade_ziti_tunnel.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "github.com/openziti/ziti/common/version" - c "github.com/openziti/ziti/ziti/constants" -) - -// UpgradeZitiTunnelOptions the options for the upgrade ziti-tunnel command -type UpgradeZitiTunnelOptions struct { - InstallOptions - - Version string -} - -// Run implements the command -func (o *UpgradeZitiTunnelOptions) Run() error { - newVersion, err := o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_TUNNEL) - if err != nil { - return err - } - - newVersionStr := newVersion.String() - - if o.Version != "" { - newVersionStr = o.Version - } - - o.deleteInstalledBinary(c.ZITI_TUNNEL) - - return o.installZitiApp(version.GetBranch(), c.ZITI_TUNNEL, true, newVersionStr) -} diff --git a/ziti/cmd/install/use.go b/ziti/cmd/install/use.go deleted file mode 100644 index 6226049ed..000000000 --- a/ziti/cmd/install/use.go +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "fmt" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/openziti/ziti/ziti/util" - "io" - - "github.com/blang/semver" - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -// UseOptions are the flags for delete commands -type UseOptions struct { - InstallOptions - - Version string - Branch string -} - -// NewCmdUse creates the command -func NewCmdUse(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UseOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "use [branch]", - Short: "switch between branches of Ziti", - Long: ` -'ziti use' fetches the list of currently available branch-build names from artifactory, -presents them in a chooser-list, and once one is selected, will switch the current 'ziti' binary for the -chosen one. This is useful for swapping between different feature branches, or back and forth from a release -build to a feature-branch build. -`, - Aliases: []string{}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{}, - Hidden: true, - } - - cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to use") - cmd.Flags().BoolVarP(&options.Verbose, "verbose", "", false, "Enable verbose logging") - cmd.Flags().StringVarP(&options.Branch, "branch", "b", "", "Name of branch to switch to") - cmd.Flags().BoolVarP(&options.Staging, "staging", "", false, "Install/Upgrade components from the ziti-staging repo") - - return cmd -} - -func (o *UseOptions) install(branch string, zitiApp string) error { - newVersion, err := o.getLatestZitiAppVersionForBranch(branch, zitiApp) - if err != nil { - log.Infoln("Attempt to fetch latest version of '" + zitiApp + "' for branch '" + branch + "' failed: " + err.Error()) - - // Special-case branch fallback (to master) when dealing with ziti-prox-c - if zitiApp == c.ZITI_PROX_C || zitiApp == c.ZITI_EDGE_TUNNEL { - branch = "master" - newVersion, err = o.getLatestZitiAppVersionForBranch(branch, zitiApp) - if err != nil { - return err - } - } else { - return err - } - } - - if o.Version != "" { - newVersion, err = semver.Make(o.Version) - if err != nil { - return err - } - } - - log.Infoln("Attempting to install '" + zitiApp + "' version: " + newVersion.String() + " from branch '" + branch + "'") - - return o.installZitiApp(branch, zitiApp, true, newVersion.String()) -} - -// Run implements the command -func (o *UseOptions) Run() error { - - fmt.Println("Current source branch is: ", version.GetBranch()) - - branch := o.Branch - if branch == "" { - list, err := o.getCurrentZitiSnapshotList() - if err != nil { - return err - } - branch, err = util.PickName(list, "Which Branch would you like to switch to: ") - if err != nil { - return err - } - } - - if o.Staging { - if o.Branch != "main" { - log.Errorf("Error: --staging can only be used with --branch of 'main'. You specified '%s'", branch) - return nil - } - } - - err := o.install(branch, c.ZITI) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - err = o.install(branch, c.ZITI_CONTROLLER) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - err = o.install(branch, c.ZITI_ROUTER) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - err = o.install(branch, c.ZITI_TUNNEL) - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - err = o.installZitiProxC("") - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - err = o.installZitiEdgeTunnel("") - if err != nil { - log.Errorf("Error: install failed %s \n", err.Error()) - } - - return nil -} diff --git a/ziti/cmd/install/version.go b/ziti/cmd/install/version.go deleted file mode 100644 index f398866fe..000000000 --- a/ziti/cmd/install/version.go +++ /dev/null @@ -1,277 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package install - -import ( - "fmt" - "github.com/blang/semver" - "github.com/openziti/ziti/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/table" - "github.com/openziti/ziti/ziti/internal/log" - "io" - "os" - - "github.com/openziti/ziti/common/version" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/util" - - "github.com/spf13/cobra" -) - -type VersionOptions struct { - InstallOptions - - Container string - NoVersionCheck bool -} - -func NewCmdVersion(out io.Writer, errOut io.Writer) *cobra.Command { - options := &VersionOptions{ - InstallOptions: InstallOptions{ - CommonOptions: common.CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "version", - Short: "Print the version information", - Aliases: []string{"ver", "v"}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - Hidden: true, - } - options.AddCommonFlags(cmd) - - cmd.Flags().BoolVarP(&options.NoVersionCheck, "no-update", "n", false, - "disable update check") - - return cmd -} - -// Run ... -func (o *VersionOptions) Run() error { - _, err := util.ConfigDir() - if err != nil { - return err - } - - info := util.ColorInfo - - t := table.CreateTable(os.Stdout) - t.AddRow("NAME", "VERSION") - - t.AddRow(c.ZITI, info(version.GetBuildMetadata(o.Verbose))) - - o.versionPrintZitiApp(c.ZITI_CONTROLLER, &t) - o.versionPrintZitiApp(c.ZITI_PROX_C, &t) - o.versionPrintZitiApp(c.ZITI_ROUTER, &t) - o.versionPrintZitiApp(c.ZITI_TUNNEL, &t) - o.versionPrintZitiApp(c.ZITI_EDGE_TUNNEL, &t) - - t.Render() - - if !o.NoVersionCheck && !o.Verbose { - return o.versionCheck() - } - - return nil -} - -func (o *VersionOptions) getVersionFromZitiApp(zitiApp string, versionArg string) (string, error) { - if o.Verbose { - return o.GetCommandOutput("", zitiApp, versionArg, "--verbose") - } - return o.GetCommandOutput("", zitiApp, versionArg) -} - -func (o *VersionOptions) getVersionFromZitiAppMultiArg(zitiApp string) (string, error) { - var varsionArg string - if zitiApp == c.ZITI { - varsionArg = "--version" - } else { - varsionArg = "version" - } - return o.getVersionFromZitiApp(zitiApp, varsionArg) -} - -func (o *VersionOptions) versionPrintZitiApp(zitiApp string, table *table.Table) { - output, err := o.getVersionFromZitiAppMultiArg(zitiApp) - if err == nil { - table.AddRow(zitiApp, util.ColorInfo(output)) - } else { - if !isBinaryInstalled(zitiApp) { - table.AddRow(zitiApp, util.ColorWarning("not installed")) - } - } -} - -func (o *VersionOptions) versionCheck() error { - if err := o.versionCheckZitiApp(c.ZITI); err != nil { - return err - } - if err := o.versionCheckZitiApp(c.ZITI_CONTROLLER); err != nil { - return err - } - if err := o.versionCheckZitiApp(c.ZITI_PROX_C); err != nil { - return err - } - if err := o.versionCheckZitiApp(c.ZITI_ROUTER); err != nil { - return err - } - if err := o.versionCheckZitiApp(c.ZITI_TUNNEL); err != nil { - return err - } - if err := o.versionCheckZitiApp(c.ZITI_EDGE_TUNNEL); err != nil { - return err - } - return nil -} - -func (o *VersionOptions) versionCheckZitiApp(zitiApp string) error { - var currentVersion semver.Version - var newVersion semver.Version - var err error - - if !isBinaryInstalled(zitiApp) { - return nil - } - - switch zitiApp { - case c.ZITI: - newVersion, err = o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI) - case c.ZITI_CONTROLLER: - newVersion, err = o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_CONTROLLER) - case c.ZITI_PROX_C: - newVersion, err = o.getLatestGitHubReleaseVersion(c.ZITI_SDK_C_GITHUB) - case c.ZITI_ROUTER: - newVersion, err = o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_ROUTER) - case c.ZITI_TUNNEL: - newVersion, err = o.getLatestZitiAppVersion(version.GetBranch(), c.ZITI_TUNNEL) - case c.ZITI_EDGE_TUNNEL: - newVersion, err = o.getLatestGitHubReleaseVersion(c.ZITI_EDGE_TUNNEL_GITHUB) - default: - return nil - } - if err != nil { - return err - } - - app := util.ColorInfo(zitiApp) - output, err := o.getVersionFromZitiAppMultiArg(zitiApp) - if err != nil { - log.Warnf("\nAn err occurred: %s", err) - } else { - currentVersion, err = semver.ParseTolerant(output) - if err != nil { - log.Warnf("Failed to get %s version: %s\n", zitiApp, err) - return err - } - if newVersion.GT(currentVersion) { - log.Warnf("\nA new %s version is available: %s\n", app, util.ColorInfo(newVersion.String())) - - if o.BatchMode { - log.Warnf("To upgrade to this new version use: %s\n", util.ColorInfo("ziti upgrade "+zitiApp)) - } else { - message := fmt.Sprintf("Would you like to upgrade to the new %s version?", app) - if util.Confirm(message, true, "Please indicate if you would like to upgrade the binary version.") { - switch zitiApp { - case c.ZITI: - err = o.upgradeZiti() - case c.ZITI_CONTROLLER: - err = o.upgradeZitiController() - case c.ZITI_PROX_C: - err = o.upgradeZitiProxC() - case c.ZITI_ROUTER: - err = o.upgradeZitiRouter() - case c.ZITI_TUNNEL: - err = o.upgradeZitiTunnel() - case c.ZITI_EDGE_TUNNEL: - err = o.upgradeZitiEdgeTunnel() - default: - } - if err != nil { - return err - } - } - } - } - } - - return nil -} - -func (o *VersionOptions) upgradeZiti() error { - options := &UpgradeZitiOptions{ - InstallOptions: InstallOptions{ - CommonOptions: o.CommonOptions, - }, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiController() error { - options := &UpgradeZitiControllerOptions{ - InstallOptions: InstallOptions{ - CommonOptions: o.CommonOptions, - }, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiProxC() error { - options := &UpgradeZitiProxCOptions{ - InstallOptions: InstallOptions{ - CommonOptions: o.CommonOptions, - }, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiRouter() error { - options := &UpgradeZitiRouterOptions{ - InstallOptions: InstallOptions{ - CommonOptions: o.CommonOptions, - }, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiTunnel() error { - options := &UpgradeZitiTunnelOptions{ - InstallOptions: InstallOptions{ - CommonOptions: o.CommonOptions, - }, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiEdgeTunnel() error { - options := &UpgradeZitiEdgeTunnelOptions{ - InstallOptions: InstallOptions{ - CommonOptions: o.CommonOptions, - }, - } - return options.Run() -} diff --git a/ziti/cmd/table/padding.go b/ziti/cmd/table/padding.go deleted file mode 100644 index e8d5a9745..000000000 --- a/ziti/cmd/table/padding.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package table - -import ( - "math" - "strings" -) - -const ( - ALIGN_LEFT = 0 - ALIGN_CENTER = 1 - ALIGN_RIGHT = 2 -) - -func Pad(s, pad string, width int, align int) string { - switch align { - case ALIGN_CENTER: - return PadCenter(s, pad, width) - case ALIGN_RIGHT: - return PadLeft(s, pad, width) - default: - return PadRight(s, pad, width) - } -} - -func PadRight(s, pad string, width int) string { - gap := width - len(s) - if gap > 0 { - return s + strings.Repeat(pad, gap) - } - return s -} - -func PadLeft(s, pad string, width int) string { - gap := width - len(s) - if gap > 0 { - return strings.Repeat(pad, gap) + s - } - return s -} - -func PadCenter(s, pad string, width int) string { - gap := width - len(s) - if gap > 0 { - gapLeft := int(math.Ceil(float64(gap) / 2)) - gapRight := gap - gapLeft - return strings.Repeat(pad, gapLeft) + s + strings.Repeat(pad, gapRight) - } - return s -} diff --git a/ziti/cmd/table/table.go b/ziti/cmd/table/table.go deleted file mode 100644 index 52528a5cc..000000000 --- a/ziti/cmd/table/table.go +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package table - -import ( - "fmt" - "io" -) - -type Table struct { - Out io.Writer - Rows [][]string - ColumnWidths []int - ColumnAlign []int -} - -func CreateTable(out io.Writer) Table { - return Table{ - Out: out, - } -} - -// Clear removes all rows while preserving the layout -func (t *Table) Clear() { - t.Rows = [][]string{} -} - -// AddRow adds a new row to the table -func (t *Table) AddRow(col ...string) { - t.Rows = append(t.Rows, col) -} - -func (t *Table) Render() { - // lets figure out the max widths of each column - for _, row := range t.Rows { - for ci, col := range row { - l := len(col) - t.ColumnWidths = ensureArrayCanContain(t.ColumnWidths, ci) - if l > t.ColumnWidths[ci] { - t.ColumnWidths[ci] = l - } - } - } - - out := t.Out - for _, row := range t.Rows { - lastColumn := len(row) - 1 - for ci, col := range row { - if ci > 0 { - fmt.Fprint(out, " ") - } - l := t.ColumnWidths[ci] - align := t.GetColumnAlign(ci) - if ci >= lastColumn && align != ALIGN_CENTER && align != ALIGN_RIGHT { - fmt.Fprint(out, col) - } else { - fmt.Fprint(out, Pad(col, " ", l, align)) - } - } - fmt.Fprint(out, "\n") - } -} - -// SetColumnsAligns sets the alignment of the columns -func (t *Table) SetColumnsAligns(colAligns []int) { - t.ColumnAlign = colAligns -} - -// GetColumnAlign return the column alignment -func (t *Table) GetColumnAlign(i int) int { - t.ColumnAlign = ensureArrayCanContain(t.ColumnAlign, i) - return t.ColumnAlign[i] -} - -// SetColumnAlign sets the column alignment for the given column index -func (t *Table) SetColumnAlign(i int, align int) { - t.ColumnAlign = ensureArrayCanContain(t.ColumnAlign, i) - t.ColumnAlign[i] = align -} - -func ensureArrayCanContain(array []int, idx int) []int { - diff := idx + 1 - len(array) - for i := 0; i < diff; i++ { - array = append(array, 0) - } - return array -} diff --git a/ziti/cmd/templates/templater.go b/ziti/cmd/templates/templater.go index e60a141b2..9c57dea47 100644 --- a/ziti/cmd/templates/templater.go +++ b/ziti/cmd/templates/templater.go @@ -19,7 +19,6 @@ package templates import ( "bytes" "fmt" - "github.com/openziti/ziti/ziti/cmd/table" "io" "strings" "text/template" @@ -168,7 +167,7 @@ func (t *templater) cmdGroupsString(c *cobra.Command) string { if cmd.Runnable() { path := t.groupPath(cmd) //cmds = append(cmds, " "+rpad(path, maxLen - len(path))+" "+cmd.Short) - cmds = append(cmds, " "+table.PadRight(path, " ", maxLen)+" "+cmd.Short) + cmds = append(cmds, " "+padRight(path, " ", maxLen)+" "+cmd.Short) } } groups = append(groups, strings.Join(cmds, "\n")) @@ -176,6 +175,14 @@ func (t *templater) cmdGroupsString(c *cobra.Command) string { return strings.Join(groups, "\n\n") } +func padRight(s, pad string, width int) string { + gap := width - len(s) + if gap > 0 { + return s + strings.Repeat(pad, gap) + } + return s +} + func (t *templater) rootCmdName(c *cobra.Command) string { return t.rootCmd(c).CommandPath() } diff --git a/ziti/controller/root.go b/ziti/controller/root.go index 610e82963..c59827cb5 100644 --- a/ziti/controller/root.go +++ b/ziti/controller/root.go @@ -19,8 +19,9 @@ package controller import ( "fmt" "github.com/michaelquigley/pfxlog" - edgeSubCmd "github.com/openziti/ziti/controller/subcmd" "github.com/openziti/ziti/common/version" + edgeSubCmd "github.com/openziti/ziti/controller/subcmd" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/openziti/ziti/ziti/constants" "github.com/openziti/ziti/ziti/util" "github.com/sirupsen/logrus" @@ -60,7 +61,11 @@ func NewControllerCmd() *cobra.Command { cmd.AddCommand(NewRunCmd()) cmd.AddCommand(NewDeleteSessionsFromConfigCmd()) cmd.AddCommand(NewDeleteSessionsFromDbCmd()) - cmd.AddCommand(NewVersionCmd()) + + versionCmd := common.NewVersionCmd() + versionCmd.Hidden = true + versionCmd.Deprecated = "use 'ziti version' instead of 'ziti controller version'" + cmd.AddCommand(versionCmd) edgeSubCmd.AddCommands(cmd, version.GetCmdBuildInfo()) diff --git a/ziti/controller/version.go b/ziti/controller/version.go deleted file mode 100644 index 99128008e..000000000 --- a/ziti/controller/version.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package controller - -import ( - "fmt" - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -func NewVersionCmd() *cobra.Command { - return &cobra.Command{ - Use: "version", - Short: "Show component version", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.GetBuildMetadata(verbose)) - }, - } -} diff --git a/ziti/internal/log/log.go b/ziti/internal/log/log.go index 48182ec06..f94374dbf 100644 --- a/ziti/internal/log/log.go +++ b/ziti/internal/log/log.go @@ -34,10 +34,6 @@ func Infoln(msg string) { fmt.Println(msg) } -func Blank() { - fmt.Println() -} - func Warnf(msg string, args ...interface{}) { Warn(fmt.Sprintf(msg, args...)) } @@ -46,14 +42,6 @@ func Warn(msg string) { color.Yellow(msg) } -func Errorf(msg string, args ...interface{}) { - Error(fmt.Sprintf(msg, args...)) -} - -func Error(msg string) { - color.Red(msg) -} - func Fatalf(msg string, args ...interface{}) { Fatal(fmt.Sprintf(msg, args...)) } diff --git a/ziti/router/root.go b/ziti/router/root.go index 3a9c6f66d..0c4ee9aa6 100644 --- a/ziti/router/root.go +++ b/ziti/router/root.go @@ -19,6 +19,7 @@ package router import ( "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/openziti/ziti/ziti/constants" "github.com/openziti/ziti/ziti/util" "github.com/sirupsen/logrus" @@ -58,7 +59,11 @@ func NewRouterCmd() *cobra.Command { routerCmd.AddCommand(NewRunCmd()) routerCmd.AddCommand(NewEnrollGwCmd()) - routerCmd.AddCommand(NewVersionCmd()) + + versionCmd := common.NewVersionCmd() + versionCmd.Hidden = true + versionCmd.Deprecated = "use 'ziti version' instead of 'ziti router version'" + routerCmd.AddCommand(versionCmd) return routerCmd } diff --git a/ziti/router/version.go b/ziti/router/version.go deleted file mode 100644 index 8dad7e7e1..000000000 --- a/ziti/router/version.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package router - -import ( - "fmt" - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -func NewVersionCmd() *cobra.Command { - return &cobra.Command{ - Use: "version", - Short: "Show component version", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.GetBuildMetadata(verbose)) - }, - } -} diff --git a/ziti/tunnel/root.go b/ziti/tunnel/root.go index 8a21abf32..3b4389544 100644 --- a/ziti/tunnel/root.go +++ b/ziti/tunnel/root.go @@ -29,7 +29,6 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/agent" "github.com/openziti/sdk-golang/ziti" - "github.com/openziti/ziti/common/enrollment" "github.com/openziti/ziti/common/version" "github.com/openziti/ziti/tunnel" "github.com/openziti/ziti/tunnel/dns" @@ -70,12 +69,14 @@ func NewTunnelCmd(standalone bool) *cobra.Command { root.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)") root.PersistentFlags().StringVar(&cliAgentAlias, "cli-agent-alias", "", "Alias which can be used by ziti agent commands to find this instance") - p := common.NewOptionsProvider(os.Stdout, os.Stderr) - root.AddCommand(enrollment.NewEnrollCommand(p)) root.AddCommand(NewHostCmd()) root.AddCommand(NewProxyCmd()) root.AddCommand(hostSpecificCmds...) - root.AddCommand(NewVersionCmd()) + + versionCmd := common.NewVersionCmd() + versionCmd.Hidden = true + versionCmd.Deprecated = "use 'ziti version' instead of 'ziti router version'" + root.AddCommand(versionCmd) return root } @@ -86,13 +87,6 @@ var cliAgentEnabled bool var cliAgentAddr string var cliAgentAlias string -func Execute() { - if err := NewTunnelCmd(true).Execute(); err != nil { - pfxlog.Logger().Errorf("error: %s", err) - os.Exit(1) - } -} - func rootPreRun(cmd *cobra.Command, _ []string) { verbose, err := cmd.Flags().GetBool("verbose") if err != nil { diff --git a/ziti/util/colors.go b/ziti/util/colors.go deleted file mode 100644 index 1e817ab60..000000000 --- a/ziti/util/colors.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import "github.com/fatih/color" - -var ColorInfo = color.New(color.FgGreen).SprintFunc() -var ColorStatus = color.New(color.FgBlue).SprintFunc() -var ColorWarning = color.New(color.FgYellow).SprintFunc() -var ColorError = color.New(color.FgRed).SprintFunc() diff --git a/ziti/util/commands.go b/ziti/util/commands.go index ac9d1c71e..0baebbf88 100644 --- a/ziti/util/commands.go +++ b/ziti/util/commands.go @@ -18,22 +18,10 @@ package util import ( "github.com/spf13/cobra" - "os" ) -const ( - CONFIGFILENAME = "config" -) - -func PathWithBinary() string { - path := os.Getenv("PATH") - binDir, _ := BinaryLocation() - return binDir + string(os.PathListSeparator) + path -} - // NewEmptyParentCmd creates a new cobra command with no parent func NewEmptyParentCmd(name string, description string) *cobra.Command { - return &cobra.Command{ Use: name, Short: description, diff --git a/ziti/util/dirs.go b/ziti/util/dirs.go index 37d2e341c..42ac2ec26 100644 --- a/ziti/util/dirs.go +++ b/ziti/util/dirs.go @@ -17,8 +17,6 @@ package util import ( - "encoding/json" - "fmt" "os" "path/filepath" "runtime" @@ -54,32 +52,6 @@ func ConfigDir() (string, error) { return path, nil } -func ZitiAppConfigDir(zitiApp string) (string, error) { - h, err := ConfigDir() - if err != nil { - return "", err - } - path := filepath.Join(h, zitiApp) - err = os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - -func CacheDir() (string, error) { - h, err := ConfigDir() - if err != nil { - return "", err - } - path := filepath.Join(h, "cache") - err = os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - func EnvironmentsDir() (string, error) { h, err := ConfigDir() if err != nil { @@ -93,25 +65,6 @@ func EnvironmentsDir() (string, error) { return path, nil } -func NewEnvironmentDir(envName string) (string, error) { - h, err := EnvironmentsDir() - if err != nil { - return "", err - } - path := filepath.Join(h, envName) - - _, err = os.Stat(path) - if err == nil { - return "", fmt.Errorf("Environment dir (%s) already exists", envName) - } - - err = os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - func PKIRootDir() (string, error) { var path string var err error @@ -132,82 +85,3 @@ func PKIRootDir() (string, error) { } return path, nil } - -func BinaryLocation() (string, error) { - h, err := ConfigDir() - if err != nil { - return "", err - } - path := filepath.Join(h, "bin") - err = os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - -// TerraformProviderBinaryLocation provides the proper location to place a Terraform provider based on the currently running OS. -// In Mac/Linux, it's `~/.terraform.d/plugins` and on Windows it's `%APPDATA%\terraform.d\plugins` -func TerraformProviderBinaryLocation() (string, error) { - var path string - h := HomeDir() - if runtime.GOOS == "windows" { - h = os.Getenv("APPDATA") - if h == "" { - return "", fmt.Errorf("APPDATA env var missing; install of Terraform provider cannot proceed") - } - path = filepath.Join(h, "terraform.d/plugins") - } else { - path = filepath.Join(h, ".terraform.d/plugins") - } - err := os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - -// WriteZitiAppConfigFile writes out the config file data for the given Ziti application to the appropriate config file -func WriteZitiAppConfigFile(zitiApp string, configData interface{}) error { - return WriteZitiAppFile(zitiApp, "config", configData) -} - -// WriteZitiAppFile writes application data (config, session, preferences, etc) to an appropriate location -func WriteZitiAppFile(zitiApp string, fileType string, appData interface{}) error { - configDir, err := ZitiAppConfigDir(zitiApp) - if err != nil { - return err - } - filePath := filepath.Join(configDir, fileType+".json") - - data, err := json.MarshalIndent(appData, "", " ") - if err != nil { - return err - } - - return os.WriteFile(filePath, data, 0600) -} - -// ReadZitiAppConfigFile reads in the config file data for the given Ziti application from an appropriate location -func ReadZitiAppConfigFile(zitiApp string, configData interface{}) error { - return ReadZitiAppFile(zitiApp, "config", configData) -} - -// ReadZitiAppFile reads application data (config, session, preferences, etc) for the given Ziti application from an appropriate location -func ReadZitiAppFile(zitiApp string, fileType string, configData interface{}) error { - configDir, err := ZitiAppConfigDir(zitiApp) - if err != nil { - return err - } - - filePath := filepath.Join(configDir, fileType+".json") - - data, err := os.ReadFile(filePath) - if err != nil { - return err - } - - err = json.Unmarshal(data, configData) - - return err -} diff --git a/ziti/util/files.go b/ziti/util/files.go index 305f50c00..e36b4e0db 100644 --- a/ziti/util/files.go +++ b/ziti/util/files.go @@ -17,150 +17,14 @@ package util import ( - "fmt" "io" "os" - "path/filepath" - "strconv" ) const ( DefaultWritePermissions = 0760 ) -func FileExists(path string) (bool, error) { - _, err := os.Stat(path) - if err == nil { - return true, nil - } - if os.IsNotExist(err) { - return false, nil - } - return true, err -} - -func IsEmpty(name string) (bool, error) { - f, err := os.Open(name) - if err != nil { - return false, err - } - defer f.Close() - - _, err = f.Readdirnames(1) // Or f.Readdir(1) - if err == io.EOF { - return true, nil - } - return false, err // Either not empty or error, suits both cases -} - -// CreateUniqueDirectory creates a new directory but if the combination of dir and name exists -// then append a number until a unique name is found -func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error) { - for i := 0; i < maximumAttempts; i++ { - n := name - if i > 0 { - n += strconv.Itoa(i) - } - p := filepath.Join(dir, n) - exists, err := FileExists(p) - if err != nil { - return p, err - } - if !exists { - err := os.MkdirAll(p, DefaultWritePermissions) - if err != nil { - return "", fmt.Errorf("Failed to create directory %s due to %s", p, err) - } - return p, nil - } - } - return "", fmt.Errorf("Could not create a unique file in %s starting with %s after %d attempts", dir, name, maximumAttempts) -} - -func RenameDir(src string, dst string, force bool) (err error) { - err = CopyDir(src, dst, force) - if err != nil { - return fmt.Errorf("failed to copy source dir %s to %s: %s", src, dst, err) - } - err = os.RemoveAll(src) - if err != nil { - return fmt.Errorf("failed to cleanup source dir %s: %s", src, err) - } - return nil -} - -func RenameFile(src string, dst string) (err error) { - err = CopyFile(src, dst) - if err != nil { - return fmt.Errorf("failed to copy source file %s to %s: %s", src, dst, err) - } - err = os.RemoveAll(src) - if err != nil { - return fmt.Errorf("failed to cleanup source file %s: %s", src, err) - } - return nil -} - -// credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04 -func CopyDir(src string, dst string, force bool) (err error) { - src = filepath.Clean(src) - dst = filepath.Clean(dst) - - si, err := os.Stat(src) - if err != nil { - return err - } - if !si.IsDir() { - return fmt.Errorf("source is not a directory") - } - - _, err = os.Stat(dst) - if err != nil && !os.IsNotExist(err) { - return - } - if err == nil { - if force { - os.RemoveAll(dst) - } else { - return fmt.Errorf("destination already exists") - } - } - - err = os.MkdirAll(dst, si.Mode()) - if err != nil { - return - } - - entries, err := os.ReadDir(src) - if err != nil { - return - } - - for _, entry := range entries { - srcPath := filepath.Join(src, entry.Name()) - dstPath := filepath.Join(dst, entry.Name()) - - if entry.IsDir() { - err = CopyDir(srcPath, dstPath, force) - if err != nil { - return - } - } else { - // Skip symlinks. - if entry.Type()&os.ModeSymlink != 0 { - continue - } - - err = CopyFile(srcPath, dstPath) - if err != nil { - return - } - } - } - - return -} - // credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04 func CopyFile(src, dst string) (err error) { in, err := os.Open(src) @@ -200,65 +64,3 @@ func CopyFile(src, dst string) (err error) { return } - -// CopyDirOverwrite copies from the source dir to the destination dir overwriting files along the way -func CopyDirOverwrite(src string, dst string) (err error) { - src = filepath.Clean(src) - dst = filepath.Clean(dst) - - si, err := os.Stat(src) - if err != nil { - return err - } - if !si.IsDir() { - return fmt.Errorf("source is not a directory") - } - - _, err = os.Stat(dst) - if err != nil && !os.IsNotExist(err) { - return - } - - err = os.MkdirAll(dst, si.Mode()) - if err != nil { - return - } - - entries, err := os.ReadDir(src) - if err != nil { - return - } - - for _, entry := range entries { - srcPath := filepath.Join(src, entry.Name()) - dstPath := filepath.Join(dst, entry.Name()) - - if entry.IsDir() { - err = CopyDirOverwrite(srcPath, dstPath) - if err != nil { - return - } - } else { - // Skip symlinks. - if entry.Type()&os.ModeSymlink != 0 { - continue - } - - err = CopyFile(srcPath, dstPath) - if err != nil { - return - } - } - } - return -} - -// loads a file -func LoadBytes(dir, name string) ([]byte, error) { - path := filepath.Join(dir, name) // relative path - bytes, err := os.ReadFile(path) - if err != nil { - return nil, fmt.Errorf("error loading file %s in directory %s, %v", name, dir, err) - } - return bytes, nil -} diff --git a/ziti/util/pickers.go b/ziti/util/pickers.go index 2099bfb05..a11610319 100644 --- a/ziti/util/pickers.go +++ b/ziti/util/pickers.go @@ -17,11 +17,6 @@ package util import ( - "fmt" - "github.com/openziti/ziti/ziti/internal/log" - "sort" - "strings" - "gopkg.in/AlecAivazis/survey.v1" ) @@ -42,19 +37,6 @@ func PickValue(message string, defaultValue string, required bool) (string, erro return answer, nil } -func PickPassword(message string) (string, error) { - answer := "" - prompt := &survey.Password{ - Message: message, - } - validator := survey.Required - err := survey.AskOne(prompt, &answer, validator) - if err != nil { - return "", err - } - return strings.TrimSpace(answer), nil -} - func PickNameWithDefault(names []string, message string, defaultValue string) (string, error) { name := "" if len(names) == 0 { @@ -75,91 +57,6 @@ func PickNameWithDefault(names []string, message string, defaultValue string) (s return name, nil } -func PickRequiredNameWithDefault(names []string, message string, defaultValue string) (string, error) { - name := "" - if len(names) == 0 { - return "", nil - } else if len(names) == 1 { - name = names[0] - } else { - prompt := &survey.Select{ - Message: message, - Options: names, - Default: defaultValue, - } - err := survey.AskOne(prompt, &name, survey.Required) - if err != nil { - return "", err - } - } - return name, nil -} - func PickName(names []string, message string) (string, error) { return PickNameWithDefault(names, message, "") } - -func PickNames(names []string, message string) ([]string, error) { - picked := []string{} - if len(names) == 0 { - return picked, nil - } else if len(names) == 1 { - return names, nil - } else { - prompt := &survey.MultiSelect{ - Message: message, - Options: names, - } - err := survey.AskOne(prompt, &picked, nil) - if err != nil { - return picked, err - } - } - return picked, nil -} - -// SelectNamesWithFilter selects from a list of names with a given filter. Optionally selecting them all -func SelectNamesWithFilter(names []string, message string, selectAll bool, filter string) ([]string, error) { - filtered := []string{} - for _, name := range names { - if filter == "" || strings.Contains(name, filter) { - filtered = append(filtered, name) - } - } - if len(filtered) == 0 { - return nil, fmt.Errorf("No names match filter: %s", filter) - } - return SelectNames(filtered, message, selectAll) -} - -// SelectNames select which names from the list should be chosen -func SelectNames(names []string, message string, selectAll bool) ([]string, error) { - answer := []string{} - if len(names) == 0 { - return answer, fmt.Errorf("No names to choose from!") - } - sort.Strings(names) - - prompt := &survey.MultiSelect{ - Message: message, - Options: names, - } - if selectAll { - prompt.Default = names - } - err := survey.AskOne(prompt, &answer, nil) - return answer, err -} - -// Confirm prompts the user to confirm something -func Confirm(message string, defaultValue bool, help string) bool { - answer := defaultValue - prompt := &survey.Confirm{ - Message: message, - Default: defaultValue, - Help: help, - } - _ = survey.AskOne(prompt, &answer, nil) - log.Blank() - return answer -} diff --git a/ziti/util/rest.go b/ziti/util/rest.go index 5919e01d8..d88319aa5 100644 --- a/ziti/util/rest.go +++ b/ziti/util/rest.go @@ -17,66 +17,23 @@ package util import ( - "archive/tar" "bytes" - "compress/gzip" "encoding/json" "fmt" "github.com/Jeffail/gabs" - "github.com/blang/semver" openApiRuntime "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" "github.com/openziti/edge-api/rest_management_api_client" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/common/version" fabric_rest_client "github.com/openziti/ziti/controller/rest_client" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - c "github.com/openziti/ziti/ziti/constants" "gopkg.in/resty.v1" "io" "net/http" "net/url" - "os" "path" - "path/filepath" - "runtime" - "strconv" - "strings" - "text/template" "time" ) -// Download a file from the given URL -func DownloadFile(filepath string, url string) (err error) { - // Create the file - out, err := os.Create(filepath) - if err != nil { - return err - } - defer out.Close() - - // Get the data - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - // Writer the body to file - _, err = io.Copy(out, resp.Body) - if err != nil { - return err - } - - // make it executable - err = os.Chmod(filepath, 0755) - - if err != nil { - return err - } - return nil -} - // Use a 2-second timeout with a retry count of 5 func NewClient() *resty.Client { return resty. @@ -86,316 +43,6 @@ func NewClient() *resty.Client { SetRedirectPolicy(resty.FlexibleRedirectPolicy(15)) } -func getRequest(verbose bool) *resty.Request { - return NewClient(). - SetDebug(verbose). - R() -} - -// DownloadArtifactoryFile will download a file from the given Artifactory URL -func DownloadArtifactoryFile(url string, filepath string) (err error) { - fullUrl := "https://netfoundry.jfrog.io/netfoundry/" + url - resp, err := getRequest(false). - SetHeader("X-JFrog-Art-Api", cmdhelper.JFrogAPIKey()). - SetOutput(filepath). - Get(fullUrl) - - if err != nil { - return fmt.Errorf("unable to download '%s', %s", url, err) - } - - if resp.IsError() { - return fmt.Errorf("unable to download file, error HTTP status code [%d] returned for url [%s]", resp.StatusCode(), fullUrl) - } - - return nil -} - -// Used to parse the 'get-object-tagging' response -type Data struct { - TagSet []struct { - Value string `json:"Value"` - Key string `json:"Key"` - } -} - -// Used to parse the '/api/versions' response from Artifactory -type ArtifactoryVersionsData struct { - Version string `json:"version"` - Artifacts []struct { - } -} - -func GetLatestVersionFromArtifactory(verbose bool, staging bool, branch string, appName string) (semver.Version, error) { - resp, err := getRequest(verbose). - SetQueryParams(map[string]string{ - // "key": "value", - }). - SetHeader("X-JFrog-Art-Api", cmdhelper.JFrogAPIKey()). - SetResult(&ArtifactoryVersionsData{}). - Get("https://netfoundry.jfrog.io/netfoundry/api/versions/" + GetArtifactoryPath(staging, appName, branch)) - - if err != nil { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s'; %s", appName, err) - } - - if resp.StatusCode() == http.StatusNotFound { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on branch '%s'; Not Found", appName, branch) - } - if resp.StatusCode() != http.StatusOK { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on branch '%s'; %s", appName, branch, resp.Status()) - } - - result := *resp.Result().(*ArtifactoryVersionsData) - - return semver.Make(strings.TrimPrefix(result.Version, "v")) -} - -// Used to parse the '/api/search/aql' response from Artifactory -type AQLResult struct { - Repo string - Path string - Name string - Type string - Size int - Created string - CreatedBy string - Modified string - ModifiedBy string - Updated string - Properties []struct { - Key string - Value string - } -} -type ArtifactoryAQLData struct { - Results []AQLResult -} - -type AQLVars struct { - SemverMajor string - SemverMaxMinor string - SemverMinMinor string - App string - Arch string - OS string -} - -func GetLatestSemanticVersionFromArtifactory(verbose bool, staging bool, branch string, appName string, versionWildcard string) (semver.Version, error) { - sv := strings.Split(versionWildcard, ".") - minor, err := strconv.Atoi(sv[1]) - if err != nil { - panic(err) - } - maxMinor := minor + 1 - aqlVars := AQLVars{sv[0], strconv.Itoa(maxMinor), sv[1], appName, runtime.GOARCH, runtime.GOOS} - tpl, err := template.New("aql").Parse("items.find( { \"@build.number\":{\"$lt\":\"{{ .SemverMajor}}.{{ .SemverMaxMinor}}.*\"}, \"@build.number\":{\"$gt\":\"{{ .SemverMajor}}.{{ .SemverMinMinor}}.*\"}, \"repo\":{\"$match\":\"ziti-release\"}, \"path\":{\"$match\":\"{{ .App}}/{{ .Arch}}/{{ .OS}}/*\"} } ).include(\"@build.number\") ") - if err != nil { - panic(err) - } - var body bytes.Buffer - err = tpl.Execute(&body, aqlVars) - if err != nil { - panic(err) - } - resp, err := getRequest(verbose). - SetHeader("X-JFrog-Art-Api", cmdhelper.JFrogAPIKey()). - SetHeader("Content-Type", "text/plain"). - SetBody(body.String()). - SetResult(&ArtifactoryAQLData{}). - Post("https://netfoundry.jfrog.io/netfoundry/api/search/aql") - - if err != nil { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s'; %s", appName, err) - } - - if resp.StatusCode() == http.StatusNotFound { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on branch '%s'; Not Found", appName, branch) - } - if resp.StatusCode() != http.StatusOK { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on branch '%s'; %s", appName, branch, resp.Status()) - } - - aqlData := (*resp.Result().(*ArtifactoryAQLData)) - - latestSemVer, _ := semver.Make("0.0.0") - - for _, result := range aqlData.Results { - sv, err := semver.Make(result.Properties[0].Value) - if err != nil { - panic(err) - } - if sv.GT(latestSemVer) { - latestSemVer = sv - } - } - - return latestSemVer, nil -} - -func GetLatestTerraformProviderVersionFromArtifactory(branch string, provider string) (semver.Version, error) { - repoUrl := "https://netfoundry.jfrog.io/netfoundry/api/versions/" + GetTerraformProviderArtifactoryPath(provider, branch) - resp, err := getRequest(false). - SetQueryParams(map[string]string{ - // "key": "value", - }). - SetHeader("X-JFrog-Art-Api", cmdhelper.JFrogAPIKey()). - SetResult(&ArtifactoryVersionsData{}). - Get(repoUrl) - - if err != nil { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on repo url %s; %s", provider, repoUrl, err) - } - - if resp.StatusCode() == http.StatusNotFound { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on branch '%s' on repo url %s; Not Found", provider, branch, repoUrl) - } - if resp.StatusCode() != http.StatusOK { - return semver.Version{}, fmt.Errorf("unable to get latest version for '%s' on branch '%s' on repo url %s; %s", provider, branch, repoUrl, resp.Status()) - } - - result := (*resp.Result().(*ArtifactoryVersionsData)) - - return semver.Make(strings.TrimPrefix(result.Version, "v")) -} - -// Used to parse the '/api/storage' response from Artifactory -type ArtifactoryStorageChildrenData struct { - URI string `json:"uri"` - Folder bool `json:"folder"` -} -type ArtifactoryStorageData struct { - Repo string `json:"repo"` - Path string `json:"path"` - Created string `json:"created"` - LastModified string `json:"lastModified"` - LastUpdated string `json:"lastUpdated"` - Children []ArtifactoryStorageChildrenData `json:"children"` - URI string `json:"uri"` -} - -func GetCurrentSnapshotListFromArtifactory(verbose bool) ([]ArtifactoryStorageChildrenData, error) { - resp, err := getRequest(verbose). - SetHeader("X-JFrog-Art-Api", cmdhelper.JFrogAPIKey()). - SetResult(&ArtifactoryStorageData{}). - Get("https://netfoundry.jfrog.io/netfoundry/api/storage/ziti-snapshot/") - - if err != nil { - return nil, fmt.Errorf("unable to get list of branches; %s", err) - } - - result := (*resp.Result().(*ArtifactoryStorageData)) - - return result.Children, nil -} - -func GetArtifactoryPath(staging bool, appName string, branch string) string { - if branch == "" { - branch = version.GetBranch() - } - - arch := runtime.GOARCH - os := runtime.GOOS - - var path string - if staging { - path = "ziti-staging/" - } else if branch == "main" { - path = "ziti-release/" - } else { - path = "ziti-snapshot/" + branch + "/" - } - // Special-case the source-repo when dealing with ziti-prox-c - if branch == "main" && appName == c.ZITI_PROX_C { - path = "ziti-staging/" - } - - path += appName + "/" + arch + "/" + os - - return path -} - -func GetTerraformProviderArtifactoryPath(provider string, branch string) string { - if branch == "" { - branch = "master" - } - var path string - if branch == "master" { - path = c.TERRAFORM_PROVIDER_PREFIX + provider + "-release/" - } else { - path = c.TERRAFORM_PROVIDER_PREFIX + provider + "-snapshot/" + branch + "/" - } - path += c.TERRAFORM_PROVIDER_PREFIX + provider + "/" + version.GetArchitecture() + "/" + version.GetOS() - - return path -} - -// untargz a tarball to a target, from -// http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzip -func UnTargz(tarball, target string, onlyFiles []string) error { - zreader, err := os.Open(tarball) - if err != nil { - return err - } - defer zreader.Close() - - reader, err := gzip.NewReader(zreader) - defer func() { - _ = reader.Close() - }() - - if err != nil { - panic(err) - } - - tarReader := tar.NewReader(reader) - - for { - inkey := false - header, err := tarReader.Next() - if err == io.EOF { - break - } else if err != nil { - return err - } - - for _, value := range onlyFiles { - if value == "*" || value == path.Base(header.Name) { - inkey = true - break - } - } - - if !inkey { - continue - } - - path := filepath.Join(target, path.Base(header.Name)) - info := header.FileInfo() - if info.IsDir() { - if err = os.MkdirAll(path, info.Mode()); err != nil { - return err - } - continue - } else { - if err = os.Remove(path); err != nil { - fmt.Printf("error removing [%s] (%v)", path, err) - } - } - - file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()) - if err != nil { - return err - } - defer file.Close() - _, err = io.Copy(file, tarReader) - if err != nil { - return err - } - } - return nil -} - func PrettyPrintResponse(resp *resty.Response) string { out := resp.String() var prettyJSON bytes.Buffer diff --git a/ziti/util/session.go b/ziti/util/session.go deleted file mode 100644 index 3ff612507..000000000 --- a/ziti/util/session.go +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "fmt" -) - -const ( - appName = "ziti" - sessionType = "edge-controller-session" -) - -// Session stores configuration options for the CLI -type Session struct { - Host string - Token string - Cert string -} - -func (session *Session) GetBaseUrl() string { - return session.Host -} - -func (session *Session) GetCert() string { - return session.Cert -} - -func (session *Session) GetToken() string { - return session.Token -} - -// Persist writes out the Ziti CLI session file -func (session *Session) Persist() error { - return WriteZitiAppFile(appName, sessionType, session) -} - -// Load reads in the Ziti CLI session file -func (session *Session) Load() error { - err := ReadZitiAppFile(appName, sessionType, session) - if err != nil { - return fmt.Errorf("unable to load Ziti CLI configuration. Exiting. Error: %v", err) - } - if session.Host == "" { - return fmt.Errorf("host not specified in cli config file. Exiting") - } - return nil -} - -func (session *Session) String() string { - return fmt.Sprintf("session Host: %v, Token: %s, Cert: %s", session.Host, session.Token, session.Cert) -} diff --git a/ziti/util/strings.go b/ziti/util/strings.go deleted file mode 100644 index 6a2a52716..000000000 --- a/ziti/util/strings.go +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "regexp" - "sort" - "strings" -) - -// RegexpSplit splits a string into an array using the regexSep as a separator -func RegexpSplit(text string, regexSeperator string) []string { - reg := regexp.MustCompile(regexSeperator) - indexes := reg.FindAllStringIndex(text, -1) - lastIdx := 0 - result := make([]string, len(indexes)+1) - for i, element := range indexes { - result[i] = text[lastIdx:element[0]] - lastIdx = element[1] - } - result[len(indexes)] = text[lastIdx:] - return result -} - -// StringIndexes returns all the indices where the value occurs in the given string -func StringIndexes(text string, value string) []int { - answer := []int{} - t := text - valueLen := len(value) - offset := 0 - for { - idx := strings.Index(t, value) - if idx < 0 { - break - } - answer = append(answer, idx+offset) - offset += valueLen - t = t[idx+valueLen:] - } - return answer -} - -func StringArrayIndex(array []string, value string) int { - for i, v := range array { - if v == value { - return i - } - } - return -1 -} - -// FirstNotEmptyString returns the first non empty string or the empty string if none can be found -func FirstNotEmptyString(values ...string) string { - for _, v := range values { - if v != "" { - return v - } - } - return "" -} - -// SortedMapKeys returns the sorted keys of the given map -func SortedMapKeys(m map[string]string) []string { - answer := make([]string, 0, len(m)) - for k := range m { - answer = append(answer, k) - } - sort.Strings(answer) - return answer -} - -func ReverseStrings(a []string) { - for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 { - a[i], a[j] = a[j], a[i] - } -} - -// StringArrayToLower returns a string slice with all the values converted to lower case -func StringArrayToLower(values []string) []string { - answer := make([]string, 0, len(values)) - for _, v := range values { - answer = append(answer, strings.ToLower(v)) - } - return answer -} - -// StringMatches returns true if the given text matches the includes/excludes lists -func StringMatchesAny(text string, includes []string, excludes []string) bool { - for _, x := range excludes { - if StringMatchesPattern(text, x) { - return false - } - } - if len(includes) == 0 { - return true - } - for _, inc := range includes { - if StringMatchesPattern(text, inc) { - return true - } - } - return false -} - -// StringMatchesPattern returns true if the given text matches the includes/excludes lists -func StringMatchesPattern(text string, pattern string) bool { - if pattern == "*" { - return true - } - if strings.HasSuffix(pattern, "*") { - prefix := strings.TrimSuffix(pattern, "*") - return strings.HasPrefix(text, prefix) - } - return text == pattern -} diff --git a/ziti/util/suggestions.go b/ziti/util/suggestions.go deleted file mode 100644 index 5d223ff32..000000000 --- a/ziti/util/suggestions.go +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "fmt" - "sort" - "strings" -) - -const ( - DefaultSuggestionsMinimumDistance = 2 -) - -func InvalidOptionError(option string, value string, err error) error { - return InvalidOptionf(option, value, "%s", err) -} - -func InvalidOptionf(option string, value string, message string, a ...interface{}) error { - text := fmt.Sprintf(message, a...) - return fmt.Errorf("Invalid option: --%s %s\n%s", option, value, text) -} - -func MissingOption(name string) error { - return fmt.Errorf("Missing option: --%s", name) -} - -func InvalidOption(name string, value string, values []string) error { - suggestions := SuggestionsFor(value, values, DefaultSuggestionsMinimumDistance) - if len(suggestions) > 0 { - if len(suggestions) == 1 { - return InvalidOptionf(name, value, "Did you mean: --%s %s", name, suggestions[0]) - } - return InvalidOptionf(name, value, "Did you mean one of: %s", strings.Join(suggestions, ", ")) - } - sort.Strings(values) - return InvalidOptionf(name, value, "Possible values: %s", strings.Join(values, ", ")) -} - -func InvalidArg(value string, values []string) error { - suggestions := SuggestionsFor(value, values, DefaultSuggestionsMinimumDistance) - if len(suggestions) > 0 { - if len(suggestions) == 1 { - return InvalidArgf(value, "Did you mean: %s", suggestions[0]) - } - return InvalidArgf(value, "Did you mean one of: %s", strings.Join(suggestions, ", ")) - } - sort.Strings(values) - return InvalidArgf(value, "Possible values: %s", strings.Join(values, ", ")) -} - -func InvalidArgError(value string, err error) error { - return InvalidArgf(value, "%s", err) -} - -func InvalidArgf(value string, message string, a ...interface{}) error { - text := fmt.Sprintf(message, a...) - return fmt.Errorf("Invalid argument: %s\n%s", value, text) -} - -func SuggestionsFor(typedName string, values []string, suggestionsMinimumDistance int, explicitSuggestions ...string) []string { - suggestions := []string{} - for _, value := range values { - levenshteinDistance := ld(typedName, value, true) - suggestByLevenshtein := levenshteinDistance <= suggestionsMinimumDistance - suggestByPrefix := strings.HasPrefix(strings.ToLower(value), strings.ToLower(typedName)) - if suggestByLevenshtein || suggestByPrefix { - suggestions = append(suggestions, value) - } - for _, explicitSuggestion := range explicitSuggestions { - if strings.EqualFold(typedName, explicitSuggestion) { - suggestions = append(suggestions, value) - } - } - } - return suggestions -} - -// ld compares two strings and returns the levenshtein distance between them. -// -// this was copied from vendor/github.com/spf13/cobra/command.go as its not public -func ld(s, t string, ignoreCase bool) int { - if ignoreCase { - s = strings.ToLower(s) - t = strings.ToLower(t) - } - d := make([][]int, len(s)+1) - for i := range d { - d[i] = make([]int, len(t)+1) - } - for i := range d { - d[i][0] = i - } - for j := range d[0] { - d[0][j] = j - } - for j := 1; j <= len(t); j++ { - for i := 1; i <= len(s); i++ { - if s[i-1] == t[j-1] { - d[i][j] = d[i-1][j-1] - } else { - min := d[i-1][j] - if d[i][j-1] < min { - min = d[i][j-1] - } - if d[i-1][j-1] < min { - min = d[i-1][j-1] - } - d[i][j] = min + 1 - } - } - - } - return d[len(s)][len(t)] -} diff --git a/zititest/go.mod b/zititest/go.mod index 392488ed7..b3be62506 100644 --- a/zititest/go.mod +++ b/zititest/go.mod @@ -13,14 +13,14 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/michaelquigley/pfxlog v0.6.10 github.com/openziti/agent v1.0.16 - github.com/openziti/channel/v2 v2.0.122 + github.com/openziti/channel/v2 v2.0.125 github.com/openziti/edge-api v0.26.14 github.com/openziti/fablab v0.5.42 - github.com/openziti/foundation/v2 v2.0.40 - github.com/openziti/identity v1.0.73 + github.com/openziti/foundation/v2 v2.0.42 + github.com/openziti/identity v1.0.74 github.com/openziti/sdk-golang v0.23.15 - github.com/openziti/storage v0.2.33 - github.com/openziti/transport/v2 v2.0.125 + github.com/openziti/storage v0.2.34 + github.com/openziti/transport/v2 v2.0.128 github.com/openziti/ziti v0.28.3 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 @@ -137,8 +137,8 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openziti/dilithium v0.3.3 // indirect github.com/openziti/jwks v1.0.3 // indirect - github.com/openziti/metrics v1.2.48 // indirect - github.com/openziti/runzmd v1.0.41 // indirect + github.com/openziti/metrics v1.2.49 // indirect + github.com/openziti/runzmd v1.0.42 // indirect github.com/openziti/secretstream v0.1.18 // indirect github.com/openziti/x509-claims v1.0.3 // indirect github.com/openziti/xweb/v2 v2.1.0 // indirect diff --git a/zititest/go.sum b/zititest/go.sum index 00662888d..c1b71b784 100644 --- a/zititest/go.sum +++ b/zititest/go.sum @@ -590,32 +590,32 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openziti/agent v1.0.16 h1:9Saji+8hFE1NpzP2XzDhsVJbCrDlhixoLHfOpFt5Z+U= github.com/openziti/agent v1.0.16/go.mod h1:zfm53+PVWoGFzjGGgQdKby5749G6VRYHe+eQJmoVKy4= -github.com/openziti/channel/v2 v2.0.122 h1:MPALuLUuTsW2QJzaoRkrP/wGqhIeWtSsrnxt2Ept5SU= -github.com/openziti/channel/v2 v2.0.122/go.mod h1:n4r/pWTFYJy98hEtf4ATYVHU70OePjoM8JJzrIvXvZg= +github.com/openziti/channel/v2 v2.0.125 h1:VRF2m2AHH1ZAbY4pJct8x71NO/jeqHqF3ahDtLwLwTU= +github.com/openziti/channel/v2 v2.0.125/go.mod h1:+Dqcg/xJICPi/E+RnWE//ua2O6xdQg0/KhA3oxjMRYI= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= github.com/openziti/edge-api v0.26.14 h1:BpxKavDVdykOY7GSdKXi7klv9Im4vw7bTMujz3wFE1Q= github.com/openziti/edge-api v0.26.14/go.mod h1:aTRqB9J/6ISbw9+YWjzD0tvWAXY98m8yWcbiGNqAQTU= github.com/openziti/fablab v0.5.42 h1:vENJKfEba2T4sSLwlKDL/IzBYfY8iHnhc4umf6IESiY= github.com/openziti/fablab v0.5.42/go.mod h1:HDT06y1QX8kO8ZQrgHvZmJsvc8iRybESGtlDLDII4ks= -github.com/openziti/foundation/v2 v2.0.40 h1:8oXL77egZjnQuKuxPTHiBOh+X/I2mSJefIbnLSv8rFI= -github.com/openziti/foundation/v2 v2.0.40/go.mod h1:38RikdtjvzDUALm3jT3PSOrU0bHCleRty6bHGdfFyUI= -github.com/openziti/identity v1.0.73 h1:F1iF/rDQYfDIv4ktqBYwK/0C5Ra/7y92Z5Umrw4c4fk= -github.com/openziti/identity v1.0.73/go.mod h1:SKcvyjTlSIpxJuhYLjayJgB800EJ/nO4Y/Lhh77NE9A= +github.com/openziti/foundation/v2 v2.0.42 h1:cXZFql3xY92AHPCk/wqIoSUX9EHgegwPrs5bhFE2jNg= +github.com/openziti/foundation/v2 v2.0.42/go.mod h1:a+REYnK9bZ2cvmOiuBLp57MjQqn3U5cHhJcDMLMO8rE= +github.com/openziti/identity v1.0.74 h1:BUCKjGXIdoEHLL1+kO/smitZvGwP9dOUpjVEJFtSSBc= +github.com/openziti/identity v1.0.74/go.mod h1:8Bzh+112+3ucQP2Fdbz7ehqsjYCCdDMwHgHwlHrKzf0= github.com/openziti/jwks v1.0.3 h1:hf8wkb+Cg4nH/HM0KROFd7u+C3DkRVcFZJ7tDV+4icc= github.com/openziti/jwks v1.0.3/go.mod h1:t4xxq8vlXGsPn29kiQVnZBBDDnEoOFqtJoHibkJunQQ= -github.com/openziti/metrics v1.2.48 h1:bDUcWSTWM4vXh4YU8z953Q/vtlUjtH+pSaQviKzB578= -github.com/openziti/metrics v1.2.48/go.mod h1:rLFoXigAFb5clCDqe/RlvFFjlaTr9Li7iEn3OxInmb0= -github.com/openziti/runzmd v1.0.41 h1:Iuwe91Lzq63ux2R6+VIWEvcEKhpKkPb1QVNwrJHOuDA= -github.com/openziti/runzmd v1.0.41/go.mod h1:T79oGLLJNnAhHzcfnlrOR39S2XGkzwYZLZh62xee0wk= +github.com/openziti/metrics v1.2.49 h1:StBi4IqoUy56o61OSlw9s8AOjk7XciTW3C0uU0xHpqY= +github.com/openziti/metrics v1.2.49/go.mod h1:J8pUiiILh+KRupiCVjXBl87AeyX+nHUSMO7qVut0s1o= +github.com/openziti/runzmd v1.0.42 h1:mnhYAOKMEaV7nPY5zf4HQIhs50QW2oh3NtgdeOZS1U0= +github.com/openziti/runzmd v1.0.42/go.mod h1:aMVPhw7xor34jYzGzeo1RQ3mcU1pnAQAuoLpBa06wrQ= github.com/openziti/sdk-golang v0.23.15 h1:+h+zin2CB6nP8e2Sqi2Jxo4Sbo3wTp8PIfh7QNm4lPA= github.com/openziti/sdk-golang v0.23.15/go.mod h1:aYvN+PCUV2AHPcbgcG1Khgso5TbmNaLMke0ByshU4Hs= github.com/openziti/secretstream v0.1.18 h1:bMHI4ez6pVSGFzHCHHn6imkaCYqd3o9Oa8gDObf8icI= github.com/openziti/secretstream v0.1.18/go.mod h1:gosi8ohW+dAHhz1h/MjZEcEVWO0jisWqWjEjmx7oAEs= -github.com/openziti/storage v0.2.33 h1:15WKxJ0J1GCNOMmOkoosjoxKN2Hrm4p3g8p9WAiMS9Y= -github.com/openziti/storage v0.2.33/go.mod h1:AbE5KkTVlXVFHRqpc7Ug3eFpNOc1HFBFwNIYn8Rtp+s= -github.com/openziti/transport/v2 v2.0.125 h1:6kDfabGFIE2+UPyvJVtfI43CNKcMwNOrCRX602CbDU4= -github.com/openziti/transport/v2 v2.0.125/go.mod h1:meVOsDPZSO/hNWSA+NGK5sAoeSgWoqfJgKUZlM3iX1E= +github.com/openziti/storage v0.2.34 h1:s1FgYkLXNE4KglkiHznnpmGIWj+YvNp64eX8FWvEo5Y= +github.com/openziti/storage v0.2.34/go.mod h1:oaShQMtacL6LjfPprJZY6HU7JqgI+Tm8U+bnIKjXtdY= +github.com/openziti/transport/v2 v2.0.128 h1:N3yrefO7jD1YjCEmx8mqrTJzE30nxntqd9kVChIn43U= +github.com/openziti/transport/v2 v2.0.128/go.mod h1:c/0QKR4dIp7LzVcyooEf+xmv87DvF8SMvK+MPFrhVbM= github.com/openziti/x509-claims v1.0.3 h1:HNdQ8Nf1agB3lBs1gahcO6zfkeS4S5xoQ2/PkY4HRX0= github.com/openziti/x509-claims v1.0.3/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE= github.com/openziti/xweb/v2 v2.1.0 h1:Xhh3C2pZkq/Prr65V+SfFSibLDYteoc4f62KQCcTZF4=