From 7bd67cf9b9c0c85c92483b3dcec9975080e959cd Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 09:33:03 -0500 Subject: [PATCH 01/15] Remove the update command, which was non-functional --- CHANGELOG.md | 11 ++++++ ziti/cmd/ziti/cmd/cmd.go | 2 - ziti/cmd/ziti/cmd/update.go | 78 ------------------------------------- 3 files changed, 11 insertions(+), 80 deletions(-) delete mode 100644 ziti/cmd/ziti/cmd/update.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 75cf7d5ef..a5d3d31a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# Release 0.27.0 + +## What's New + +* Ziti CLI + * The CLI has been cleaned up and unused, unusable and underused components have been removed + +## Ziti CLI + +* The update command has been removed. It was non-functional, so this should not affect anyone + # Release 0.26.11 ## What's New diff --git a/ziti/cmd/ziti/cmd/cmd.go b/ziti/cmd/ziti/cmd/cmd.go index c648b0460..0819fd6ba 100644 --- a/ziti/cmd/ziti/cmd/cmd.go +++ b/ziti/cmd/ziti/cmd/cmd.go @@ -123,7 +123,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com initCommands := NewCmdInit(out, err) createCommands := NewCmdCreate(out, err) - updateCommands := NewCmdUpdate(out, err) executeCommands := NewCmdExecute(out, err) agentCommands := NewAgentCmd(p) psCommands := NewCmdPs(p) @@ -152,7 +151,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com Commands: []*cobra.Command{ initCommands, createCommands, - updateCommands, }, }, { diff --git a/ziti/cmd/ziti/cmd/update.go b/ziti/cmd/ziti/cmd/update.go deleted file mode 100644 index 42a098568..000000000 --- a/ziti/cmd/ziti/cmd/update.go +++ /dev/null @@ -1,78 +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 cmd - -import ( - "io" - - "github.com/spf13/cobra" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" -) - -// Update contains the command line options -type UpdateOptions struct { - CommonOptions - - DisableImport bool - OutDir string -} - -var ( - updateResources = `Valid resource types include: - - * config - ` - - updateLong = templates.LongDesc(` - Updates an existing resource. - - ` + updateResources + ` -`) -) - -// NewCmdUpdate creates a command object for the "update" command -func NewCmdUpdate(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpdateOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "update", - Short: "Updates an existing resource", - Long: updateLong, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - - // cmd.AddCommand(NewCmdUpdateConfig(f, out, errOut)) - - return cmd -} - -// Run implements this command -func (o *UpdateOptions) Run() error { - return o.Cmd.Help() -} From cf2d3145e654dd376e6b89745ecac1a09c18b69b Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 09:37:12 -0500 Subject: [PATCH 02/15] Remove ansible/vagrant functionality. Removes adhoc, playbook and ping commands --- CHANGELOG.md | 1 + ziti/ansible/install.go | 144 --------- ziti/ansible/main.go | 187 ----------- ziti/ansible/module.go | 74 ----- ziti/ansible/playbook.go | 59 ---- ziti/cmd/ziti/cmd/adhoc.go | 122 ------- ziti/cmd/ziti/cmd/cmd.go | 3 - ziti/cmd/ziti/cmd/common_install.go | 8 - ziti/cmd/ziti/cmd/install_ansible.go | 94 ------ ziti/cmd/ziti/cmd/ping.go | 120 ------- ziti/cmd/ziti/cmd/playbook.go | 138 -------- ziti/provisioner/main.go | 35 -- ziti/provisioner/vagrant.go | 96 ------ ziti/vagrantutil/command.go | 190 ----------- ziti/vagrantutil/error.go | 100 ------ ziti/vagrantutil/parse.go | 68 ---- ziti/vagrantutil/stringer.go | 32 -- ziti/vagrantutil/vagrant.go | 456 --------------------------- 18 files changed, 1 insertion(+), 1926 deletions(-) delete mode 100644 ziti/ansible/install.go delete mode 100644 ziti/ansible/main.go delete mode 100644 ziti/ansible/module.go delete mode 100644 ziti/ansible/playbook.go delete mode 100644 ziti/cmd/ziti/cmd/adhoc.go delete mode 100644 ziti/cmd/ziti/cmd/install_ansible.go delete mode 100644 ziti/cmd/ziti/cmd/ping.go delete mode 100644 ziti/cmd/ziti/cmd/playbook.go delete mode 100644 ziti/provisioner/main.go delete mode 100644 ziti/provisioner/vagrant.go delete mode 100644 ziti/vagrantutil/command.go delete mode 100644 ziti/vagrantutil/error.go delete mode 100644 ziti/vagrantutil/parse.go delete mode 100644 ziti/vagrantutil/stringer.go delete mode 100644 ziti/vagrantutil/vagrant.go diff --git a/CHANGELOG.md b/CHANGELOG.md index a5d3d31a5..f5bbff075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ## Ziti CLI * The update command has been removed. It was non-functional, so this should not affect anyone +* The adhoc, ping and playbook commands have been removed. These were ansible and vagrant commands that were not widely used. # Release 0.26.11 diff --git a/ziti/ansible/install.go b/ziti/ansible/install.go deleted file mode 100644 index 5881c63d0..000000000 --- a/ziti/ansible/install.go +++ /dev/null @@ -1,144 +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 ansible - -import ( - "fmt" - "os" - "path/filepath" -) - -// Options for installing ansible -type InstallOptions struct { - RequirementsTXT string - VirtualEnv string - Path string -} - -func InstallViaPip(options *InstallOptions) error { - // TODO - var ( - virtualenvBinary string - virtualEnv string - pipBinary string - requirementsTXT string - err error - ) - - if options.Path != "" { - if _, err = os.Stat(options.Path); os.IsNotExist(err) { - return fmt.Errorf("The specified Path (%s) does not exist", options.Path) - } - } - - cwd, _ := os.Getwd() - - // if no requirements.txt is set we should check to see if we have one in - // dir in provided path or the current working dir, if so we can use that. - if options.RequirementsTXT == "" { - if options.Path != "" { - requirementsTXT = filepath.Join(options.Path, "requirements.txt") - } else { - requirementsTXT = filepath.Join(cwd, "requirements.txt") - } - if requirementsTXT != "" { - fmt.Printf("checking if %s exists... ", requirementsTXT) - if _, err = os.Stat(requirementsTXT); err == nil { - options.RequirementsTXT = requirementsTXT - fmt.Println("yes") - } else { - fmt.Println("no") - } - } - } else { - fmt.Printf("checking if %s exists... ", options.RequirementsTXT) - if _, err = os.Stat(options.RequirementsTXT); err == nil { - fmt.Println("yes") - } else { - fmt.Println("no") - return fmt.Errorf("(%s) does not exist", options.RequirementsTXT) - } - } - - // if requesting virtualenv we need to make sure virtualenv binary exists - if options.VirtualEnv != "" { - virtualenvBinary = checkBinInPath("virtualenv") - if virtualenvBinary == "" { - return fmt.Errorf("unable to find virtualenv in path") - } - } - - // if no virtualenv is set we should check to see if we have a virtualenv - // dir in provided path or the current working dir, if so we can use that. - if options.VirtualEnv == "" { - //fmt.Printf("you specified path %s\n", options.Path) - if options.Path != "" { - virtualEnv = filepath.Join(options.Path, "virtualenv") - options.VirtualEnv = virtualEnv - } else { - virtualEnv = filepath.Join(cwd, "virtualenv") - fmt.Printf("checking if %s exists... ", virtualEnv) - if _, err = os.Stat(virtualEnv); err == nil { - options.VirtualEnv = virtualEnv - fmt.Println("yes") - } else { - fmt.Println("no") - } - } - } - - // if requesting virtualenv we need to make sure virtualenv binary exists - if options.VirtualEnv != "" { - virtualenvBinary = checkBinInPath("virtualenv") - if virtualenvBinary == "" { - return fmt.Errorf("unable to find virtualenv in path") - } - } - - // if a virtualenv is specified make sure that pip is installed - // in it and use that, otherwise make sure its in path. - if options.VirtualEnv != "" { - fmt.Printf("Using VirtualEnv: %s\n", options.VirtualEnv) - pipBinary = filepath.Join(options.VirtualEnv, "bin", "pip") - if _, err = os.Stat(pipBinary); os.IsNotExist(err) { - err = runCmd(virtualenvBinary, []string{options.VirtualEnv}) - if err != nil { - return err - } - } - } else { - pipBinary = checkBinInPath("pip") - } - if pipBinary == "" { - return fmt.Errorf("unable to find pip in path") - } - fmt.Printf("Using Pip: %s\n", pipBinary) - - if options.RequirementsTXT != "" { - err = runCmd(pipBinary, []string{"install", "-r", options.RequirementsTXT}) - if err != nil { - return err - } - } else { - err = runCmd(pipBinary, []string{"install", "ansible"}) - if err != nil { - return err - } - } - - return nil -} diff --git a/ziti/ansible/main.go b/ziti/ansible/main.go deleted file mode 100644 index 584bb9dde..000000000 --- a/ziti/ansible/main.go +++ /dev/null @@ -1,187 +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 ansible - -import ( - "bufio" - "fmt" - "os" - "os/exec" - "path/filepath" - "strings" -) - -// Options for running ansible -type Options struct { - SSHConfigFile string - SSHForwardAgent bool - Provisioner string - Environment string - Inventory string - KnownHostsFile string - ModuleOptions - PlaybookOptions -} - -// sets an environment variable -func setEnvironmentVariables(variable, value string) { - os.Setenv(variable, value) -} - -// appends a string to an existing environment variable -func appendEnvironmentVariable(variable, value string) { - old := os.Getenv(variable) - new := []string{old, value} - os.Setenv(variable, strings.Join(new, " ")) -} - -// Checks if specified ssh config file exists, if not it -// checks if there is an ssh_config in the specified environment -// otherwise defaults to no ssh config. -// appends result to env var ANSIBLE_SSH_ARGS -func sshConfigFile(options *Options) error { - if options.SSHConfigFile == "" { - sshConfigFile := filepath.Join(options.Environment, "ssh_config") - if _, err := os.Stat(sshConfigFile); !os.IsNotExist(err) { - options.SSHConfigFile = sshConfigFile - } - } else { - if _, err := os.Stat(options.SSHConfigFile); os.IsNotExist(err) { - return fmt.Errorf("ssh_config file %s does not exist", options.SSHConfigFile) - } - } - if options.SSHConfigFile != "" { - appendEnvironmentVariable("ANSIBLE_SSH_ARGS", - fmt.Sprintf("-F %s", options.SSHConfigFile)) - } - return nil -} - -// isEnvironment checks if a given directory is a suitable environment -func isEnvironment(path string) bool { - fi, err := os.Stat(path) - switch { - case err != nil: - return false - case fi.IsDir(): - testInventory := filepath.Join(path, "hosts") - if _, err := os.Stat(testInventory); os.IsNotExist(err) { - return false - } - return true - default: - return false - } -} - -// if the user specifies an environment we will attempt to ensure that -// it exists, we will also set the inventory arg to be passed onto ansible. -func configureEnvironment(options *Options) error { - if options.Environment != "" { - if isEnvironment(options.Environment) { - options.Inventory = filepath.Join(options.Environment, "hosts") - } else { - return fmt.Errorf("%s is not a valid environment path", options.Environment) - } - } else { - cwd, _ := os.Getwd() - fmt.Printf("--environment not set. Trying your working directory (%s)\n", cwd) - if isEnvironment(cwd) { - options.Environment = cwd - options.Inventory = filepath.Join(cwd, "hosts") - } else { - return fmt.Errorf("%s is not a valid environment path", cwd) - } - } - - if options.Inventory != "" { - if _, err := os.Stat(options.Inventory); os.IsNotExist(err) { - return fmt.Errorf("inventory file %s does not exist", options.Inventory) - } - } - return nil -} - -// checks if the user specifies an alternative known hosts file, if not -// looks for one in the specified environment or just defaults to none. -func configureKnownHostsFile(options *Options) error { - if options.KnownHostsFile != "" { - if _, err := os.Stat(options.KnownHostsFile); os.IsNotExist(err) { - return fmt.Errorf("known hosts file %s does not exist", options.KnownHostsFile) - } - } else { - maybeKnownHostsFile := filepath.Join(options.Environment, "ssh_known_hosts") - if _, err := os.Stat(maybeKnownHostsFile); !os.IsNotExist(err) { - options.KnownHostsFile = maybeKnownHostsFile - } - } - if options.KnownHostsFile != "" { - appendEnvironmentVariable("ANSIBLE_SSH_ARGS", - fmt.Sprintf("-o UserKnownHostsFile=%s", options.KnownHostsFile)) - } - return nil -} - -// enables ssh agent forwarding -func configureSSHForwardAgent(options *Options) { - if options.SSHForwardAgent { - appendEnvironmentVariable("ANSIBLE_SSH_ARGS", "-o ForwardAgent=yes") - } -} - -func init() { - // setEnvironmentVariables("ANSIBLE_STDOUT_CALLBACK","json") -} - -func checkBinInPath(binary string) string { - fmt.Printf("==> checkBinInPath: %s\n", binary) - location, err := exec.LookPath(binary) - if err != nil { - fmt.Printf("==> checkBinInPath: err: %s\n", err) - return "" - } - return location -} - -// runCmd takes a command and args and runs it, streaming output to stdout -func runCmd(cmdName string, cmdArgs []string) error { - fmt.Printf("==> Running: %s %s\n", cmdName, strings.Join(cmdArgs, " ")) - //return fmt.Errorf("bye") - cmd := exec.Command(cmdName, cmdArgs...) - cmdReader, err := cmd.StdoutPipe() - if err != nil { - return err - } - - scanner := bufio.NewScanner(cmdReader) - go func() { - for scanner.Scan() { - fmt.Printf("%s\n", scanner.Text()) - } - }() - - err = cmd.Start() - if err != nil { - return err - } - - err = cmd.Wait() - if err != nil { - return err - } - return nil -} diff --git a/ziti/ansible/module.go b/ziti/ansible/module.go deleted file mode 100644 index b0bc944e3..000000000 --- a/ziti/ansible/module.go +++ /dev/null @@ -1,74 +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 ansible - -import ( - "fmt" -) - -// ModuleOptions for running ansible -type ModuleOptions struct { - ModuleHosts string - Module string - ModulePath string - ModuleArgs string -} - -// Module ansible playbook -func Module(options *Options, ansibleArgs []string) error { - var ( - err error - zitiArgs []string - ) - - err = configureEnvironment(options) - if err != nil { - return err - } - err = sshConfigFile(options) - if err != nil { - return err - } - err = configureKnownHostsFile(options) - if err != nil { - return err - } - configureSSHForwardAgent(options) - - zitiArgs = []string{options.ModuleHosts, "--module-name", options.Module} - - if options.ModulePath != "" { - zitiArgs = append(zitiArgs, - []string{"--module-path", options.ModulePath}...) - } - - if options.ModuleArgs != "" { - zitiArgs = append(zitiArgs, - []string{"--args", fmt.Sprintf("'%s'", options.ModuleArgs)}...) - } - - if options.Inventory != "" { - zitiArgs = append(zitiArgs, - []string{"--inventory", options.Inventory}...) - } - - cmdName := "ansible" - cmdArgs := append(zitiArgs, ansibleArgs...) - - return runCmd(cmdName, cmdArgs) - -} diff --git a/ziti/ansible/playbook.go b/ziti/ansible/playbook.go deleted file mode 100644 index 9d58620de..000000000 --- a/ziti/ansible/playbook.go +++ /dev/null @@ -1,59 +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 ansible - -import ( -// "fmt" -// "strings" -) - -// PlaybookOptions for running ansible -type PlaybookOptions struct { -} - -// PlaybookRun ansible playbook -func PlaybookRun(options *Options, ansibleArgs []string) error { - var ( - err error - zitiArgs []string - ) - - err = configureEnvironment(options) - if err != nil { - return err - } - err = sshConfigFile(options) - if err != nil { - return err - } - err = configureKnownHostsFile(options) - if err != nil { - return err - } - configureSSHForwardAgent(options) - - if options.Inventory != "" { - zitiArgs = append(zitiArgs, - []string{"--inventory", options.Inventory}...) - } - - cmdName := "ansible-playbook" - cmdArgs := append(zitiArgs, ansibleArgs...) - // fmt.Println("running: ansible_playbook", strings.Join(cmdArgs, " ")) - - return runCmd(cmdName, cmdArgs) -} diff --git a/ziti/cmd/ziti/cmd/adhoc.go b/ziti/cmd/ziti/cmd/adhoc.go deleted file mode 100644 index d94c36290..000000000 --- a/ziti/cmd/ziti/cmd/adhoc.go +++ /dev/null @@ -1,122 +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 cmd - -import ( - "fmt" - "io" - "os" - "os/exec" - "path/filepath" - - "github.com/openziti/ziti/ziti/ansible" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/spf13/cobra" -) - -// AdhocOptions are the flags for delete commands -type AdhocOptions struct { - CommonOptions -} - -var adhocOptions = &ansible.Options{} - -// NewCmdAdhoc creates the command -func NewCmdAdhoc(out io.Writer, errOut io.Writer) *cobra.Command { - options := &AdhocOptions{ - CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "adhoc [flags] command [ansible arguments]", - Short: "wrapper around ansible command", - Long: ` -'ziti adhoc' is a wrapper around the 'ansible --module' shell that adds some additional useful features. -`, - Aliases: []string{}, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - var ( - err error - virtualEnv string - ) - // check if there's a virtualenv we should use in your cwd - cwd, _ := os.Getwd() - virtualEnv = filepath.Join(cwd, "virtualenv/bin") - if _, err = os.Stat(virtualEnv); err == nil { - os.Setenv("PATH", fmt.Sprintf("%s:%s", virtualEnv, os.Getenv("PATH"))) - } - - // check if there's a virtualenv we should use in your environment - if adhocOptions.Environment != cwd { - virtualEnv = filepath.Join(adhocOptions.Environment, "virtualenv/bin") - if _, err = os.Stat(virtualEnv); err == nil { - os.Setenv("PATH", fmt.Sprintf("%s:%s", virtualEnv, os.Getenv("PATH"))) - } - } - // check if ansible-playbook binary exists - _, err = exec.LookPath("ansible") - if err != nil { - return err - } - return nil - }, - - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{}, - } - - // stops parsing flags after first unknown flag is found - cmd.Flags().SetInterspersed(false) - - cmd.Flags().StringVarP(&adhocOptions.SSHConfigFile, "ssh-config-file", - "s", "", "Path to ssh config file to use.") - - cmd.Flags().BoolVarP(&adhocOptions.SSHForwardAgent, "ssh-forward-agent", - "f", false, "path to ssh config file to use") - - cmd.Flags().StringVarP(&adhocOptions.Environment, "environment", - "e", "", "directory that contains ansible inventory") - - cmd.Flags().StringVarP(&adhocOptions.KnownHostsFile, "known-hosts-file", - "", "", "location of known hosts file") - - cmd.Flags().StringVarP(&adhocOptions.ModuleHosts, "hosts", - "", "all", "host or host pattern to run") - - return cmd -} - -// Run implements this command -func (o *AdhocOptions) Run() error { - adhocOptions.Module = "raw" - - if len(o.Args) < 1 { - return o.Cmd.Help() - } - - adhocOptions.ModuleArgs = o.Args[0] - args := o.Args[1:] - return ansible.Module(adhocOptions, args) -} diff --git a/ziti/cmd/ziti/cmd/cmd.go b/ziti/cmd/ziti/cmd/cmd.go index 0819fd6ba..7ff1a2cb6 100644 --- a/ziti/cmd/ziti/cmd/cmd.go +++ b/ziti/cmd/ziti/cmd/cmd.go @@ -192,9 +192,6 @@ 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(NewCmdPlaybook(out, err)) - cmd.AddCommand(NewCmdPing(out, err)) - cmd.AddCommand(NewCmdAdhoc(out, err)) cmd.AddCommand(NewCmdUse(out, err)) return cmd diff --git a/ziti/cmd/ziti/cmd/common_install.go b/ziti/cmd/ziti/cmd/common_install.go index 2aab9e0b4..b72071b6e 100644 --- a/ziti/cmd/ziti/cmd/common_install.go +++ b/ziti/cmd/ziti/cmd/common_install.go @@ -19,7 +19,6 @@ package cmd import ( "fmt" "github.com/blang/semver" - "github.com/openziti/ziti/ziti/ansible" c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/openziti/ziti/ziti/cmd/ziti/util" @@ -131,13 +130,6 @@ func (o *CommonOptions) doInstallMissingDependencies(install []string) error { switch i { case "aws": err = o.installAWSCli() - case "ansible": - opts := &ansible.InstallOptions{ - RequirementsTXT: "", - VirtualEnv: "", - Path: "", - } - err = ansible.InstallViaPip(opts) default: return fmt.Errorf("unknown dependency to install %s", i) } diff --git a/ziti/cmd/ziti/cmd/install_ansible.go b/ziti/cmd/ziti/cmd/install_ansible.go deleted file mode 100644 index f05e450e0..000000000 --- a/ziti/cmd/ziti/cmd/install_ansible.go +++ /dev/null @@ -1,94 +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 cmd - -import ( - "io" - - "github.com/openziti/ziti/ziti/ansible" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - "github.com/spf13/cobra" -) - -var ( - installAnsibleLong = templates.LongDesc(` - 'ziti install ansible' will install ansible and/or any dependencies provided. - If you do not specify a virtualenv or requirements file it will attempt - to find them in your local path, or it will try to find them in your - environment if you provide one. - `) - - installAnsibleExample = templates.Examples(` - # Install Ansible - ziti install ansible - `) -) - -// InstallAnsibleOptions the options for the install command -type InstallAnsibleOptions struct { - InstallOptions - - Version string -} - -var installOptions = &ansible.InstallOptions{} - -// NewCmdInstallAnsible defines the command -func NewCmdInstallAnsible(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InstallAnsibleOptions{ - InstallOptions: InstallOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ansible", - Short: "Install ansible via pip", - Aliases: []string{}, - Long: installAnsibleLong, - Example: installAnsibleExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - - // stops parsing flags after first unknown flag is found - cmd.Flags().SetInterspersed(false) - - cmd.Flags().StringVarP(&installOptions.VirtualEnv, "virtualenv", - "v", "", "Path to VirtualEnv to use") - - cmd.Flags().StringVarP(&installOptions.RequirementsTXT, "requirements", - "r", "", "path to requirements.txt") - - cmd.Flags().StringVarP(&installOptions.Path, "environment", - "e", "", "path to your ziti environment") - - return cmd -} - -// Run implements the command -func (o *InstallAnsibleOptions) Run() error { - return ansible.InstallViaPip(installOptions) -} diff --git a/ziti/cmd/ziti/cmd/ping.go b/ziti/cmd/ziti/cmd/ping.go deleted file mode 100644 index 7e7c27cc6..000000000 --- a/ziti/cmd/ziti/cmd/ping.go +++ /dev/null @@ -1,120 +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 cmd - -import ( - "fmt" - "io" - "os" - "os/exec" - "path/filepath" - - "github.com/openziti/ziti/ziti/ansible" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - // "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - "github.com/spf13/cobra" -) - -// PingOptions are the flags for delete commands -type PingOptions struct { - CommonOptions -} - -var pingOptions = &ansible.Options{} - -// NewCmdPing creates the command -func NewCmdPing(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PingOptions{ - CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "ping [flags] [--] [ansible arguments]", - Short: "check if all hosts are available", - Long: ` -'ziti' ping' uses the ansible ping module to check if all hosts are available. -This is useful for checking if your machine can successfully SSH/Ansible to -each host. -`, - Aliases: []string{}, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - var ( - err error - virtualEnv string - ) - // check if there's a virtualenv we should use in your cwd - cwd, _ := os.Getwd() - virtualEnv = filepath.Join(cwd, "virtualenv/bin") - if _, err = os.Stat(virtualEnv); err == nil { - os.Setenv("PATH", fmt.Sprintf("%s:%s", virtualEnv, os.Getenv("PATH"))) - } - - // check if there's a virtualenv we should use in your environment - if pingOptions.Environment != cwd { - virtualEnv = filepath.Join(pingOptions.Environment, "virtualenv/bin") - if _, err = os.Stat(virtualEnv); err == nil { - os.Setenv("PATH", fmt.Sprintf("%s:%s", virtualEnv, os.Getenv("PATH"))) - } - } - // check if ansible-playbook binary exists - _, err = exec.LookPath("ansible") - if err != nil { - return err - } - return nil - }, - - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{}, - } - - // stops parsing flags after first unknown flag is found - cmd.Flags().SetInterspersed(false) - - cmd.Flags().StringVarP(&pingOptions.SSHConfigFile, "ssh-config-file", - "s", "", "Path to ssh config file to use.") - - cmd.Flags().StringVarP(&pingOptions.Environment, "environment", - "e", "", "directory that contains ansible inventory") - - cmd.Flags().StringVarP(&pingOptions.KnownHostsFile, "known-hosts-file", - "", "", "location of known hosts file") - - cmd.Flags().StringVarP(&pingOptions.ModuleHosts, "hosts", - "", "all", "host or host pattern to run") - - return cmd -} - -// Run implements this command -func (o *PingOptions) Run() error { - pingOptions.Module = "ping" - - // if len(o.Args) < 1 { - // return o.Cmd.Help() - // } - - return ansible.Module(pingOptions, o.Args) -} diff --git a/ziti/cmd/ziti/cmd/playbook.go b/ziti/cmd/ziti/cmd/playbook.go deleted file mode 100644 index 47d95ce9a..000000000 --- a/ziti/cmd/ziti/cmd/playbook.go +++ /dev/null @@ -1,138 +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 cmd - -import ( - "fmt" - "io" - - "github.com/openziti/ziti/ziti/ansible" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/provisioner" - - "github.com/spf13/cobra" - "os" - "os/exec" - "path/filepath" -) - -const () - -type PlaybookOptions struct { - CommonOptions -} - -var playbookOptions = &ansible.Options{} -var po = &provisioner.Options{} - -func NewCmdPlaybook(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PlaybookOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "playbook [flags] file.yml [--] [ansible-playbook arguments]", - Short: "Wrapper around ansible command", - Long: ` -'ziti playbook' will run an ansible playbook over your provided environment. - -You can set additional ansible-playbook flags by providing a double dash "--" and -then the additional flags. - -Example: - -To run playbook/yaml over the env/test environment passing flags to ansible and use -the user "root" and run in verbose mode, do this: - - $ ziti playbook -e env/test playbook.yml -- --user=root -vvvv -`, - Aliases: []string{"up"}, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - var ( - err error - virtualEnv string - ) - - // check if there's a virtualenv we should use in your cwd - cwd, _ := os.Getwd() - virtualEnv = filepath.Join(cwd, "virtualenv/bin") - if _, err = os.Stat(virtualEnv); err == nil { - os.Setenv("PATH", fmt.Sprintf("%s:%s", virtualEnv, os.Getenv("PATH"))) - } - - // check if there's a virtualenv we should use in your environment - if playbookOptions.Environment != cwd { - virtualEnv = filepath.Join(playbookOptions.Environment, "virtualenv/bin") - if _, err = os.Stat(virtualEnv); err == nil { - os.Setenv("PATH", fmt.Sprintf("%s:%s", virtualEnv, os.Getenv("PATH"))) - } - } - - // check if ansible-playbook binary exists - _, err = exec.LookPath("ansible-playbook") - if err != nil { - return err - } - // check if provisioning needs to happen - if po.Provisioner != "" { - po.Environment = playbookOptions.Environment - err = provisioner.Up(po) - if err != nil { - return err - } - } - - return nil - }, - - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - options.AddCommonFlags(cmd) - - cmd.Flags().StringVarP(&playbookOptions.SSHConfigFile, "ssh-config-file", - "s", "", "Path to ssh config file to use.") - - cmd.Flags().BoolVarP(&playbookOptions.SSHForwardAgent, "ssh-forward-agent", - "f", false, "path to ssh config file to use") - - cmd.Flags().StringVarP(&playbookOptions.Environment, "environment", - "e", "", "directory that contains ansible inventory") - - cmd.Flags().StringVarP(&playbookOptions.KnownHostsFile, "known-hosts-file", - "", "", "location of known hosts file") - - cmd.Flags().StringVarP(&po.Provisioner, "provisioner", - "", "", "provisioner (vagrant)") - - return cmd -} - -// Run ... -func (o *PlaybookOptions) Run() error { - if len(o.Args) < 1 { - return o.Cmd.Help() - } - return ansible.PlaybookRun(playbookOptions, o.Args) -} diff --git a/ziti/provisioner/main.go b/ziti/provisioner/main.go deleted file mode 100644 index bdf7d1a2a..000000000 --- a/ziti/provisioner/main.go +++ /dev/null @@ -1,35 +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 provisioner - -import ( - "fmt" -) - -// Provisioner settings -type Options struct { - Provisioner string - Environment string -} - -// Up instantiates an environment -func Up(po *Options) error { - if po.Provisioner == "vagrant" { - return VagrantUp(po) - } - return fmt.Errorf("%s is not a valid provisioner choice", po.Provisioner) -} diff --git a/ziti/provisioner/vagrant.go b/ziti/provisioner/vagrant.go deleted file mode 100644 index 2a9195581..000000000 --- a/ziti/provisioner/vagrant.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 provisioner - -import ( - "github.com/openziti/ziti/ziti/vagrantutil" - "fmt" - "io/ioutil" - "os" - "path/filepath" -) - -var vagrant *vagrantutil.Vagrant - -func findVagrantfile(paths []string) string { - var ( - vagrantFile string - path string - ) - for _, path = range paths { - vagrantFile = filepath.Join(path, "Vagrantfile") - if _, err := os.Stat(vagrantFile); !os.IsNotExist(err) { - return path - } - } - return "" -} - -func runVagrantUp() { - output, _ := vagrant.Up() - // print the output - for line := range output { - fmt.Println(line) - } -} - -// VagrantUp provisioner -func VagrantUp(po *Options) error { - var ( - err error - ) - cwd, _ := os.Getwd() - paths := []string{po.Environment, cwd} - vagrantPath := findVagrantfile(paths) - if vagrantPath == "" { - return fmt.Errorf("cannot find vagrantfile in %s", paths) - } - vagrant, _ = vagrantutil.NewVagrant(vagrantPath) - vagrant.Status() - // fmt.Println("vagrant.State: %s", vagrant.State) - switch state := vagrant.State; state { - case "NotCreated": - runVagrantUp() - case "PowerOff": - runVagrantUp() - case "Saved": - runVagrantUp() - case "Running": - // do nothing - default: - return fmt.Errorf("cannot handle vagrant state %s.", state) - } - - if vagrant.State == "NotCreated" { - output, _ := vagrant.Up() - // print the output - for line := range output { - fmt.Println(line) - } - } - sshConfig, err := (vagrant.SSHConfig()) - if err != nil { - return err - } - sshConfigFile := filepath.Join(vagrantPath, "ssh_config") - err = ioutil.WriteFile(sshConfigFile, []byte(sshConfig), 0644) - if err != nil { - return err - } - - return nil -} diff --git a/ziti/vagrantutil/command.go b/ziti/vagrantutil/command.go deleted file mode 100644 index 34326602f..000000000 --- a/ziti/vagrantutil/command.go +++ /dev/null @@ -1,190 +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 vagrantutil - -import ( - "bufio" - "errors" - "fmt" - "io" - "log" - "os" - "os/exec" - "strings" - "sync" -) - -var env = append(os.Environ(), "VAGRANT_CHECKPOINT_DISABLE=1") - -type command struct { - // log logging.Logger - cwd string - - onSuccess func() - onFailure func(err error) - - ignoreErr func(err error) bool - errIgnored bool - - cmd *exec.Cmd -} - -func newCommand(cwd string) *command { - cmd := &command{ - cwd: cwd, - } - - // if log != nil { - // cmd.log = log.New(cwd) - // } - - return cmd -} - -func (cmd *command) init(args []string) { - cmd.cmd = exec.Command("vagrant", args...) - cmd.cmd.Dir = cmd.cwd - cmd.cmd.Env = env - - cmd.debugf("%s: executing: %v", cmd.cwd, cmd.cmd.Args) -} - -func (cmd *command) run(args ...string) (string, error) { - cmd.init(args) - - out, err := cmd.cmd.CombinedOutput() - if err != nil && len(out) != 0 { - err = fmt.Errorf("%s: %s", err, out) - } - - if e := cmd.checkError(err); e != nil { - return "", cmd.done(e) - } - - s := string(out) - - cmd.debugf("execution of %v was successful: %s", cmd.cmd.Args, s) - - return s, cmd.done(nil) - -} - -// start starts the command and sends back both the stdout and stderr to -// the returned channel. Any error happened during the streaming is passed to -// the Error field. -func (cmd *command) start(args ...string) (ch <-chan *CommandOutput, err error) { - cmd.init(args) - - stdoutPipe, err := cmd.cmd.StdoutPipe() - if err != nil { - return nil, cmd.done(err) - } - - stderrPipe, err := cmd.cmd.StderrPipe() - if err != nil { - return nil, cmd.done(err) - } - - if err := cmd.cmd.Start(); err != nil { - return nil, cmd.done(err) - } - - var wg sync.WaitGroup - wg.Add(2) - out := make(chan *CommandOutput) - - output := func(r io.Reader) { - scanner := bufio.NewScanner(r) - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - if line == "" { - continue // ignore excessive whitespace - } - - cmd.debugf("%s", line) - cmd.checkError(errors.New(line)) - - out <- &CommandOutput{Line: line} - } - - cmd.reportError(out, scanner.Err()) - wg.Done() - } - - go output(stdoutPipe) - go output(stderrPipe) - - go func() { - wg.Wait() - - err := cmd.reportError(out, cmd.cmd.Wait()) - - close(out) - cmd.done(err) - }() - - return out, nil -} - -func (cmd *command) done(err error) error { - if e := cmd.checkError(err); e != nil { - - cmd.debugf("execution of %v failed: %s", cmd.cmd.Args, e) - - if cmd.onFailure != nil { - cmd.onFailure(e) - } - - return e - } - - if cmd.onSuccess != nil { - cmd.onSuccess() - } - - return nil -} - -func (cmd *command) checkError(err error) error { - if err == nil { - return nil - } - - if cmd.errIgnored || cmd.ignoreErr != nil && cmd.ignoreErr(err) { - cmd.errIgnored = true - return nil - } - - return err -} - -func (cmd *command) reportError(out chan<- *CommandOutput, err error) error { - if e := cmd.checkError(err); e != nil { - cmd.debugf("reporting error for %v: %s (%t)", cmd.cmd.Args, err, cmd.errIgnored) - out <- &CommandOutput{Error: err} - - return e - } - - return nil -} - -func (cmd *command) debugf(format string, args ...interface{}) { - // if cmd.log != nil { - log.Printf(format, args...) - // } -} diff --git a/ziti/vagrantutil/error.go b/ziti/vagrantutil/error.go deleted file mode 100644 index 9b56cc423..000000000 --- a/ziti/vagrantutil/error.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 vagrantutil - -import ( - "errors" - "os" - "strings" -) - -// List of errors ignored by Destroy / Status methods: -const ( - errNotCreated = "A Vagrant environment or target machine is required to run this" - errRubyNotExists = "No such file or directory - getcwd (Errno::ENOENT)" -) - -func isNotCreated(err error) bool { - return os.IsNotExist(err) || strings.Contains(err.Error(), errNotCreated) || - strings.Contains(err.Error(), errRubyNotExists) -} - -// The following errors are returned by the Wait function: -var ( - ErrBoxAlreadyExists = errors.New("box already exists") - ErrBoxInvalidVersion = errors.New("invalid box version") - ErrBoxNotAvailable = errors.New("box is not available") - ErrBoxDownload = errors.New("unable to download the box") - ErrVirtualBox = errors.New("VirtualBox is missing or not operational") -) - -var defaultWaiter Waiter - -// Waiter is used to consume output channel from a Vagrant command, parsing -// each line looking for an error when command execution fails. -type Waiter struct { - // OutputFunc, when non-nil, is called each time a Wait method receives - // a line of output from command channel. - OutputFunc func(string) -} - -// Wait is a convenience method that consumes Vagrant output looking -// for well-known errors. -// -// It returns an error variable for any known error condition, which makes it -// easier for the caller to recover from failure. -// -// If OutputFunc is non-nil, it's called on each line of output received -// from the out channel. -func (w *Waiter) Wait(out <-chan *CommandOutput, err error) error { - var e error - for o := range out { - if w.OutputFunc != nil { - w.OutputFunc(o.Line) - } - for s, err := range errMapping { - if strings.Contains(o.Line, s) { - e = nonil(e, err) - } - } - e = nonil(e, o.Error) - } - return nonil(e, err) -} - -// Wait is a convenience function that consumes Vagrant output looking -// for well-known errors. -func Wait(out <-chan *CommandOutput, err error) error { - return defaultWaiter.Wait(out, err) -} - -var errMapping = map[string]error{ - "The box you're attempting to add already exists.": ErrBoxAlreadyExists, - "Gem::Requirement::BadRequirementError": ErrBoxInvalidVersion, - "could not be accessed in the remote catalog.": ErrBoxNotAvailable, - "An error occurred while downloading the remote file.": ErrBoxDownload, - "VirtualBox is complaining that the kernel module is not loaded": ErrVirtualBox, -} - -func nonil(err ...error) error { - for _, e := range err { - if e != nil { - return e - } - } - return nil -} diff --git a/ziti/vagrantutil/parse.go b/ziti/vagrantutil/parse.go deleted file mode 100644 index 5503d1f42..000000000 --- a/ziti/vagrantutil/parse.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 vagrantutil - -import ( - "bufio" - "fmt" - "strings" -) - -// parseData parses the given vagrant type field from the machine readable -// output (records). -func parseData(records [][]string, typeName string) (string, error) { - data := "" - for _, record := range records { - // first three are defined, after that data is variadic, it contains - // zero or more information. We should have a data, otherwise it's - // useless. - if len(record) < 4 { - continue - } - - if typeName == record[2] && record[3] != "" { - data = record[3] - break - } - } - - if data == "" { - return "", fmt.Errorf("couldn't parse data for vagrant type: %q", typeName) - } - - return data, nil -} - -func parseRecords(out string) (recs [][]string, err error) { - scanner := bufio.NewScanner(strings.NewReader(out)) - - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - if line == "" { - continue - } - - row := strings.Split(line, ",") - recs = append(recs, row) - } - - if err := scanner.Err(); err != nil { - return nil, err - } - - return recs, nil -} diff --git a/ziti/vagrantutil/stringer.go b/ziti/vagrantutil/stringer.go deleted file mode 100644 index b3f8ac9d9..000000000 --- a/ziti/vagrantutil/stringer.go +++ /dev/null @@ -1,32 +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. -*/ - -// Code generated by "stringer -type=Status -output=stringer.go"; DO NOT EDIT - -package vagrantutil - -import "fmt" - -const _Status_name = "UnknownNotCreatedRunningSavedPowerOffAbortedPreparing" - -var _Status_index = [...]uint8{0, 7, 17, 24, 29, 37, 44, 53} - -func (i Status) String() string { - if i < 0 || i >= Status(len(_Status_index)-1) { - return fmt.Sprintf("Status(%d)", i) - } - return _Status_name[_Status_index[i]:_Status_index[i+1]] -} diff --git a/ziti/vagrantutil/vagrant.go b/ziti/vagrantutil/vagrant.go deleted file mode 100644 index 095b5f1f1..000000000 --- a/ziti/vagrantutil/vagrant.go +++ /dev/null @@ -1,456 +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 vagrantutil is a high level wrapper around Vagrant which provides an -// idiomatic go API. -package vagrantutil - -import ( - "bufio" - "errors" - "fmt" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" -) - -//go:generate stringer -type=Status -output=stringer.go - -type Status int - -const ( - // Some possible states: - // https://github.com/mitchellh/vagrant/blob/master/templates/locales/en.yml#L1504 - Unknown Status = iota - NotCreated - Running - Saved - PowerOff - Aborted - Preparing -) - -// Box represents a single line of `vagrant box list` output. -type Box struct { - Name string - Provider string - Version string -} - -// CommandOutput is the streaming output of a command -type CommandOutput struct { - Line string - Error error -} - -type Vagrant struct { - // VagrantfilePath is the directory with specifies the directory where - // Vagrantfile is being stored. - VagrantfilePath string - - // ProviderName overwrites the default provider used for the Vagrantfile. - ProviderName string - - // ID is the unique ID of the given box. - ID string - - // State is populated/updated if the Status() or List() method is called. - State string - - // Log is used for logging output of vagrant commands in debug mode. - // Log logging.Logger -} - -// NewVagrant returns a new Vagrant instance for the given path. The path -// should be unique. If the path already exists in the system it'll be used, if -// not a new setup will be createad. -func NewVagrant(path string) (*Vagrant, error) { - if path == "" { - return nil, errors.New("vagrant: path is empty") - } - - if err := os.MkdirAll(path, 0755); err != nil { - return nil, err - } - - return &Vagrant{ - VagrantfilePath: path, - }, nil -} - -// Create creates the vagrantFile in the pre initialized vagrant path. -func (v *Vagrant) Create(vagrantFile string) error { - // Recreate the directory in case it was removed between - // call to NewVagrant and Create. - if err := os.MkdirAll(v.VagrantfilePath, 0755); err != nil { - return v.error(err) - } - - v.debugf("create:\n%s", vagrantFile) - - return v.error(ioutil.WriteFile(v.vagrantfile(), []byte(vagrantFile), 0644)) -} - -// Version returns the current installed vagrant version -func (v *Vagrant) Version() (string, error) { - out, err := v.vagrantCommand().run("version", "--machine-readable") - if err != nil { - return "", err - } - - records, err := parseRecords(out) - if err != nil { - return "", v.error(err) - } - - versionInstalled, err := parseData(records, "version-installed") - if err != nil { - return "", v.error(err) - } - - return versionInstalled, nil -} - -// Status returns the state of the box, such as "Running", "NotCreated", etc... -func (v *Vagrant) Status() (s Status, err error) { - defer func() { - v.State = s.String() - }() - - var notCreated bool - cmd := v.vagrantCommand() - cmd.ignoreErr = func(err error) bool { - if isNotCreated(err) { - notCreated = true - return true - } - - return false - } - - out, err := cmd.run("status", "--machine-readable") - if err != nil { - return Unknown, err - } - - if notCreated { - return NotCreated, nil - } - - records, err := parseRecords(out) - if err != nil { - return Unknown, v.error(err) - } - - status, err := parseData(records, "state") - if err != nil { - return Unknown, v.error(err) - } - - s, err = toStatus(status) - if err != nil { - return Unknown, err - } - - return s, nil -} - -func (v *Vagrant) Provider() (string, error) { - out, err := v.vagrantCommand().run("status", "--machine-readable") - if err != nil { - return "", err - } - - records, err := parseRecords(out) - if err != nil { - return "", v.error(err) - } - - provider, err := parseData(records, "provider-name") - if err != nil { - return "", v.error(err) - } - - return provider, nil -} - -// List returns all available boxes on the system. Under the hood it calls -// "global-status" and parses the output. -func (v *Vagrant) List() ([]*Vagrant, error) { - // Refresh box status cache. So it does not report that aborted - // box is running etc. - _, err := v.vagrantCommand().run("global-status", "--prune") - if err != nil { - return nil, err - } - out, err := v.vagrantCommand().run("global-status") - if err != nil { - return nil, err - } - - output := make([][]string, 0) - - scanner := bufio.NewScanner(strings.NewReader(out)) - collectStarted := false - - for scanner.Scan() { - if strings.HasPrefix(scanner.Text(), "--") { - scanner.Scan() // advance to next line - collectStarted = true - } - - if !collectStarted { - continue - } - - trimmedLine := strings.TrimSpace(scanner.Text()) - if trimmedLine == "" { - break // we are finished with collecting the boxes - } - - output = append(output, strings.Fields(trimmedLine)) - } - if err := scanner.Err(); err != nil { - return nil, v.error(err) - } - - boxes := make([]*Vagrant, len(output)) - - for i, box := range output { - // example box: [0c269f6 default virtualbox aborted /Users/fatih/path] - boxes[i] = &Vagrant{ - ID: box[0], - VagrantfilePath: box[len(box)-1], - State: box[3], - } - } - - return boxes, nil -} - -// Up executes "vagrant up" for the given vagrantfile. The returned channel -// contains the output stream. At the end of the output, the error is put into -// the Error field if there is any. -func (v *Vagrant) Up() (<-chan *CommandOutput, error) { - if v.ProviderName != "" { - return v.vagrantCommand().start("up", "--provider", v.ProviderName) - } - - return v.vagrantCommand().start("up") -} - -// Halt executes "vagrant halt". The returned reader contains the output -// stream. The client is responsible of calling the Close method of the -// returned reader. -func (v *Vagrant) Halt() (<-chan *CommandOutput, error) { - return v.vagrantCommand().start("halt") -} - -// Destroy executes "vagrant destroy". The returned reader contains the output -// stream. The client is responsible of calling the Close method of the -// returned reader. -func (v *Vagrant) Destroy() (<-chan *CommandOutput, error) { - if _, err := os.Stat(v.VagrantfilePath); os.IsNotExist(err) { - // Makes Destroy idempotent if called consecutively multiple times on - // the same path. - // - // Returning closed channel to not make existing like the one - // below hang: - // - // ch, err := vg.Destroy() - // if err != nil { - // ... - // } - // for line := range ch { - // ... - // } - // - ch := make(chan *CommandOutput) - close(ch) - - return ch, nil - } - - cmd := v.vagrantCommand() - cmd.onSuccess = func() { - // cleanup vagrant directory on success, as it's no longer needed; - // after destroy it should be not possible to call vagrant up - // again, call to Create is required first - if err := os.RemoveAll(v.VagrantfilePath); err != nil { - v.debugf("failed to cleanup %q after destroy: %s", v.VagrantfilePath, err) - } - - // We leave empty directory to not make other commands fail - // due to missing cwd. - // - // TODO(rjeczalik): rework lookup to use box id instead - if err := os.MkdirAll(v.VagrantfilePath, 0755); err != nil { - v.debugf("failed to create empty dir %q after destroy: %s", v.VagrantfilePath, err) - } - } - // if vagrant box is not created, return success - the destroy - // should be effectively a nop - cmd.ignoreErr = isNotCreated - - return cmd.start("destroy", "--force") -} - -var stripFmt = strings.NewReplacer("(", "", ",", "", ")", "") - -// BoxList executes "vagrant box list", parses the output and returns all -// available base boxes. -func (v *Vagrant) BoxList() ([]*Box, error) { - out, err := v.vagrantCommand().run("box", "list") - if err != nil { - return nil, err - } - - var boxes []*Box - scanner := bufio.NewScanner(strings.NewReader(out)) - - for scanner.Scan() { - line := strings.TrimSpace(stripFmt.Replace(scanner.Text())) - if line == "" { - continue - } - - var box Box - n, err := fmt.Sscanf(line, "%s %s %s", &box.Name, &box.Provider, &box.Version) - if err != nil { - return nil, v.errorf("%s for line: %s", err, line) - } - if n != 3 { - return nil, v.errorf("unable to parse output line: %s", line) - } - - boxes = append(boxes, &box) - } - if err := scanner.Err(); err != nil { - return nil, v.error(err) - } - - return boxes, nil -} - -// BoxAdd executes "vagrant box add" for the given box. The returned channel -// contains the output stream. At the end of the output, the error is put into -// the Error field if there is any. -// -// TODO(rjeczalik): BoxAdd does not support currently adding boxes directly -// from files. -func (v *Vagrant) BoxAdd(box *Box) (<-chan *CommandOutput, error) { - args := append([]string{"box", "add"}, toArgs(box)...) - return v.vagrantCommand().start(args...) -} - -// BoxRemove executes "vagrant box remove" for the given box. The returned channel -// contains the output stream. At the end of the output, the error is put into -// the Error field if there is any. -func (v *Vagrant) BoxRemove(box *Box) (<-chan *CommandOutput, error) { - args := append([]string{"box", "remove"}, toArgs(box)...) - return v.vagrantCommand().start(args...) -} - -// SSH executes "vagrant ssh" for the given vagrantfile. The returned channel -// contains the output stream. At the end of the output, the error is put into -// the Error field if there is any. -func (v *Vagrant) SSH(command string) (<-chan *CommandOutput, error) { - args := []string{"ssh", "-c", command} - return v.vagrantCommand().start(args...) -} - -// vagrantfile returns the Vagrantfile path -func (v *Vagrant) vagrantfile() string { - return filepath.Join(v.VagrantfilePath, "Vagrantfile") -} - -// vagrantfileExists checks if a Vagrantfile exists in the given path. It -// returns a nil error if exists. -func (v *Vagrant) vagrantfileExists() error { - if _, err := os.Stat(v.vagrantfile()); os.IsNotExist(err) { - return err - } - return nil -} - -// vagrantCommand creates a command which is setup to be run next to -// Vagrantfile -func (v *Vagrant) vagrantCommand() *command { - return newCommand(v.VagrantfilePath) -} - -func (v *Vagrant) debugf(format string, args ...interface{}) { - // if v.Log != nil { - log.Printf(format, args...) - // } -} - -func (v *Vagrant) errorf(format string, args ...interface{}) error { - err := fmt.Errorf(format, args...) - v.debugf("%s", err) - return err -} - -func (v *Vagrant) error(err error) error { - if err != nil { - v.debugf("%s", err) - } - return err -} - -// Runs "ssh-config" and returns the output. -func (v *Vagrant) SSHConfig() (string, error) { - out, err := v.vagrantCommand().run("ssh-config") - if err != nil { - return "", err - } - return out, nil -} - -// toArgs converts the given box to argument list for `vagrant box add/remove` -// commands -func toArgs(box *Box) (args []string) { - if box.Provider != "" { - args = append(args, "--provider", box.Provider) - } - if box.Version != "" { - args = append(args, "--box-version", box.Version) - } - return append(args, box.Name) -} - -// toStatus converts the given state string to Status type -func toStatus(state string) (Status, error) { - switch state { - case "running": - return Running, nil - case "not_created": - return NotCreated, nil - case "saved": - return Saved, nil - case "poweroff": - return PowerOff, nil - case "aborted": - return Aborted, nil - case "preparing": - return Preparing, nil - default: - return Unknown, fmt.Errorf("Unknown state: %s", state) - } - -} From 6ba28396bafb5a4ae0a4c9958fe16fae36c52ab9 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 09:39:47 -0500 Subject: [PATCH 03/15] Mark the art command hidden --- CHANGELOG.md | 1 + ziti/cmd/ziti/cmd/art.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5bbff075..2b89f7722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * The update command has been removed. It was non-functional, so this should not affect anyone * The adhoc, ping and playbook commands have been removed. These were ansible and vagrant commands that were not widely used. +* Make the art command hidden, doesn't need to be removed, leave it as an easter egg # Release 0.26.11 diff --git a/ziti/cmd/ziti/cmd/art.go b/ziti/cmd/ziti/cmd/art.go index 201befee3..7c2b5dd79 100644 --- a/ziti/cmd/ziti/cmd/art.go +++ b/ziti/cmd/ziti/cmd/art.go @@ -40,8 +40,9 @@ func NewCmdArt(out io.Writer, errOut io.Writer) *cobra.Command { } cmd := &cobra.Command{ - Use: "art", - Short: "Print the Ziti logo as ascii art :)", + Use: "art", + Short: "Print the Ziti logo as ascii art :)", + Hidden: true, Run: func(cmd *cobra.Command, args []string) { options.Cmd = cmd options.Args = args From 3e4e869ef680414e4a50bed25ca49021282bffff Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 10:05:19 -0500 Subject: [PATCH 04/15] Consolidate agent code under agentcli. Move ps command under agent. --- CHANGELOG.md | 1 + ziti/cmd/ziti/cmd/agent.go | 75 ----- ziti/cmd/ziti/cmd/agentcli/agent.go | 48 +++- .../cmd/{ => agentcli}/agent_ch_simple.go | 9 +- .../{ => agentcli}/agent_controller_init.go | 7 +- .../agent_controller_raft_join.go | 7 +- .../agent_controller_raft_list.go | 9 +- ziti/cmd/ziti/cmd/agentcli/agent_ps.go | 262 ++++++++++++++++++ .../{ => agentcli}/agent_router_add_route.go | 11 +- .../agent_router_forget_link.go | 9 +- .../ziti/cmd/{ => agentcli}/agent_simple.go | 7 +- ziti/cmd/ziti/cmd/cmd.go | 5 +- ziti/cmd/ziti/cmd/ps.go | 148 ---------- ziti/goprocess/gp.go | 141 ---------- ziti/util/util.go | 74 ----- 15 files changed, 338 insertions(+), 475 deletions(-) delete mode 100644 ziti/cmd/ziti/cmd/agent.go rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_ch_simple.go (94%) rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_controller_init.go (95%) rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_controller_raft_join.go (95%) rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_controller_raft_list.go (95%) create mode 100644 ziti/cmd/ziti/cmd/agentcli/agent_ps.go rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_router_add_route.go (94%) rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_router_forget_link.go (95%) rename ziti/cmd/ziti/cmd/{ => agentcli}/agent_simple.go (92%) delete mode 100644 ziti/cmd/ziti/cmd/ps.go delete mode 100644 ziti/goprocess/gp.go delete mode 100644 ziti/util/util.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b89f7722..7112ac11f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * The update command has been removed. It was non-functional, so this should not affect anyone * The adhoc, ping and playbook commands have been removed. These were ansible and vagrant commands that were not widely used. * Make the art command hidden, doesn't need to be removed, leave it as an easter egg +* Move ziti ps command under ziti agent. Remove all ziti ps subcommands, as they already exist as ziti agent subcommands # Release 0.26.11 diff --git a/ziti/cmd/ziti/cmd/agent.go b/ziti/cmd/ziti/cmd/agent.go deleted file mode 100644 index 932585ac7..000000000 --- a/ziti/cmd/ziti/cmd/agent.go +++ /dev/null @@ -1,75 +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 cmd - -import ( - "github.com/openziti/edge/router/debugops" - "github.com/openziti/fabric/controller" - "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/fabric/router" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/spf13/cobra" -) - -type AgentAppId byte - -const ( - AgentAppController = AgentAppId(controller.AgentAppId) - AgentAppRouter = AgentAppId(router.AgentAppId) -) - -func NewAgentCmd(p common.OptionsProvider) *cobra.Command { - agentCmd := agentcli.NewAgentCmd(p) - - ctrlCmd := &cobra.Command{ - Use: "controller", - Aliases: []string{"c"}, - Short: "Interact with a ziti-controller process using the IPC agent", - Run: func(cmd *cobra.Command, args []string) { - cmdhelper.CheckErr(cmd.Help()) - }, - } - - agentCmd.AddCommand(ctrlCmd) - ctrlCmd.AddCommand(NewSimpleChAgentCustomCmd("snapshot-db", AgentAppController, int32(mgmt_pb.ContentType_SnapshotDbRequestType), p)) - ctrlCmd.AddCommand(NewAgentCtrlRaftJoin(p)) - ctrlCmd.AddCommand(NewAgentCtrlRaftList(p)) - ctrlCmd.AddCommand(NewAgentCtrlInit(p)) - - routerCmd := &cobra.Command{ - Use: "router", - Aliases: []string{"r"}, - Short: "Interact with a ziti-router process using the IPC agent", - Run: func(cmd *cobra.Command, args []string) { - cmdhelper.CheckErr(cmd.Help()) - }, - } - - agentCmd.AddCommand(routerCmd) - - routerCmd.AddCommand(NewRouteCmd(p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-routes", AgentAppRouter, router.DumpForwarderTables, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("disconnect", AgentAppRouter, router.CloseControlChannel, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("reconnect", AgentAppRouter, router.OpenControlChannel, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-api-sessions", AgentAppRouter, debugops.DumpApiSessions, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-links", AgentAppRouter, router.DumpLinks, p)) - routerCmd.AddCommand(NewForgetLinkAgentCmd(p)) - - return agentCmd -} diff --git a/ziti/cmd/ziti/cmd/agentcli/agent.go b/ziti/cmd/ziti/cmd/agentcli/agent.go index 1a2920072..6c39b6ea7 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent.go @@ -1,8 +1,12 @@ package agentcli import ( - "github.com/openziti/channel/v2" "github.com/openziti/agent" + "github.com/openziti/channel/v2" + "github.com/openziti/edge/router/debugops" + "github.com/openziti/fabric/controller" + "github.com/openziti/fabric/pb/mgmt_pb" + "github.com/openziti/fabric/router" "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" @@ -11,6 +15,13 @@ import ( "time" ) +type AgentAppId byte + +const ( + AgentAppController = AgentAppId(controller.AgentAppId) + AgentAppRouter = AgentAppId(router.AgentAppId) +) + func NewAgentCmd(p common.OptionsProvider) *cobra.Command { agentCmd := &cobra.Command{ Use: "agent", @@ -20,6 +31,7 @@ func NewAgentCmd(p common.OptionsProvider) *cobra.Command { }, } + agentCmd.AddCommand(NewPsCmd(p)) agentCmd.AddCommand(NewGoVersionCmd(p)) agentCmd.AddCommand(NewGcCmd(p)) agentCmd.AddCommand(NewSetGcCmd(p)) @@ -33,6 +45,40 @@ func NewAgentCmd(p common.OptionsProvider) *cobra.Command { agentCmd.AddCommand(NewSetChannelLogLevelCmd(p)) agentCmd.AddCommand(NewClearChannelLogLevelCmd(p)) + ctrlCmd := &cobra.Command{ + Use: "controller", + Aliases: []string{"c"}, + Short: "Interact with a ziti-controller process using the IPC agent", + Run: func(cmd *cobra.Command, args []string) { + cmdhelper.CheckErr(cmd.Help()) + }, + } + + agentCmd.AddCommand(ctrlCmd) + ctrlCmd.AddCommand(NewSimpleChAgentCustomCmd("snapshot-db", AgentAppController, int32(mgmt_pb.ContentType_SnapshotDbRequestType), p)) + ctrlCmd.AddCommand(NewAgentCtrlRaftJoin(p)) + ctrlCmd.AddCommand(NewAgentCtrlRaftList(p)) + ctrlCmd.AddCommand(NewAgentCtrlInit(p)) + + routerCmd := &cobra.Command{ + Use: "router", + Aliases: []string{"r"}, + Short: "Interact with a ziti-router process using the IPC agent", + Run: func(cmd *cobra.Command, args []string) { + cmdhelper.CheckErr(cmd.Help()) + }, + } + + agentCmd.AddCommand(routerCmd) + + routerCmd.AddCommand(NewRouteCmd(p)) + routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-routes", AgentAppRouter, router.DumpForwarderTables, p)) + routerCmd.AddCommand(NewSimpleAgentCustomCmd("disconnect", AgentAppRouter, router.CloseControlChannel, p)) + routerCmd.AddCommand(NewSimpleAgentCustomCmd("reconnect", AgentAppRouter, router.OpenControlChannel, p)) + routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-api-sessions", AgentAppRouter, debugops.DumpApiSessions, p)) + routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-links", AgentAppRouter, router.DumpLinks, p)) + routerCmd.AddCommand(NewForgetLinkAgentCmd(p)) + return agentCmd } diff --git a/ziti/cmd/ziti/cmd/agent_ch_simple.go b/ziti/cmd/ziti/cmd/agentcli/agent_ch_simple.go similarity index 94% rename from ziti/cmd/ziti/cmd/agent_ch_simple.go rename to ziti/cmd/ziti/cmd/agentcli/agent_ch_simple.go index be69c8fd8..a95323274 100644 --- a/ziti/cmd/ziti/cmd/agent_ch_simple.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_ch_simple.go @@ -14,14 +14,13 @@ limitations under the License. */ -package cmd +package agentcli import ( "fmt" - "github.com/openziti/channel/v2" "github.com/openziti/agent" + "github.com/openziti/channel/v2" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -30,13 +29,13 @@ import ( ) type SimpleChAgentCmdOptions struct { - agentcli.AgentOptions + AgentOptions requestType int32 } func NewSimpleChAgentCustomCmd(name string, appId AgentAppId, op int32, p common.OptionsProvider) *cobra.Command { options := &SimpleChAgentCmdOptions{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, requestType: op, diff --git a/ziti/cmd/ziti/cmd/agent_controller_init.go b/ziti/cmd/ziti/cmd/agentcli/agent_controller_init.go similarity index 95% rename from ziti/cmd/ziti/cmd/agent_controller_init.go rename to ziti/cmd/ziti/cmd/agentcli/agent_controller_init.go index f67f8e96f..bf3dc5779 100644 --- a/ziti/cmd/ziti/cmd/agent_controller_init.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_controller_init.go @@ -14,7 +14,7 @@ limitations under the License. */ -package cmd +package agentcli import ( "fmt" @@ -23,7 +23,6 @@ import ( "github.com/openziti/channel/v2/protobufs" "github.com/openziti/edge/pb/edge_mgmt_pb" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -32,12 +31,12 @@ import ( ) type AgentCtrlInitOptions struct { - agentcli.AgentOptions + AgentOptions } func NewAgentCtrlInit(p common.OptionsProvider) *cobra.Command { options := &AgentCtrlInitOptions{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, } diff --git a/ziti/cmd/ziti/cmd/agent_controller_raft_join.go b/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_join.go similarity index 95% rename from ziti/cmd/ziti/cmd/agent_controller_raft_join.go rename to ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_join.go index 8aa981b28..d53141001 100644 --- a/ziti/cmd/ziti/cmd/agent_controller_raft_join.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_join.go @@ -14,7 +14,7 @@ limitations under the License. */ -package cmd +package agentcli import ( "fmt" @@ -23,7 +23,6 @@ import ( "github.com/openziti/fabric/controller" "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -32,14 +31,14 @@ import ( ) type AgentCtrlRaftJoinOptions struct { - agentcli.AgentOptions + AgentOptions Voter bool MemberId string } func NewAgentCtrlRaftJoin(p common.OptionsProvider) *cobra.Command { options := &AgentCtrlRaftJoinOptions{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, } diff --git a/ziti/cmd/ziti/cmd/agent_controller_raft_list.go b/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_list.go similarity index 95% rename from ziti/cmd/ziti/cmd/agent_controller_raft_list.go rename to ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_list.go index 46ff2e6d0..c615fe2fc 100644 --- a/ziti/cmd/ziti/cmd/agent_controller_raft_list.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_list.go @@ -14,16 +14,15 @@ limitations under the License. */ -package cmd +package agentcli import ( "fmt" "github.com/golang/protobuf/proto" + "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/agent" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -32,12 +31,12 @@ import ( ) type AgentCtrlRaftListOptions struct { - agentcli.AgentOptions + AgentOptions } func NewAgentCtrlRaftList(p common.OptionsProvider) *cobra.Command { options := &AgentCtrlRaftListOptions{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, } diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_ps.go b/ziti/cmd/ziti/cmd/agentcli/agent_ps.go new file mode 100644 index 000000000..f29666c8c --- /dev/null +++ b/ziti/cmd/ziti/cmd/agentcli/agent_ps.go @@ -0,0 +1,262 @@ +/* + 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 agentcli + +import ( + "bytes" + "fmt" + "github.com/keybase/go-ps" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "os" + "os/user" + "path/filepath" + "regexp" + goversion "rsc.io/goversion/version" + "runtime" + "strconv" + "strings" + "sync" + + cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" +) + +type AgentPsAction struct { + AgentOptions +} + +// NewPsCmd Pss a command object for the "Ps" command +func NewPsCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentPsAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), + }, + } + + cmd := &cobra.Command{ + Use: "ps", + Short: "Show Ziti process info", + Long: "Show information about currently running Ziti processes", + Run: func(cmd *cobra.Command, args []string) { + action.Cmd = cmd + action.Args = args + err := action.Run() + cmdhelper.CheckErr(err) + }, + } + + return cmd +} + +// Run implements this command +func (self *AgentPsAction) Run() error { + fmt.Println("ps is running") + ps := FindAll() + + var maxPID, maxPPID, maxExec, maxVersion int + for i, p := range ps { + + fmt.Println("p.Path is: " + p.Path) + + ps[i].BuildVersion = shortenVersion(p.BuildVersion) + maxPID = max(maxPID, len(strconv.Itoa(p.PID))) + maxPPID = max(maxPPID, len(strconv.Itoa(p.PPID))) + maxExec = max(maxExec, len(p.Exec)) + maxVersion = max(maxVersion, len(ps[i].BuildVersion)) + + } + + for _, p := range ps { + buf := bytes.NewBuffer(nil) + pid := strconv.Itoa(p.PID) + fmt.Fprint(buf, pad(pid, maxPID)) + fmt.Fprint(buf, " ") + + ppid := strconv.Itoa(p.PPID) + fmt.Fprint(buf, pad(ppid, maxPPID)) + fmt.Fprint(buf, " ") + + fmt.Fprint(buf, pad(p.Exec, maxExec)) + + if p.Agent { + fmt.Fprint(buf, "*") + } else { + fmt.Fprint(buf, " ") + } + fmt.Fprint(buf, " ") + + fmt.Fprint(buf, pad(p.BuildVersion, maxVersion)) + fmt.Fprint(buf, " ") + + fmt.Fprint(buf, p.Path) + fmt.Fprintln(buf) + buf.WriteTo(os.Stdout) + } + + return nil +} + +var develRe = regexp.MustCompile(`devel\s+\+\w+`) + +func shortenVersion(v string) string { + if !strings.HasPrefix(v, "devel") { + return v + } + results := develRe.FindAllString(v, 1) + if len(results) == 0 { + return v + } + return results[0] +} + +func pad(s string, total int) string { + if len(s) >= total { + return s + } + return s + strings.Repeat(" ", total-len(s)) +} + +func max(i, j int) int { + if i > j { + return i + } + return j +} + +// P represents a Go process. +type P struct { + PID int + PPID int + Exec string + Path string + BuildVersion string + Agent bool +} + +// FindAll returns all the Ziti processes currently running on this host. +func FindAll() []P { + pss, err := ps.Processes() + // fmt.Println("FindAll, err is: %s", err) + + if err != nil { + return nil + } + + var wg sync.WaitGroup + wg.Add(len(pss)) + found := make(chan P) + + for _, pr := range pss { + pr := pr + go func() { + defer wg.Done() + + path, version, agent, ok, err := isGo(pr) + if err != nil { + // TODO(jbd): Return a list of errors. + } + if !ok { + return + } + if isZiti(pr) { + found <- P{ + PID: pr.Pid(), + PPID: pr.PPid(), + Exec: pr.Executable(), + Path: path, + BuildVersion: version, + Agent: agent, + } + } + }() + } + go func() { + wg.Wait() + close(found) + }() + var results []P + for p := range found { + results = append(results, p) + } + return results +} + +// isGo looks up the runtime.buildVersion symbol +// in the process' binary and determines if the process +// if a Go process or not. If the process is a Go process, +// it reports PID, binary name and full path of the binary. +func isGo(pr ps.Process) (path, version string, agent, ok bool, err error) { + if pr.Pid() == 0 { + // ignore system process + return + } + path, err = pr.Path() + if err != nil { + return + } + var versionInfo goversion.Version + versionInfo, err = goversion.ReadExe(path) + if err != nil { + return + } + ok = true + version = versionInfo.Release + pidfile, err := PIDFile(pr.Pid()) + if err == nil { + _, err := os.Stat(pidfile) + agent = err == nil + } + return path, version, agent, ok, nil +} + +const gopsConfigDirEnvKey = "GOPS_CONFIG_DIR" + +func ConfigDir() (string, error) { + if configDir := os.Getenv(gopsConfigDirEnvKey); configDir != "" { + return configDir, nil + } + + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("APPDATA"), "gops"), nil + } + homeDir := guessUnixHomeDir() + if homeDir == "" { + return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty") + } + return filepath.Join(homeDir, ".config", "gops"), nil +} + +func guessUnixHomeDir() string { + usr, err := user.Current() + if err == nil { + return usr.HomeDir + } + return os.Getenv("HOME") +} + +func PIDFile(pid int) (string, error) { + gopsdir, err := ConfigDir() + if err != nil { + return "", err + } + return fmt.Sprintf("%s/%d", gopsdir, pid), nil +} + +func isZiti(pr ps.Process) (ok bool) { + return strings.HasPrefix(pr.Executable(), "ziti") +} diff --git a/ziti/cmd/ziti/cmd/agent_router_add_route.go b/ziti/cmd/ziti/cmd/agentcli/agent_router_add_route.go similarity index 94% rename from ziti/cmd/ziti/cmd/agent_router_add_route.go rename to ziti/cmd/ziti/cmd/agentcli/agent_router_add_route.go index 5277ae8b4..c604c20ae 100644 --- a/ziti/cmd/ziti/cmd/agent_router_add_route.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_router_add_route.go @@ -14,29 +14,28 @@ limitations under the License. */ -package cmd +package agentcli import ( "encoding/binary" - "google.golang.org/protobuf/proto" + "github.com/openziti/agent" "github.com/openziti/fabric/pb/ctrl_pb" "github.com/openziti/fabric/router" - "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" + "google.golang.org/protobuf/proto" "os" ) type AgentRouteAction struct { - agentcli.AgentOptions + AgentOptions CtrlListener string } func NewRouteCmd(p common.OptionsProvider) *cobra.Command { options := &AgentRouteAction{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, } diff --git a/ziti/cmd/ziti/cmd/agent_router_forget_link.go b/ziti/cmd/ziti/cmd/agentcli/agent_router_forget_link.go similarity index 95% rename from ziti/cmd/ziti/cmd/agent_router_forget_link.go rename to ziti/cmd/ziti/cmd/agentcli/agent_router_forget_link.go index e8a7e70dd..8895ac0fd 100644 --- a/ziti/cmd/ziti/cmd/agent_router_forget_link.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_router_forget_link.go @@ -14,16 +14,15 @@ limitations under the License. */ -package cmd +package agentcli import ( "fmt" + "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/fabric/router" - "github.com/openziti/agent" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -32,12 +31,12 @@ import ( ) type ForgetLinkAgentAction struct { - agentcli.AgentOptions + AgentOptions } func NewForgetLinkAgentCmd(p common.OptionsProvider) *cobra.Command { options := &ForgetLinkAgentAction{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, } diff --git a/ziti/cmd/ziti/cmd/agent_simple.go b/ziti/cmd/ziti/cmd/agentcli/agent_simple.go similarity index 92% rename from ziti/cmd/ziti/cmd/agent_simple.go rename to ziti/cmd/ziti/cmd/agentcli/agent_simple.go index 7aa4e20ad..a0fbded07 100644 --- a/ziti/cmd/ziti/cmd/agent_simple.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_simple.go @@ -14,11 +14,10 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -26,12 +25,12 @@ import ( ) type SimpleAgentAction struct { - agentcli.AgentOptions + AgentOptions } func NewSimpleAgentCustomCmd(name string, appId AgentAppId, op byte, p common.OptionsProvider) *cobra.Command { action := &SimpleAgentAction{ - AgentOptions: agentcli.AgentOptions{ + AgentOptions: AgentOptions{ CommonOptions: p(), }, } diff --git a/ziti/cmd/ziti/cmd/cmd.go b/ziti/cmd/ziti/cmd/cmd.go index 7ff1a2cb6..d2c1bffa1 100644 --- a/ziti/cmd/ziti/cmd/cmd.go +++ b/ziti/cmd/ziti/cmd/cmd.go @@ -19,6 +19,7 @@ package cmd import ( goflag "flag" "fmt" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" "io" "os" "path/filepath" @@ -124,8 +125,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com initCommands := NewCmdInit(out, err) createCommands := NewCmdCreate(out, err) executeCommands := NewCmdExecute(out, err) - agentCommands := NewAgentCmd(p) - psCommands := NewCmdPs(p) + agentCommands := agentcli.NewAgentCmd(p) pkiCommands := NewCmdPKI(out, err) fabricCommand := fabric.NewFabricCmd(p) edgeCommand := edge.NewCmdEdge(out, err) @@ -158,7 +158,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com Commands: []*cobra.Command{ executeCommands, agentCommands, - psCommands, pkiCommands, unwrapIdentityFileCommand, }, diff --git a/ziti/cmd/ziti/cmd/ps.go b/ziti/cmd/ziti/cmd/ps.go deleted file mode 100644 index b4ebb67b6..000000000 --- a/ziti/cmd/ziti/cmd/ps.go +++ /dev/null @@ -1,148 +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 cmd - -import ( - "bytes" - "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/spf13/cobra" - "os" - "regexp" - "strconv" - "strings" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/goprocess" -) - -type PsAction struct { - agentcli.AgentOptions -} - -// NewCmdPs Pss a command object for the "Ps" command -func NewCmdPs(p common.OptionsProvider) *cobra.Command { - action := &PsAction{ - AgentOptions: agentcli.AgentOptions{ - CommonOptions: p(), - }, - } - - cmd := &cobra.Command{ - Use: "ps", - Short: "Show Ziti process info", - Long: "Show information about currently running Ziti preocesses", - Run: func(cmd *cobra.Command, args []string) { - action.Cmd = cmd - action.Args = args - err := action.Run() - cmdhelper.CheckErr(err) - }, - } - - cmd.AddCommand(agentcli.NewGetCmd(p)) - cmd.AddCommand(agentcli.NewGoVersionCmd(p)) - cmd.AddCommand(agentcli.NewGcCmd(p)) - cmd.AddCommand(agentcli.NewSetGcCmd(p)) - cmd.AddCommand(agentcli.NewStackCmd(p)) - cmd.AddCommand(agentcli.NewMemstatsCmd(p)) - cmd.AddCommand(agentcli.NewStatsCmd(p)) - cmd.AddCommand(agentcli.NewPprofHeapCmd(p)) - cmd.AddCommand(agentcli.NewPprofCpuCmd(p)) - cmd.AddCommand(agentcli.NewTraceCmd(p)) - cmd.AddCommand(agentcli.NewSetLogLevelCmd(p)) - cmd.AddCommand(agentcli.NewSetChannelLogLevelCmd(p)) - cmd.AddCommand(agentcli.NewClearChannelLogLevelCmd(p)) - - return cmd -} - -// Run implements this command -func (self *PsAction) Run() error { - fmt.Println("ps is running") - ps := goprocess.FindAll() - - var maxPID, maxPPID, maxExec, maxVersion int - for i, p := range ps { - - fmt.Println("p.Path is: " + p.Path) - - ps[i].BuildVersion = shortenVersion(p.BuildVersion) - maxPID = max(maxPID, len(strconv.Itoa(p.PID))) - maxPPID = max(maxPPID, len(strconv.Itoa(p.PPID))) - maxExec = max(maxExec, len(p.Exec)) - maxVersion = max(maxVersion, len(ps[i].BuildVersion)) - - } - - for _, p := range ps { - buf := bytes.NewBuffer(nil) - pid := strconv.Itoa(p.PID) - fmt.Fprint(buf, pad(pid, maxPID)) - fmt.Fprint(buf, " ") - - ppid := strconv.Itoa(p.PPID) - fmt.Fprint(buf, pad(ppid, maxPPID)) - fmt.Fprint(buf, " ") - - fmt.Fprint(buf, pad(p.Exec, maxExec)) - - if p.Agent { - fmt.Fprint(buf, "*") - } else { - fmt.Fprint(buf, " ") - } - fmt.Fprint(buf, " ") - - fmt.Fprint(buf, pad(p.BuildVersion, maxVersion)) - fmt.Fprint(buf, " ") - - fmt.Fprint(buf, p.Path) - fmt.Fprintln(buf) - buf.WriteTo(os.Stdout) - } - - return nil -} - -var develRe = regexp.MustCompile(`devel\s+\+\w+`) - -func shortenVersion(v string) string { - if !strings.HasPrefix(v, "devel") { - return v - } - results := develRe.FindAllString(v, 1) - if len(results) == 0 { - return v - } - return results[0] -} - -func pad(s string, total int) string { - if len(s) >= total { - return s - } - return s + strings.Repeat(" ", total-len(s)) -} - -func max(i, j int) int { - if i > j { - return i - } - return j -} diff --git a/ziti/goprocess/gp.go b/ziti/goprocess/gp.go deleted file mode 100644 index 65ea71b4f..000000000 --- a/ziti/goprocess/gp.go +++ /dev/null @@ -1,141 +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 goprocess - -import ( - // "fmt" - "os" - "strings" - "sync" - - goversion "rsc.io/goversion/version" - - "github.com/openziti/ziti/ziti/util" - ps "github.com/keybase/go-ps" -) - -// P represents a Go process. -type P struct { - PID int - PPID int - Exec string - Path string - BuildVersion string - Agent bool -} - -// FindAll returns all the Ziti processes currently running on this host. -func FindAll() []P { - pss, err := ps.Processes() - // fmt.Println("FindAll, err is: %s", err) - - if err != nil { - return nil - } - - var wg sync.WaitGroup - wg.Add(len(pss)) - found := make(chan P) - - for _, pr := range pss { - pr := pr - go func() { - defer wg.Done() - - path, version, agent, ok, err := isGo(pr) - if err != nil { - // TODO(jbd): Return a list of errors. - } - if !ok { - return - } - if isZiti(pr) { - found <- P{ - PID: pr.Pid(), - PPID: pr.PPid(), - Exec: pr.Executable(), - Path: path, - BuildVersion: version, - Agent: agent, - } - } - }() - } - go func() { - wg.Wait() - close(found) - }() - var results []P - for p := range found { - results = append(results, p) - } - return results -} - -// Find finds info about the process identified with the given PID. -func Find(pid int) (p P, ok bool, err error) { - pr, err := ps.FindProcess(pid) - if err != nil { - return P{}, false, err - } - path, version, agent, ok, err := isGo(pr) - if !ok { - return P{}, false, nil - } - return P{ - PID: pr.Pid(), - PPID: pr.PPid(), - Exec: pr.Executable(), - Path: path, - BuildVersion: version, - Agent: agent, - }, true, nil -} - -// isGo looks up the runtime.buildVersion symbol -// in the process' binary and determines if the process -// if a Go process or not. If the process is a Go process, -// it reports PID, binary name and full path of the binary. -func isGo(pr ps.Process) (path, version string, agent, ok bool, err error) { - if pr.Pid() == 0 { - // ignore system process - return - } - path, err = pr.Path() - if err != nil { - return - } - var versionInfo goversion.Version - versionInfo, err = goversion.ReadExe(path) - if err != nil { - return - } - ok = true - version = versionInfo.Release - pidfile, err := util.PIDFile(pr.Pid()) - if err == nil { - _, err := os.Stat(pidfile) - agent = err == nil - } - return path, version, agent, ok, nil -} - -func isZiti(pr ps.Process) (ok bool) { - // fmt.Println("isZiti, pr.Executable(): %s", pr.Executable()) - - return strings.HasPrefix(pr.Executable(), "ziti-") -} diff --git a/ziti/util/util.go b/ziti/util/util.go deleted file mode 100644 index e20959678..000000000 --- a/ziti/util/util.go +++ /dev/null @@ -1,74 +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 ( - "errors" - "fmt" - "io/ioutil" - "os" - "os/user" - "path/filepath" - "runtime" - "strings" -) - -const gopsConfigDirEnvKey = "GOPS_CONFIG_DIR" - -func ConfigDir() (string, error) { - if configDir := os.Getenv(gopsConfigDirEnvKey); configDir != "" { - return configDir, nil - } - - if runtime.GOOS == "windows" { - return filepath.Join(os.Getenv("APPDATA"), "gops"), nil - } - homeDir := guessUnixHomeDir() - if homeDir == "" { - return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty") - } - return filepath.Join(homeDir, ".config", "gops"), nil -} - -func guessUnixHomeDir() string { - usr, err := user.Current() - if err == nil { - return usr.HomeDir - } - return os.Getenv("HOME") -} - -func PIDFile(pid int) (string, error) { - gopsdir, err := ConfigDir() - if err != nil { - return "", err - } - return fmt.Sprintf("%s/%d", gopsdir, pid), nil -} - -func GetPort(pid int) (string, error) { - portfile, err := PIDFile(pid) - if err != nil { - return "", err - } - b, err := ioutil.ReadFile(portfile) - if err != nil { - return "", err - } - port := strings.TrimSpace(string(b)) - return port, nil -} From 6068ca0beae3be53ee91183491a4dfee848fd3f7 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 10:43:57 -0500 Subject: [PATCH 05/15] Flatten ziti tree. Move ziti/cmd/ziti/* -> ziti/ --- common/enrollment/enroll.go | 4 +- doc/003-local-deploy.md | 15 ++++-- ziti-controller/main.go | 4 +- ziti-router/main.go | 4 +- ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go | 8 +-- ziti/cmd/{ziti/cmd => }/agentcli/agent.go | 4 +- .../cmd => }/agentcli/agent_ch_simple.go | 4 +- .../agentcli/agent_clear_channel_log_level.go | 4 +- .../agentcli/agent_controller_init.go | 4 +- .../agentcli/agent_controller_raft_join.go | 4 +- .../agentcli/agent_controller_raft_list.go | 4 +- ziti/cmd/{ziti/cmd => }/agentcli/agent_gc.go | 4 +- ziti/cmd/{ziti/cmd => }/agentcli/agent_get.go | 7 ++- .../agentcli/agent_go_version_action.go | 4 +- .../{ziti/cmd => }/agentcli/agent_memstats.go | 4 +- .../cmd => }/agentcli/agent_pprof_cpu.go | 4 +- .../cmd => }/agentcli/agent_pprof_heap.go | 4 +- ziti/cmd/{ziti/cmd => }/agentcli/agent_ps.go | 5 +- .../agentcli/agent_router_add_route.go | 4 +- .../agentcli/agent_router_forget_link.go | 4 +- .../agentcli/agent_set_channel_log_level.go | 4 +- .../cmd => }/agentcli/agent_set_log_level.go | 4 +- .../{ziti/cmd => }/agentcli/agent_setgc.go | 4 +- .../{ziti/cmd => }/agentcli/agent_simple.go | 4 +- .../{ziti/cmd => }/agentcli/agent_stack.go | 4 +- .../{ziti/cmd => }/agentcli/agent_stats.go | 4 +- .../{ziti/cmd => }/agentcli/agent_trace.go | 4 +- ziti/cmd/{ziti/cmd => }/api/delete.go | 2 +- ziti/cmd/{ziti/cmd => }/api/json.go | 0 ziti/cmd/{ziti/cmd => }/api/list.go | 2 +- ziti/cmd/{ziti/cmd => }/api/options.go | 2 +- ziti/cmd/{ziti/cmd => }/api/ws.go | 2 +- ziti/cmd/{ziti/cmd => }/art.go | 5 +- ziti/cmd/{ziti/cmd => }/cmd.go | 25 ++++----- ziti/cmd/{ziti/cmd => }/color/color.go | 2 +- ziti/cmd/{ziti/cmd => }/common.go | 0 ziti/cmd/{ziti/cmd => }/common/options.go | 0 ziti/cmd/{ziti/cmd => }/common_commands.go | 5 +- ziti/cmd/{ziti/cmd => }/common_init.go | 4 +- ziti/cmd/{ziti/cmd => }/common_install.go | 6 +-- .../cmd/{ziti/cmd => }/common_install_test.go | 2 +- .../cmd => }/config_templates/controller.yml | 0 .../cmd => }/config_templates/environment.yml | 0 .../cmd => }/config_templates/router.yml | 0 ziti/cmd/{ziti/cmd => }/create.go | 5 +- ziti/cmd/{ziti/cmd => }/create_config.go | 32 ++++++------ .../cmd => }/create_config_controller.go | 28 +++++----- .../cmd => }/create_config_controller_test.go | 0 .../cmd => }/create_config_environment.go | 6 +-- .../{ziti/cmd => }/create_config_router.go | 2 +- .../cmd => }/create_config_router_common.go | 5 +- .../cmd => }/create_config_router_edge.go | 4 +- .../create_config_router_edge_test.go | 2 +- .../cmd => }/create_config_router_fabric.go | 4 +- .../create_config_router_fabric_test.go | 2 +- .../cmd => }/create_config_router_test.go | 2 +- ziti/cmd/{ziti/cmd => }/create_config_test.go | 0 ziti/cmd/{ziti/cmd => }/create_environment.go | 6 +-- ziti/cmd/{ziti/cmd => }/database/cmd.go | 2 +- ziti/cmd/{ziti/cmd => }/demo/echo-notes.txt | 0 ziti/cmd/{ziti/cmd => }/demo/echo_server.go | 2 +- .../demo/echo_server_update_terminator.go | 8 +-- ziti/cmd/{ziti/cmd => }/demo/root.go | 6 +-- ziti/cmd/{ziti/cmd => }/demo/setup-client.go | 8 +-- ...up-multi-router-tunneler-hosted-service.go | 8 +-- .../cmd => }/demo/setup-multi-sdk-service.go | 8 +-- .../setup-multi-tunneler-hosted-service.go | 8 +-- .../demo/setup-router-tunneler-both-sides.go | 8 +-- .../multi-router-tunneler-hosted.md | 0 .../demo/setup-scripts/multi-sdk-hosted.md | 0 .../setup-scripts/multi-tunneler-hosted.md | 0 .../router-tunneler-both-sides.md | 0 .../cmd => }/demo/setup-scripts/sdk-client.md | 0 .../single-router-tunneler-hosted.md | 0 .../demo/setup-scripts/single-sdk-hosted.md | 0 .../update-config-addressable.md | 0 .../demo/setup-scripts/update-config-ha.md | 0 ...p-single-router-tunneler-hosted-service.go | 8 +-- .../cmd => }/demo/setup-single-sdk-service.go | 8 +-- .../demo/setup-update-config-addressable.go | 8 +-- .../cmd => }/demo/setup-update-config-ha.go | 8 +-- ziti/cmd/{ziti/cmd => }/demo/zcat.go | 0 ziti/cmd/{ziti/cmd => }/edge/common.go | 2 +- ziti/cmd/{ziti/cmd => }/edge/create.go | 6 +-- .../cmd => }/edge/create_authenticator.go | 4 +- .../edge/create_authenticator_updb.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/create_ca.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/create_config.go | 6 +-- .../{ziti/cmd => }/edge/create_config_type.go | 6 +-- .../{ziti/cmd => }/edge/create_edge_router.go | 7 ++- .../edge/create_edge_router_policy.go | 6 +-- .../{ziti/cmd => }/edge/create_enrollment.go | 8 +-- .../{ziti/cmd => }/edge/create_identity.go | 6 +-- .../cmd => }/edge/create_posture_check.go | 8 +-- .../cmd/{ziti/cmd => }/edge/create_service.go | 6 +-- .../edge/create_service_edge_router_policy.go | 6 +-- .../cmd => }/edge/create_service_policy.go | 6 +-- .../{ziti/cmd => }/edge/create_terminator.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/db.go | 2 +- .../{ziti/cmd => }/edge/db_check_integrity.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/db_snapshot.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/delete.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/detail.go | 2 +- .../cmd/{ziti/cmd => }/edge/encryption_var.go | 0 ziti/cmd/{ziti/cmd => }/edge/list.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/login.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/logout.go | 8 +-- .../cmd/{ziti/cmd => }/edge/policy_advisor.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/root.go | 5 +- ziti/cmd/{ziti/cmd => }/edge/show.go | 8 +-- .../cmd/{ziti/cmd => }/edge/trace_identity.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/traceroute.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/update.go | 6 +-- .../cmd => }/edge/update_authenticator.go | 4 +- .../edge/update_authenticator_updb.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/update_ca.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/update_config.go | 6 +-- .../{ziti/cmd => }/edge/update_config_type.go | 6 +-- .../{ziti/cmd => }/edge/update_edge_router.go | 7 ++- .../edge/update_edge_router_policy.go | 6 +-- .../{ziti/cmd => }/edge/update_identity.go | 6 +-- .../cmd => }/edge/update_identity_configs.go | 6 +-- .../cmd => }/edge/update_posture_check.go | 6 +-- .../cmd/{ziti/cmd => }/edge/update_service.go | 6 +-- .../edge/update_service_edge_router_policy.go | 6 +-- .../cmd => }/edge/update_service_policy.go | 6 +-- .../{ziti/cmd => }/edge/update_terminator.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/use.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/verify.go | 6 +-- ziti/cmd/{ziti/cmd => }/edge/verify_ca.go | 8 +-- ziti/cmd/{ziti/cmd => }/edge/version.go | 8 +-- ziti/cmd/{ziti/cmd => }/execute.go | 5 +- ziti/cmd/{ziti/cmd => }/execute_controller.go | 8 +-- .../cmd/{ziti/cmd => }/fabric/add_identity.go | 4 +- .../{ziti/cmd => }/fabric/create_router.go | 5 +- .../{ziti/cmd => }/fabric/create_service.go | 4 +- .../cmd => }/fabric/create_terminator.go | 8 +-- ziti/cmd/{ziti/cmd => }/fabric/db.go | 4 +- .../cmd => }/fabric/db_check_integrity.go | 8 +-- ziti/cmd/{ziti/cmd => }/fabric/db_snapshot.go | 8 +-- ziti/cmd/{ziti/cmd => }/fabric/delete.go | 8 +-- ziti/cmd/{ziti/cmd => }/fabric/inspect.go | 6 +-- ziti/cmd/{ziti/cmd => }/fabric/list.go | 8 +-- .../{ziti/cmd => }/fabric/remove_identity.go | 6 +-- ziti/cmd/{ziti/cmd => }/fabric/root.go | 8 +-- .../{ziti/cmd => }/fabric/stream_circuits.go | 6 +-- .../{ziti/cmd => }/fabric/stream_metrics.go | 4 +- .../fabric/stream_toggle_pipe_traces.go | 6 +-- .../{ziti/cmd => }/fabric/stream_traces.go | 6 +-- ziti/cmd/{ziti/cmd => }/fabric/update_link.go | 6 +-- .../{ziti/cmd => }/fabric/update_router.go | 9 ++-- .../{ziti/cmd => }/fabric/update_service.go | 8 +-- .../cmd => }/fabric/update_terminator.go | 8 +-- .../cmd/{ziti/cmd => }/helpers/env_helpers.go | 2 +- ziti/cmd/{ziti/cmd => }/helpers/helpers.go | 0 .../{ziti/cmd => }/helpers/helpers_test.go | 0 ziti/cmd/{ziti/cmd => }/init.go | 6 +-- ziti/cmd/{ziti/cmd => }/install.go | 4 +- ...tall_terraform_provider_edge_controller.go | 8 +-- ziti/cmd/{ziti/cmd => }/install_ziti_ALL.go | 8 +-- .../{ziti/cmd => }/install_ziti_controller.go | 8 +-- .../cmd => }/install_ziti_edge_tunnel.go | 8 +-- .../cmd/{ziti/cmd => }/install_ziti_prox_c.go | 8 +-- .../cmd/{ziti/cmd => }/install_ziti_router.go | 8 +-- .../cmd/{ziti/cmd => }/install_ziti_tunnel.go | 8 +-- .../{ziti/cmd => }/lets_encrypt/KeyTypeVar.go | 0 .../{ziti/cmd => }/lets_encrypt/account.go | 0 .../cmd => }/lets_encrypt/accounts_storage.go | 43 ++++++++------- .../cmd => }/lets_encrypt/certs_storage.go | 15 +++--- .../cmd/{ziti/cmd => }/lets_encrypt/create.go | 4 +- ziti/cmd/{ziti/cmd => }/lets_encrypt/list.go | 2 +- ziti/cmd/{ziti/cmd => }/lets_encrypt/renew.go | 4 +- .../cmd/{ziti/cmd => }/lets_encrypt/revoke.go | 4 +- ziti/cmd/{ziti/cmd => }/lets_encrypt/root.go | 2 +- ziti/cmd/{ziti/cmd => }/lets_encrypt/setup.go | 2 +- ziti/cmd/{ziti/cmd => }/log_filter.go | 2 +- ziti/cmd/{ziti/cmd => }/pki.go | 9 ++-- ziti/cmd/{ziti/cmd => }/pki_create.go | 4 +- ziti/cmd/{ziti/cmd => }/pki_create_ca.go | 11 ++-- ziti/cmd/{ziti/cmd => }/pki_create_client.go | 11 ++-- ziti/cmd/{ziti/cmd => }/pki_create_csr.go | 9 ++-- .../{ziti/cmd => }/pki_create_intermediate.go | 11 ++-- ziti/cmd/{ziti/cmd => }/pki_create_key.go | 9 ++-- ziti/cmd/{ziti/cmd => }/pki_create_server.go | 4 +- ziti/cmd/{ziti/cmd => }/table/padding.go | 0 ziti/cmd/{ziti/cmd => }/table/table.go | 0 .../cmd => }/templates/command_groups.go | 0 ziti/cmd/{ziti/cmd => }/templates/markdown.go | 0 .../{ziti/cmd => }/templates/normalizers.go | 0 .../cmd/{ziti/cmd => }/templates/templater.go | 2 +- .../cmd/{ziti/cmd => }/templates/templates.go | 0 .../tutorial/first-service-tutorial.go | 6 +-- .../cmd => }/tutorial/plain_echo_client.go | 0 .../tutorial/plain_echo_client_cmd.go | 4 +- .../cmd => }/tutorial/plain_echo_server.go | 0 .../tutorial/plain_echo_server_cmd.go | 4 +- ziti/cmd/{ziti/cmd => }/tutorial/root.go | 6 +-- .../tutorial/tutorials/first-service.md | 0 .../cmd => }/tutorial/tutorials/more-info.md | 0 .../cmd => }/tutorial/ziti_echo_client.go | 0 .../cmd => }/tutorial/ziti_echo_client_cmd.go | 4 +- .../cmd => }/tutorial/ziti_echo_server.go | 0 .../cmd => }/tutorial/ziti_echo_server_cmd.go | 4 +- ziti/cmd/{ziti/cmd => }/uninstall.go | 4 +- .../cmd => }/uninstall_ziti_controller.go | 6 +-- .../cmd => }/uninstall_ziti_edge_tunnel.go | 6 +-- .../{ziti/cmd => }/uninstall_ziti_proxy_c.go | 6 +-- .../{ziti/cmd => }/uninstall_ziti_router.go | 6 +-- .../{ziti/cmd => }/uninstall_ziti_tunnel.go | 6 +-- ziti/cmd/{ziti/cmd => }/unwrap_identity.go | 0 ziti/cmd/{ziti/cmd => }/upgrade.go | 4 +- ziti/cmd/{ziti/cmd => }/upgrade_ziti.go | 6 +-- .../{ziti/cmd => }/upgrade_ziti_controller.go | 6 +-- .../cmd => }/upgrade_ziti_edge_tunnel.go | 6 +-- .../cmd/{ziti/cmd => }/upgrade_ziti_prox_c.go | 6 +-- .../cmd/{ziti/cmd => }/upgrade_ziti_router.go | 6 +-- .../cmd/{ziti/cmd => }/upgrade_ziti_tunnel.go | 6 +-- ziti/cmd/{ziti/cmd => }/use.go | 8 +-- ziti/cmd/{ziti/cmd => }/version.go | 11 ++-- ziti/cmd/ziti/main.go | 25 --------- ziti/{cmd/ziti => }/constants/constants.go | 0 .../controller}/delete_sessions.go | 2 +- .../subcmd => ziti/controller}/root.go | 6 +-- .../subcmd => ziti/controller}/run.go | 2 +- .../subcmd => ziti/controller}/version.go | 4 +- ziti/{cmd/ziti => }/internal/log/log.go | 0 ziti/main.go | 52 +++++++++++++++++++ ziti/pki/pki/pki.go | 4 +- ziti/pki/store/local.go | 23 ++++---- ziti/pki/store/store.go | 3 +- .../subcmd => ziti/router}/enrollgw.go | 2 +- {ziti-router/subcmd => ziti/router}/root.go | 6 +-- {ziti-router/subcmd => ziti/router}/run.go | 2 +- .../subcmd => ziti/router}/version.go | 4 +- ziti/{cmd/ziti => }/util/certs.go | 2 +- ziti/{cmd/ziti => }/util/colors.go | 0 ziti/{cmd/ziti => }/util/commands.go | 3 +- ziti/{cmd/ziti => }/util/dirs.go | 0 ziti/{cmd/ziti => }/util/files.go | 0 ziti/{cmd/ziti => }/util/identities.go | 2 +- ziti/{cmd/ziti => }/util/pickers.go | 2 +- ziti/{cmd/ziti => }/util/rest.go | 4 +- ziti/{cmd/ziti => }/util/session.go | 0 ziti/{cmd/ziti => }/util/strings.go | 0 ziti/{cmd/ziti => }/util/suggestions.go | 0 ziti/{cmd/ziti => }/util/updates.go | 2 +- 246 files changed, 655 insertions(+), 650 deletions(-) rename ziti/cmd/{ziti/cmd => }/agentcli/agent.go (96%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_ch_simple.go (95%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_clear_channel_log_level.go (94%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_controller_init.go (95%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_controller_raft_join.go (95%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_controller_raft_list.go (95%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_gc.go (92%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_get.go (93%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_go_version_action.go (92%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_memstats.go (92%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_pprof_cpu.go (93%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_pprof_heap.go (92%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_ps.go (97%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_router_add_route.go (94%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_router_forget_link.go (95%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_set_channel_log_level.go (95%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_set_log_level.go (94%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_setgc.go (93%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_simple.go (92%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_stack.go (93%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_stats.go (92%) rename ziti/cmd/{ziti/cmd => }/agentcli/agent_trace.go (92%) rename ziti/cmd/{ziti/cmd => }/api/delete.go (97%) rename ziti/cmd/{ziti/cmd => }/api/json.go (100%) rename ziti/cmd/{ziti/cmd => }/api/list.go (99%) rename ziti/cmd/{ziti/cmd => }/api/options.go (97%) rename ziti/cmd/{ziti/cmd => }/api/ws.go (97%) rename ziti/cmd/{ziti/cmd => }/art.go (96%) rename ziti/cmd/{ziti/cmd => }/cmd.go (90%) rename ziti/cmd/{ziti/cmd => }/color/color.go (98%) rename ziti/cmd/{ziti/cmd => }/common.go (100%) rename ziti/cmd/{ziti/cmd => }/common/options.go (100%) rename ziti/cmd/{ziti/cmd => }/common_commands.go (97%) rename ziti/cmd/{ziti/cmd => }/common_init.go (97%) rename ziti/cmd/{ziti/cmd => }/common_install.go (98%) rename ziti/cmd/{ziti/cmd => }/common_install_test.go (95%) rename ziti/cmd/{ziti/cmd => }/config_templates/controller.yml (100%) rename ziti/cmd/{ziti/cmd => }/config_templates/environment.yml (100%) rename ziti/cmd/{ziti/cmd => }/config_templates/router.yml (100%) rename ziti/cmd/{ziti/cmd => }/create.go (92%) rename ziti/cmd/{ziti/cmd => }/create_config.go (91%) rename ziti/cmd/{ziti/cmd => }/create_config_controller.go (92%) rename ziti/cmd/{ziti/cmd => }/create_config_controller_test.go (100%) rename ziti/cmd/{ziti/cmd => }/create_config_environment.go (98%) rename ziti/cmd/{ziti/cmd => }/create_config_router.go (97%) rename ziti/cmd/{ziti/cmd => }/create_config_router_common.go (96%) rename ziti/cmd/{ziti/cmd => }/create_config_router_edge.go (97%) rename ziti/cmd/{ziti/cmd => }/create_config_router_edge_test.go (99%) rename ziti/cmd/{ziti/cmd => }/create_config_router_fabric.go (96%) rename ziti/cmd/{ziti/cmd => }/create_config_router_fabric_test.go (99%) rename ziti/cmd/{ziti/cmd => }/create_config_router_test.go (99%) rename ziti/cmd/{ziti/cmd => }/create_config_test.go (100%) rename ziti/cmd/{ziti/cmd => }/create_environment.go (92%) rename ziti/cmd/{ziti/cmd => }/database/cmd.go (93%) rename ziti/cmd/{ziti/cmd => }/demo/echo-notes.txt (100%) rename ziti/cmd/{ziti/cmd => }/demo/echo_server.go (100%) rename ziti/cmd/{ziti/cmd => }/demo/echo_server_update_terminator.go (93%) rename ziti/cmd/{ziti/cmd => }/demo/root.go (93%) rename ziti/cmd/{ziti/cmd => }/demo/setup-client.go (91%) rename ziti/cmd/{ziti/cmd => }/demo/setup-multi-router-tunneler-hosted-service.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/setup-multi-sdk-service.go (91%) rename ziti/cmd/{ziti/cmd => }/demo/setup-multi-tunneler-hosted-service.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/setup-router-tunneler-both-sides.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/multi-router-tunneler-hosted.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/multi-sdk-hosted.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/multi-tunneler-hosted.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/router-tunneler-both-sides.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/sdk-client.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/single-router-tunneler-hosted.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/single-sdk-hosted.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/update-config-addressable.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-scripts/update-config-ha.md (100%) rename ziti/cmd/{ziti/cmd => }/demo/setup-single-router-tunneler-hosted-service.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/setup-single-sdk-service.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/setup-update-config-addressable.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/setup-update-config-ha.go (92%) rename ziti/cmd/{ziti/cmd => }/demo/zcat.go (100%) rename ziti/cmd/{ziti/cmd => }/edge/common.go (98%) rename ziti/cmd/{ziti/cmd => }/edge/create.go (92%) rename ziti/cmd/{ziti/cmd => }/edge/create_authenticator.go (92%) rename ziti/cmd/{ziti/cmd => }/edge/create_authenticator_updb.go (96%) rename ziti/cmd/{ziti/cmd => }/edge/create_ca.go (96%) rename ziti/cmd/{ziti/cmd => }/edge/create_config.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/create_config_type.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/create_edge_router.go (96%) rename ziti/cmd/{ziti/cmd => }/edge/create_edge_router_policy.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/create_enrollment.go (96%) rename ziti/cmd/{ziti/cmd => }/edge/create_identity.go (97%) rename ziti/cmd/{ziti/cmd => }/edge/create_posture_check.go (99%) rename ziti/cmd/{ziti/cmd => }/edge/create_service.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/create_service_edge_router_policy.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/create_service_policy.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/create_terminator.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/db.go (88%) rename ziti/cmd/{ziti/cmd => }/edge/db_check_integrity.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/db_snapshot.go (87%) rename ziti/cmd/{ziti/cmd => }/edge/delete.go (96%) rename ziti/cmd/{ziti/cmd => }/edge/detail.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/encryption_var.go (100%) rename ziti/cmd/{ziti/cmd => }/edge/list.go (99%) rename ziti/cmd/{ziti/cmd => }/edge/login.go (97%) rename ziti/cmd/{ziti/cmd => }/edge/logout.go (89%) rename ziti/cmd/{ziti/cmd => }/edge/policy_advisor.go (98%) rename ziti/cmd/{ziti/cmd => }/edge/root.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/show.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/trace_identity.go (94%) rename ziti/cmd/{ziti/cmd => }/edge/traceroute.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_authenticator.go (92%) rename ziti/cmd/{ziti/cmd => }/edge/update_authenticator_updb.go (97%) rename ziti/cmd/{ziti/cmd => }/edge/update_ca.go (97%) rename ziti/cmd/{ziti/cmd => }/edge/update_config.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_config_type.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_edge_router.go (96%) rename ziti/cmd/{ziti/cmd => }/edge/update_edge_router_policy.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_identity.go (97%) rename ziti/cmd/{ziti/cmd => }/edge/update_identity_configs.go (93%) rename ziti/cmd/{ziti/cmd => }/edge/update_posture_check.go (98%) rename ziti/cmd/{ziti/cmd => }/edge/update_service.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_service_edge_router_policy.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_service_policy.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/update_terminator.go (95%) rename ziti/cmd/{ziti/cmd => }/edge/use.go (90%) rename ziti/cmd/{ziti/cmd => }/edge/verify.go (89%) rename ziti/cmd/{ziti/cmd => }/edge/verify_ca.go (97%) rename ziti/cmd/{ziti/cmd => }/edge/version.go (89%) rename ziti/cmd/{ziti/cmd => }/execute.go (93%) rename ziti/cmd/{ziti/cmd => }/execute_controller.go (92%) rename ziti/cmd/{ziti/cmd => }/fabric/add_identity.go (96%) rename ziti/cmd/{ziti/cmd => }/fabric/create_router.go (96%) rename ziti/cmd/{ziti/cmd => }/fabric/create_service.go (95%) rename ziti/cmd/{ziti/cmd => }/fabric/create_terminator.go (94%) rename ziti/cmd/{ziti/cmd => }/fabric/db.go (80%) rename ziti/cmd/{ziti/cmd => }/fabric/db_check_integrity.go (94%) rename ziti/cmd/{ziti/cmd => }/fabric/db_snapshot.go (87%) rename ziti/cmd/{ziti/cmd => }/fabric/delete.go (95%) rename ziti/cmd/{ziti/cmd => }/fabric/inspect.go (96%) rename ziti/cmd/{ziti/cmd => }/fabric/list.go (97%) rename ziti/cmd/{ziti/cmd => }/fabric/remove_identity.go (91%) rename ziti/cmd/{ziti/cmd => }/fabric/root.go (94%) rename ziti/cmd/{ziti/cmd => }/fabric/stream_circuits.go (96%) rename ziti/cmd/{ziti/cmd => }/fabric/stream_metrics.go (97%) rename ziti/cmd/{ziti/cmd => }/fabric/stream_toggle_pipe_traces.go (96%) rename ziti/cmd/{ziti/cmd => }/fabric/stream_traces.go (98%) rename ziti/cmd/{ziti/cmd => }/fabric/update_link.go (92%) rename ziti/cmd/{ziti/cmd => }/fabric/update_router.go (93%) rename ziti/cmd/{ziti/cmd => }/fabric/update_service.go (92%) rename ziti/cmd/{ziti/cmd => }/fabric/update_terminator.go (94%) rename ziti/cmd/{ziti/cmd => }/helpers/env_helpers.go (99%) rename ziti/cmd/{ziti/cmd => }/helpers/helpers.go (100%) rename ziti/cmd/{ziti/cmd => }/helpers/helpers_test.go (100%) rename ziti/cmd/{ziti/cmd => }/init.go (92%) rename ziti/cmd/{ziti/cmd => }/install.go (94%) rename ziti/cmd/{ziti/cmd => }/install_terraform_provider_edge_controller.go (92%) rename ziti/cmd/{ziti/cmd => }/install_ziti_ALL.go (92%) rename ziti/cmd/{ziti/cmd => }/install_ziti_controller.go (91%) rename ziti/cmd/{ziti/cmd => }/install_ziti_edge_tunnel.go (91%) rename ziti/cmd/{ziti/cmd => }/install_ziti_prox_c.go (91%) rename ziti/cmd/{ziti/cmd => }/install_ziti_router.go (91%) rename ziti/cmd/{ziti/cmd => }/install_ziti_tunnel.go (91%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/KeyTypeVar.go (100%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/account.go (100%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/accounts_storage.go (81%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/certs_storage.go (95%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/create.go (97%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/list.go (98%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/renew.go (97%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/revoke.go (96%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/root.go (97%) rename ziti/cmd/{ziti/cmd => }/lets_encrypt/setup.go (98%) rename ziti/cmd/{ziti/cmd => }/log_filter.go (96%) rename ziti/cmd/{ziti/cmd => }/pki.go (92%) rename ziti/cmd/{ziti/cmd => }/pki_create.go (99%) rename ziti/cmd/{ziti/cmd => }/pki_create_ca.go (96%) rename ziti/cmd/{ziti/cmd => }/pki_create_client.go (97%) rename ziti/cmd/{ziti/cmd => }/pki_create_csr.go (96%) rename ziti/cmd/{ziti/cmd => }/pki_create_intermediate.go (96%) rename ziti/cmd/{ziti/cmd => }/pki_create_key.go (96%) rename ziti/cmd/{ziti/cmd => }/pki_create_server.go (97%) rename ziti/cmd/{ziti/cmd => }/table/padding.go (100%) rename ziti/cmd/{ziti/cmd => }/table/table.go (100%) rename ziti/cmd/{ziti/cmd => }/templates/command_groups.go (100%) rename ziti/cmd/{ziti/cmd => }/templates/markdown.go (100%) rename ziti/cmd/{ziti/cmd => }/templates/normalizers.go (100%) rename ziti/cmd/{ziti/cmd => }/templates/templater.go (99%) rename ziti/cmd/{ziti/cmd => }/templates/templates.go (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/first-service-tutorial.go (96%) rename ziti/cmd/{ziti/cmd => }/tutorial/plain_echo_client.go (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/plain_echo_client_cmd.go (93%) rename ziti/cmd/{ziti/cmd => }/tutorial/plain_echo_server.go (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/plain_echo_server_cmd.go (93%) rename ziti/cmd/{ziti/cmd => }/tutorial/root.go (90%) rename ziti/cmd/{ziti/cmd => }/tutorial/tutorials/first-service.md (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/tutorials/more-info.md (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/ziti_echo_client.go (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/ziti_echo_client_cmd.go (93%) rename ziti/cmd/{ziti/cmd => }/tutorial/ziti_echo_server.go (100%) rename ziti/cmd/{ziti/cmd => }/tutorial/ziti_echo_server_cmd.go (93%) rename ziti/cmd/{ziti/cmd => }/uninstall.go (94%) rename ziti/cmd/{ziti/cmd => }/uninstall_ziti_controller.go (91%) rename ziti/cmd/{ziti/cmd => }/uninstall_ziti_edge_tunnel.go (91%) rename ziti/cmd/{ziti/cmd => }/uninstall_ziti_proxy_c.go (91%) rename ziti/cmd/{ziti/cmd => }/uninstall_ziti_router.go (91%) rename ziti/cmd/{ziti/cmd => }/uninstall_ziti_tunnel.go (91%) rename ziti/cmd/{ziti/cmd => }/unwrap_identity.go (100%) rename ziti/cmd/{ziti/cmd => }/upgrade.go (94%) rename ziti/cmd/{ziti/cmd => }/upgrade_ziti.go (92%) rename ziti/cmd/{ziti/cmd => }/upgrade_ziti_controller.go (93%) rename ziti/cmd/{ziti/cmd => }/upgrade_ziti_edge_tunnel.go (92%) rename ziti/cmd/{ziti/cmd => }/upgrade_ziti_prox_c.go (92%) rename ziti/cmd/{ziti/cmd => }/upgrade_ziti_router.go (92%) rename ziti/cmd/{ziti/cmd => }/upgrade_ziti_tunnel.go (92%) rename ziti/cmd/{ziti/cmd => }/use.go (94%) rename ziti/cmd/{ziti/cmd => }/version.go (95%) delete mode 100644 ziti/cmd/ziti/main.go rename ziti/{cmd/ziti => }/constants/constants.go (100%) rename {ziti-controller/subcmd => ziti/controller}/delete_sessions.go (99%) rename {ziti-controller/subcmd => ziti/controller}/root.go (95%) rename {ziti-controller/subcmd => ziti/controller}/run.go (99%) rename {ziti-controller/subcmd => ziti/controller}/version.go (97%) rename ziti/{cmd/ziti => }/internal/log/log.go (100%) create mode 100644 ziti/main.go rename {ziti-router/subcmd => ziti/router}/enrollgw.go (99%) rename {ziti-router/subcmd => ziti/router}/root.go (94%) rename {ziti-router/subcmd => ziti/router}/run.go (99%) rename {ziti-router/subcmd => ziti/router}/version.go (98%) rename ziti/{cmd/ziti => }/util/certs.go (98%) rename ziti/{cmd/ziti => }/util/colors.go (100%) rename ziti/{cmd/ziti => }/util/commands.go (98%) rename ziti/{cmd/ziti => }/util/dirs.go (100%) rename ziti/{cmd/ziti => }/util/files.go (100%) rename ziti/{cmd/ziti => }/util/identities.go (99%) rename ziti/{cmd/ziti => }/util/pickers.go (98%) rename ziti/{cmd/ziti => }/util/rest.go (99%) rename ziti/{cmd/ziti => }/util/session.go (100%) rename ziti/{cmd/ziti => }/util/strings.go (100%) rename ziti/{cmd/ziti => }/util/suggestions.go (100%) rename ziti/{cmd/ziti => }/util/updates.go (98%) diff --git a/common/enrollment/enroll.go b/common/enrollment/enroll.go index bb513da63..c4c45519a 100644 --- a/common/enrollment/enroll.go +++ b/common/enrollment/enroll.go @@ -19,16 +19,16 @@ package enrollment import ( "encoding/json" "fmt" + "github.com/openziti/ziti/ziti/cmd/common" "io/ioutil" "os" "strings" "github.com/michaelquigley/pfxlog" - "github.com/openziti/identity/certtools" "github.com/openziti/foundation/v2/term" + "github.com/openziti/identity/certtools" "github.com/openziti/sdk-golang/ziti/config" "github.com/openziti/sdk-golang/ziti/enroll" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/doc/003-local-deploy.md b/doc/003-local-deploy.md index 5b0e16d15..e720f7d14 100644 --- a/doc/003-local-deploy.md +++ b/doc/003-local-deploy.md @@ -1,6 +1,8 @@ # Overview -This local deployment README guides you to set up a running local Ziti stack. If you have not already built the apps in this repo you may go back to [the previous tutorial about getting set up for local development](./002-local-dev.md) for build instructions. The remainder of the tutorial will assume you have installed all the apps so they can be found in your shell's executable search `PATH`. +This local deployment README guides you to set up a running local Ziti stack. If you have not already built the apps in this repo you may go back +to [the previous tutorial about getting set up for local development](./002-local-dev.md) for build instructions. The remainder of the tutorial will assume you have installed all the apps so they can +be found in your shell's executable search `PATH`. You will configure and run: @@ -9,13 +11,15 @@ You will configure and run: ## A Note About Windows -These commands require a running BASH shell. Windows users will need to use WSL, [cygwin](https://www.cygwin.com/), a Linux virtual machine, or some other environment that supports BASH. The easiest thing might just be to use the shell that comes with [git bashfor windows](https://gitforwindows.org/). WSL is maturing more and more: [Mintty and WSL](https://github.com/mintty/wsltty). +These commands require a running BASH shell. Windows users will need to use WSL, [cygwin](https://www.cygwin.com/), a Linux virtual machine, or some other environment that supports BASH. The easiest +thing might just be to use the shell that comes with [git bashfor windows](https://gitforwindows.org/). WSL is maturing more and more: [Mintty and WSL](https://github.com/mintty/wsltty). Also note that commands for `ziti`, `ziti-controller`, and `ziti-router` may need to have the `.exe` suffix appended to the example commands. ## Initialize the Environment -The remainder of this local development tutorital will instruct you to run terminal commands with current working directory of the top-level of this checked-out repo. The generated configuration files will use filesystem paths that are relative to this directory. +The remainder of this local development tutorital will instruct you to run terminal commands with current working directory of the top-level of this checked-out repo. The generated configuration files +will use filesystem paths that are relative to this directory. Go ahead and create a `./db` directory. Git is configured to ignore this directory and it will house the tutorial files. You may delete this directory to reset the tutorial. @@ -93,7 +97,8 @@ ziti-router enroll --jwt /tmp/router01.jwt ./db/router01-config.yml ## Run the Edge Router -Edge SDKs will connect to the running edge router to connect to services. Leave the router process running in a terminal so you can monitor the log messages while you continue the tutorial in a new terminal. +Edge SDKs will connect to the running edge router to connect to services. Leave the router process running in a terminal so you can monitor the log messages while you continue the tutorial in a new +terminal. ```bash ziti-router run ./db/router01-config.yml @@ -109,7 +114,7 @@ When prompted, select your running edge router `router01`. ziti edge tutorial first-service ``` -If you prefer, you may read [the first-service tutorial as a web site](../ziti/cmd/ziti/cmd/tutorial/tutorials/first-service.md) +If you prefer, you may read [the first-service tutorial as a web site](../ziti/cmd/tutorial/tutorials/first-service.md) ## Further Exploration diff --git a/ziti-controller/main.go b/ziti-controller/main.go index abd968468..27439663f 100644 --- a/ziti-controller/main.go +++ b/ziti-controller/main.go @@ -26,7 +26,7 @@ import ( "github.com/openziti/transport/v2/transwarptls" "github.com/openziti/transport/v2/wss" "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti-controller/subcmd" + "github.com/openziti/ziti/ziti/controller" "github.com/sirupsen/logrus" ) @@ -44,5 +44,5 @@ func init() { } func main() { - subcmd.Execute() + controller.Execute() } diff --git a/ziti-router/main.go b/ziti-router/main.go index 9400fcaf7..cb261b26b 100644 --- a/ziti-router/main.go +++ b/ziti-router/main.go @@ -28,7 +28,7 @@ import ( "github.com/openziti/transport/v2/ws" "github.com/openziti/transport/v2/wss" "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti-router/subcmd" + "github.com/openziti/ziti/ziti/router" "github.com/sirupsen/logrus" ) @@ -48,5 +48,5 @@ func init() { } func main() { - subcmd.Execute() + router.Execute() } diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go index c26acceab..f3c737526 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go +++ b/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go @@ -17,24 +17,24 @@ package subcmd import ( + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/util" "io/ioutil" "os" "path/filepath" "time" "github.com/michaelquigley/pfxlog" + "github.com/openziti/agent" "github.com/openziti/edge/tunnel" "github.com/openziti/edge/tunnel/dns" "github.com/openziti/edge/tunnel/entities" "github.com/openziti/edge/tunnel/intercept" - "github.com/openziti/agent" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/config" "github.com/openziti/ziti/common/enrollment" "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent.go b/ziti/cmd/agentcli/agent.go similarity index 96% rename from ziti/cmd/ziti/cmd/agentcli/agent.go rename to ziti/cmd/agentcli/agent.go index 6c39b6ea7..320f87af5 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent.go +++ b/ziti/cmd/agentcli/agent.go @@ -8,8 +8,8 @@ import ( "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/fabric/router" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "net" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_ch_simple.go b/ziti/cmd/agentcli/agent_ch_simple.go similarity index 95% rename from ziti/cmd/ziti/cmd/agentcli/agent_ch_simple.go rename to ziti/cmd/agentcli/agent_ch_simple.go index a95323274..ac97ef999 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_ch_simple.go +++ b/ziti/cmd/agentcli/agent_ch_simple.go @@ -21,8 +21,8 @@ import ( "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "net" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_clear_channel_log_level.go b/ziti/cmd/agentcli/agent_clear_channel_log_level.go similarity index 94% rename from ziti/cmd/ziti/cmd/agentcli/agent_clear_channel_log_level.go rename to ziti/cmd/agentcli/agent_clear_channel_log_level.go index 33a433bfa..c307b00e7 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_clear_channel_log_level.go +++ b/ziti/cmd/agentcli/agent_clear_channel_log_level.go @@ -20,8 +20,8 @@ import ( "bytes" "encoding/binary" "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_controller_init.go b/ziti/cmd/agentcli/agent_controller_init.go similarity index 95% rename from ziti/cmd/ziti/cmd/agentcli/agent_controller_init.go rename to ziti/cmd/agentcli/agent_controller_init.go index bf3dc5779..ffe9b960c 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_controller_init.go +++ b/ziti/cmd/agentcli/agent_controller_init.go @@ -23,8 +23,8 @@ import ( "github.com/openziti/channel/v2/protobufs" "github.com/openziti/edge/pb/edge_mgmt_pb" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "net" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_join.go b/ziti/cmd/agentcli/agent_controller_raft_join.go similarity index 95% rename from ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_join.go rename to ziti/cmd/agentcli/agent_controller_raft_join.go index d53141001..bda3a55a5 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_join.go +++ b/ziti/cmd/agentcli/agent_controller_raft_join.go @@ -23,8 +23,8 @@ import ( "github.com/openziti/fabric/controller" "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "net" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_list.go b/ziti/cmd/agentcli/agent_controller_raft_list.go similarity index 95% rename from ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_list.go rename to ziti/cmd/agentcli/agent_controller_raft_list.go index c615fe2fc..4bf2176fb 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_controller_raft_list.go +++ b/ziti/cmd/agentcli/agent_controller_raft_list.go @@ -23,8 +23,8 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "net" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_gc.go b/ziti/cmd/agentcli/agent_gc.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_gc.go rename to ziti/cmd/agentcli/agent_gc.go index 4c3bc4d51..ad56c6db9 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_gc.go +++ b/ziti/cmd/agentcli/agent_gc.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_get.go b/ziti/cmd/agentcli/agent_get.go similarity index 93% rename from ziti/cmd/ziti/cmd/agentcli/agent_get.go rename to ziti/cmd/agentcli/agent_get.go index 2a8c9d1a3..ad2aca505 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_get.go +++ b/ziti/cmd/agentcli/agent_get.go @@ -18,14 +18,13 @@ package agentcli import ( "fmt" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "strconv" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" "github.com/shirou/gopsutil/v3/process" "github.com/spf13/cobra" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" ) type AgentGetOptionsAction struct { diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_go_version_action.go b/ziti/cmd/agentcli/agent_go_version_action.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_go_version_action.go rename to ziti/cmd/agentcli/agent_go_version_action.go index 46a18e16c..94e0a9099 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_go_version_action.go +++ b/ziti/cmd/agentcli/agent_go_version_action.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_memstats.go b/ziti/cmd/agentcli/agent_memstats.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_memstats.go rename to ziti/cmd/agentcli/agent_memstats.go index 7a0e8168f..8004b8eda 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_memstats.go +++ b/ziti/cmd/agentcli/agent_memstats.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_pprof_cpu.go b/ziti/cmd/agentcli/agent_pprof_cpu.go similarity index 93% rename from ziti/cmd/ziti/cmd/agentcli/agent_pprof_cpu.go rename to ziti/cmd/agentcli/agent_pprof_cpu.go index 23519c3fb..ad590e17e 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_pprof_cpu.go +++ b/ziti/cmd/agentcli/agent_pprof_cpu.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_pprof_heap.go b/ziti/cmd/agentcli/agent_pprof_heap.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_pprof_heap.go rename to ziti/cmd/agentcli/agent_pprof_heap.go index 79a817a2f..04776721c 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_pprof_heap.go +++ b/ziti/cmd/agentcli/agent_pprof_heap.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_ps.go b/ziti/cmd/agentcli/agent_ps.go similarity index 97% rename from ziti/cmd/ziti/cmd/agentcli/agent_ps.go rename to ziti/cmd/agentcli/agent_ps.go index f29666c8c..f88bb48e0 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_ps.go +++ b/ziti/cmd/agentcli/agent_ps.go @@ -20,7 +20,8 @@ import ( "bytes" "fmt" "github.com/keybase/go-ps" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/spf13/cobra" "os" @@ -32,8 +33,6 @@ import ( "strconv" "strings" "sync" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" ) type AgentPsAction struct { diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_router_add_route.go b/ziti/cmd/agentcli/agent_router_add_route.go similarity index 94% rename from ziti/cmd/ziti/cmd/agentcli/agent_router_add_route.go rename to ziti/cmd/agentcli/agent_router_add_route.go index c604c20ae..0cd14bd8e 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_router_add_route.go +++ b/ziti/cmd/agentcli/agent_router_add_route.go @@ -21,8 +21,8 @@ import ( "github.com/openziti/agent" "github.com/openziti/fabric/pb/ctrl_pb" "github.com/openziti/fabric/router" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "google.golang.org/protobuf/proto" "os" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_router_forget_link.go b/ziti/cmd/agentcli/agent_router_forget_link.go similarity index 95% rename from ziti/cmd/ziti/cmd/agentcli/agent_router_forget_link.go rename to ziti/cmd/agentcli/agent_router_forget_link.go index 8895ac0fd..1ed92255e 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_router_forget_link.go +++ b/ziti/cmd/agentcli/agent_router_forget_link.go @@ -23,8 +23,8 @@ import ( "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/fabric/router" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "net" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_set_channel_log_level.go b/ziti/cmd/agentcli/agent_set_channel_log_level.go similarity index 95% rename from ziti/cmd/ziti/cmd/agentcli/agent_set_channel_log_level.go rename to ziti/cmd/agentcli/agent_set_channel_log_level.go index 9b44f896c..a92e8dd11 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_set_channel_log_level.go +++ b/ziti/cmd/agentcli/agent_set_channel_log_level.go @@ -20,8 +20,8 @@ import ( "bytes" "encoding/binary" "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_set_log_level.go b/ziti/cmd/agentcli/agent_set_log_level.go similarity index 94% rename from ziti/cmd/ziti/cmd/agentcli/agent_set_log_level.go rename to ziti/cmd/agentcli/agent_set_log_level.go index d9148b3e4..be306648f 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_set_log_level.go +++ b/ziti/cmd/agentcli/agent_set_log_level.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_setgc.go b/ziti/cmd/agentcli/agent_setgc.go similarity index 93% rename from ziti/cmd/ziti/cmd/agentcli/agent_setgc.go rename to ziti/cmd/agentcli/agent_setgc.go index 513571a6a..ca1a9663d 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_setgc.go +++ b/ziti/cmd/agentcli/agent_setgc.go @@ -19,8 +19,8 @@ package agentcli import ( "encoding/binary" "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" "strconv" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_simple.go b/ziti/cmd/agentcli/agent_simple.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_simple.go rename to ziti/cmd/agentcli/agent_simple.go index a0fbded07..38701e896 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_simple.go +++ b/ziti/cmd/agentcli/agent_simple.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_stack.go b/ziti/cmd/agentcli/agent_stack.go similarity index 93% rename from ziti/cmd/ziti/cmd/agentcli/agent_stack.go rename to ziti/cmd/agentcli/agent_stack.go index 81e584df5..338a4a113 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_stack.go +++ b/ziti/cmd/agentcli/agent_stack.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" "time" diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_stats.go b/ziti/cmd/agentcli/agent_stats.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_stats.go rename to ziti/cmd/agentcli/agent_stats.go index 9f68d56a3..adeba86d4 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_stats.go +++ b/ziti/cmd/agentcli/agent_stats.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/agentcli/agent_trace.go b/ziti/cmd/agentcli/agent_trace.go similarity index 92% rename from ziti/cmd/ziti/cmd/agentcli/agent_trace.go rename to ziti/cmd/agentcli/agent_trace.go index 1e5bf7031..ac704a74a 100644 --- a/ziti/cmd/ziti/cmd/agentcli/agent_trace.go +++ b/ziti/cmd/agentcli/agent_trace.go @@ -18,8 +18,8 @@ package agentcli import ( "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) diff --git a/ziti/cmd/ziti/cmd/api/delete.go b/ziti/cmd/api/delete.go similarity index 97% rename from ziti/cmd/ziti/cmd/api/delete.go rename to ziti/cmd/api/delete.go index 1ef462d25..b245907b6 100644 --- a/ziti/cmd/ziti/cmd/api/delete.go +++ b/ziti/cmd/api/delete.go @@ -19,7 +19,7 @@ package api import ( "github.com/fatih/color" "github.com/openziti/storage/boltz" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/util" "net/url" "strings" ) diff --git a/ziti/cmd/ziti/cmd/api/json.go b/ziti/cmd/api/json.go similarity index 100% rename from ziti/cmd/ziti/cmd/api/json.go rename to ziti/cmd/api/json.go diff --git a/ziti/cmd/ziti/cmd/api/list.go b/ziti/cmd/api/list.go similarity index 99% rename from ziti/cmd/ziti/cmd/api/list.go rename to ziti/cmd/api/list.go index 58987d2dc..2eef77647 100644 --- a/ziti/cmd/ziti/cmd/api/list.go +++ b/ziti/cmd/api/list.go @@ -21,7 +21,7 @@ import ( "github.com/Jeffail/gabs" "github.com/jedib0t/go-pretty/v6/table" "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "io" "net/url" diff --git a/ziti/cmd/ziti/cmd/api/options.go b/ziti/cmd/api/options.go similarity index 97% rename from ziti/cmd/ziti/cmd/api/options.go rename to ziti/cmd/api/options.go index a10c23527..cda80e3de 100644 --- a/ziti/cmd/ziti/cmd/api/options.go +++ b/ziti/cmd/api/options.go @@ -19,7 +19,7 @@ package api import ( "fmt" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/api/ws.go b/ziti/cmd/api/ws.go similarity index 97% rename from ziti/cmd/ziti/cmd/api/ws.go rename to ziti/cmd/api/ws.go index d89e78541..5abcccb1d 100644 --- a/ziti/cmd/ziti/cmd/api/ws.go +++ b/ziti/cmd/api/ws.go @@ -23,7 +23,7 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/websockets" "github.com/openziti/identity" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/util" "io" "net/http" "strings" diff --git a/ziti/cmd/ziti/cmd/art.go b/ziti/cmd/art.go similarity index 96% rename from ziti/cmd/ziti/cmd/art.go rename to ziti/cmd/art.go index 7c2b5dd79..25caa7fb0 100644 --- a/ziti/cmd/ziti/cmd/art.go +++ b/ziti/cmd/art.go @@ -17,11 +17,10 @@ package cmd import ( - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/cmd.go b/ziti/cmd/cmd.go similarity index 90% rename from ziti/cmd/ziti/cmd/cmd.go rename to ziti/cmd/cmd.go index d2c1bffa1..53edfd8c3 100644 --- a/ziti/cmd/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -19,26 +19,23 @@ package cmd import ( goflag "flag" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" + "github.com/openziti/ziti/ziti/cmd/agentcli" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/database" + "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/templates" + "github.com/openziti/ziti/ziti/cmd/tutorial" + c "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/util" "io" "os" "path/filepath" "strings" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/database" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/demo" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/fabric" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" - - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/edge" - - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/cmd/ziti/util" - "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" "github.com/spf13/viper" ) diff --git a/ziti/cmd/ziti/cmd/color/color.go b/ziti/cmd/color/color.go similarity index 98% rename from ziti/cmd/ziti/cmd/color/color.go rename to ziti/cmd/color/color.go index a5e1e0dc3..ff8a79f41 100644 --- a/ziti/cmd/ziti/cmd/color/color.go +++ b/ziti/cmd/color/color.go @@ -17,8 +17,8 @@ package color import ( - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/fatih/color" + "github.com/openziti/ziti/ziti/util" "sort" ) diff --git a/ziti/cmd/ziti/cmd/common.go b/ziti/cmd/common.go similarity index 100% rename from ziti/cmd/ziti/cmd/common.go rename to ziti/cmd/common.go diff --git a/ziti/cmd/ziti/cmd/common/options.go b/ziti/cmd/common/options.go similarity index 100% rename from ziti/cmd/ziti/cmd/common/options.go rename to ziti/cmd/common/options.go diff --git a/ziti/cmd/ziti/cmd/common_commands.go b/ziti/cmd/common_commands.go similarity index 97% rename from ziti/cmd/ziti/cmd/common_commands.go rename to ziti/cmd/common_commands.go index b106cc63a..e0be196a1 100644 --- a/ziti/cmd/ziti/cmd/common_commands.go +++ b/ziti/cmd/common_commands.go @@ -18,13 +18,12 @@ package cmd import ( "fmt" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/util" "io/ioutil" "os" "os/exec" "strings" - - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/cmd/ziti/util" ) var cliAgentEnabled bool diff --git a/ziti/cmd/ziti/cmd/common_init.go b/ziti/cmd/common_init.go similarity index 97% rename from ziti/cmd/ziti/cmd/common_init.go rename to ziti/cmd/common_init.go index bf32280ee..b1f271d13 100644 --- a/ziti/cmd/ziti/cmd/common_init.go +++ b/ziti/cmd/common_init.go @@ -18,8 +18,8 @@ package cmd import ( "fmt" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + c "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/viper" "gopkg.in/AlecAivazis/survey.v1" "os" diff --git a/ziti/cmd/ziti/cmd/common_install.go b/ziti/cmd/common_install.go similarity index 98% rename from ziti/cmd/ziti/cmd/common_install.go rename to ziti/cmd/common_install.go index b72071b6e..243d339ae 100644 --- a/ziti/cmd/ziti/cmd/common_install.go +++ b/ziti/cmd/common_install.go @@ -19,9 +19,9 @@ package cmd import ( "fmt" "github.com/blang/semver" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + c "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/util" "gopkg.in/AlecAivazis/survey.v1" "gopkg.in/resty.v1" "os" diff --git a/ziti/cmd/ziti/cmd/common_install_test.go b/ziti/cmd/common_install_test.go similarity index 95% rename from ziti/cmd/ziti/cmd/common_install_test.go rename to ziti/cmd/common_install_test.go index 3b89d6f8d..f74ee6798 100644 --- a/ziti/cmd/ziti/cmd/common_install_test.go +++ b/ziti/cmd/common_install_test.go @@ -17,7 +17,7 @@ package cmd import ( - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" + c "github.com/openziti/ziti/ziti/constants" "github.com/pborman/uuid" "github.com/stretchr/testify/assert" "os" diff --git a/ziti/cmd/ziti/cmd/config_templates/controller.yml b/ziti/cmd/config_templates/controller.yml similarity index 100% rename from ziti/cmd/ziti/cmd/config_templates/controller.yml rename to ziti/cmd/config_templates/controller.yml diff --git a/ziti/cmd/ziti/cmd/config_templates/environment.yml b/ziti/cmd/config_templates/environment.yml similarity index 100% rename from ziti/cmd/ziti/cmd/config_templates/environment.yml rename to ziti/cmd/config_templates/environment.yml diff --git a/ziti/cmd/ziti/cmd/config_templates/router.yml b/ziti/cmd/config_templates/router.yml similarity index 100% rename from ziti/cmd/ziti/cmd/config_templates/router.yml rename to ziti/cmd/config_templates/router.yml diff --git a/ziti/cmd/ziti/cmd/create.go b/ziti/cmd/create.go similarity index 92% rename from ziti/cmd/ziti/cmd/create.go rename to ziti/cmd/create.go index 65207d2d7..03e786054 100644 --- a/ziti/cmd/ziti/cmd/create.go +++ b/ziti/cmd/create.go @@ -17,11 +17,10 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "github.com/spf13/cobra" "io" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" ) var ( diff --git a/ziti/cmd/ziti/cmd/create_config.go b/ziti/cmd/create_config.go similarity index 91% rename from ziti/cmd/ziti/cmd/create_config.go rename to ziti/cmd/create_config.go index 77f0bda76..59aaf47e1 100644 --- a/ziti/cmd/ziti/cmd/create_config.go +++ b/ziti/cmd/create_config.go @@ -17,6 +17,9 @@ package cmd import ( + "github.com/openziti/ziti/ziti/cmd/common" + helpers2 "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/constants" "os" "time" @@ -26,9 +29,6 @@ import ( fabForwarder "github.com/openziti/fabric/router/forwarder" foundation "github.com/openziti/transport/v2" fabXweb "github.com/openziti/xweb/v2" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -179,7 +179,7 @@ func init() { } } - workingDir = cmdhelper.NormalizePath(zh) + workingDir = helpers2.NormalizePath(zh) } // NewCmdCreateConfig creates a command object for the "config" command @@ -189,7 +189,7 @@ func NewCmdCreateConfig() *cobra.Command { Short: "Creates a config file for specified Ziti component using environment variables", Aliases: []string{"cfg"}, Run: func(cmd *cobra.Command, args []string) { - cmdhelper.CheckErr(cmd.Help()) + helpers2.CheckErr(cmd.Help()) }, } @@ -213,47 +213,47 @@ func (data *ConfigTemplateValues) populateEnvVars() { handleVariableError(err, "hostname") // Get and add ziti home to the params - zitiHome, err := cmdhelper.GetZitiHome() + zitiHome, err := helpers2.GetZitiHome() handleVariableError(err, constants.ZitiHomeVarName) // Get Ziti Controller Name - zitiCtrlHostname, err := cmdhelper.GetZitiCtrlName() + zitiCtrlHostname, err := helpers2.GetZitiCtrlName() handleVariableError(err, constants.ZitiCtrlNameVarName) // Get Ziti Edge Router Port - zitiEdgeRouterPort, err := cmdhelper.GetZitiEdgeRouterPort() + zitiEdgeRouterPort, err := helpers2.GetZitiEdgeRouterPort() handleVariableError(err, constants.ZitiEdgeRouterPortVarName) // Get Ziti Controller Listener Address - zitiCtrlListenerAddress, err := cmdhelper.GetZitiCtrlListenerAddress() + zitiCtrlListenerAddress, err := helpers2.GetZitiCtrlListenerAddress() handleVariableError(err, constants.ZitiCtrlListenerAddressVarName) // Get Ziti Controller Advertised Address - zitiCtrlAdvertisedAddress, err := cmdhelper.GetZitiCtrlAdvertisedAddress() + zitiCtrlAdvertisedAddress, err := helpers2.GetZitiCtrlAdvertisedAddress() handleVariableError(err, constants.ZitiCtrlAdvertisedAddressVarName) // Get Ziti Controller Port - zitiCtrlPort, err := cmdhelper.GetZitiCtrlPort() + zitiCtrlPort, err := helpers2.GetZitiCtrlPort() handleVariableError(err, constants.ZitiCtrlPortVarName) // Get Ziti Edge Controller Listener Host and Port - zitiEdgeCtrlListenerHostPort, err := cmdhelper.GetZitiEdgeCtrlListenerHostPort() + zitiEdgeCtrlListenerHostPort, err := helpers2.GetZitiEdgeCtrlListenerHostPort() handleVariableError(err, constants.ZitiEdgeCtrlListenerHostPortVarName) // Get Ziti Edge Controller Advertised Host and Port - zitiEdgeCtrlAdvertisedHostPort, err := cmdhelper.GetZitiEdgeCtrlAdvertisedHostPort() + zitiEdgeCtrlAdvertisedHostPort, err := helpers2.GetZitiEdgeCtrlAdvertisedHostPort() handleVariableError(err, constants.ZitiEdgeCtrlAdvertisedHostPortVarName) // Get Ziti Edge Controller Advertised Port - zitiEdgeCtrlAdvertisedPort, err := cmdhelper.GetZitiEdgeCtrlAdvertisedPort() + zitiEdgeCtrlAdvertisedPort, err := helpers2.GetZitiEdgeCtrlAdvertisedPort() handleVariableError(err, constants.ZitiEdgeCtrlAdvertisedPortVarName) // Get Ziti edge Identity enrollment duration - zitiEdgeIdentityEnrollmentDuration, err := cmdhelper.GetZitiEdgeIdentityEnrollmentDuration() + zitiEdgeIdentityEnrollmentDuration, err := helpers2.GetZitiEdgeIdentityEnrollmentDuration() handleVariableError(err, constants.ZitiEdgeIdentityEnrollmentDurationVarName) // Get Ziti edge Router enrollment duration - zitiEdgeRouterEnrollmentDuration, err := cmdhelper.GetZitiEdgeRouterEnrollmentDuration() + zitiEdgeRouterEnrollmentDuration, err := helpers2.GetZitiEdgeRouterEnrollmentDuration() handleVariableError(err, constants.ZitiEdgeRouterEnrollmentDurationVarName) data.ZitiHome = zitiHome diff --git a/ziti/cmd/ziti/cmd/create_config_controller.go b/ziti/cmd/create_config_controller.go similarity index 92% rename from ziti/cmd/ziti/cmd/create_config_controller.go rename to ziti/cmd/create_config_controller.go index 34eefaac7..da4c7619f 100644 --- a/ziti/cmd/ziti/cmd/create_config_controller.go +++ b/ziti/cmd/create_config_controller.go @@ -19,9 +19,9 @@ package cmd import ( _ "embed" edge "github.com/openziti/edge/controller/config" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" + helpers2 "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + "github.com/openziti/ziti/ziti/constants" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -126,7 +126,7 @@ func NewCmdCreateConfigController() *cobra.Command { controllerOptions.Cmd = cmd controllerOptions.Args = args err := controllerOptions.run(data) - cmdhelper.CheckErr(err) + helpers2.CheckErr(err) }, PostRun: func(cmd *cobra.Command, args []string) { // Reset log output after run completes @@ -204,28 +204,28 @@ func SetControllerIdentityCert(c *ControllerTemplateValues) { if val == "" { val = workingDir + "/" + hostnameOrNetworkName() + ".cert" // default } - c.IdentityCert = cmdhelper.NormalizePath(val) + c.IdentityCert = helpers2.NormalizePath(val) } func SetControllerIdentityServerCert(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiCtrlIdentityServerCertVarName) if val == "" { val = workingDir + "/" + hostnameOrNetworkName() + ".server.chain.cert" // default } - c.IdentityServerCert = cmdhelper.NormalizePath(val) + c.IdentityServerCert = helpers2.NormalizePath(val) } func SetControllerIdentityKey(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiCtrlIdentityKeyVarName) if val == "" { val = workingDir + "/" + hostnameOrNetworkName() + ".key" // default } - c.IdentityKey = cmdhelper.NormalizePath(val) + c.IdentityKey = helpers2.NormalizePath(val) } func SetControllerIdentityCA(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiCtrlIdentityCAVarName) if val == "" { val = workingDir + "/" + hostnameOrNetworkName() + ".ca" // default } - c.IdentityCA = cmdhelper.NormalizePath(val) + c.IdentityCA = helpers2.NormalizePath(val) } func SetEdgeConfig(data *ControllerTemplateValues) { @@ -237,14 +237,14 @@ func SetEdgeSigningCert(c *ControllerTemplateValues) { if val == "" { val = workingDir + "/" + hostnameOrNetworkName() + ".signing.cert" // default } - c.Edge.ZitiSigningCert = cmdhelper.NormalizePath(val) + c.Edge.ZitiSigningCert = helpers2.NormalizePath(val) } func SetEdgeSigningKey(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiSigningKeyVarName) if val == "" { val = workingDir + "/" + hostnameOrNetworkName() + ".signing.key" // default } - c.Edge.ZitiSigningKey = cmdhelper.NormalizePath(val) + c.Edge.ZitiSigningKey = helpers2.NormalizePath(val) } func SetWebConfig(data *ControllerTemplateValues) { @@ -258,26 +258,26 @@ func SetWebIdentityCert(c *ControllerTemplateValues) { if val == "" { val = c.IdentityCert //default } - c.Edge.IdentityCert = cmdhelper.NormalizePath(val) + c.Edge.IdentityCert = helpers2.NormalizePath(val) } func SetWebIdentityServerCert(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiEdgeCtrlIdentityServerCertVarName) if val == "" { val = c.IdentityServerCert //default } - c.Edge.IdentityServerCert = cmdhelper.NormalizePath(val) + c.Edge.IdentityServerCert = helpers2.NormalizePath(val) } func SetWebIdentityKey(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiEdgeCtrlIdentityKeyVarName) if val == "" { val = c.IdentityKey //default } - c.Edge.IdentityKey = cmdhelper.NormalizePath(val) + c.Edge.IdentityKey = helpers2.NormalizePath(val) } func SetWebIdentityCA(c *ControllerTemplateValues) { val := os.Getenv(constants.ZitiEdgeCtrlIdentityCAVarName) if val == "" { val = c.IdentityCA //default } - c.Edge.IdentityCA = cmdhelper.NormalizePath(val) + c.Edge.IdentityCA = helpers2.NormalizePath(val) } diff --git a/ziti/cmd/ziti/cmd/create_config_controller_test.go b/ziti/cmd/create_config_controller_test.go similarity index 100% rename from ziti/cmd/ziti/cmd/create_config_controller_test.go rename to ziti/cmd/create_config_controller_test.go diff --git a/ziti/cmd/ziti/cmd/create_config_environment.go b/ziti/cmd/create_config_environment.go similarity index 98% rename from ziti/cmd/ziti/cmd/create_config_environment.go rename to ziti/cmd/create_config_environment.go index d6a996d1d..343fa2042 100644 --- a/ziti/cmd/ziti/cmd/create_config_environment.go +++ b/ziti/cmd/create_config_environment.go @@ -19,15 +19,15 @@ package cmd import ( _ "embed" "fmt" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + "github.com/openziti/ziti/ziti/constants" "os" "path/filepath" "runtime" "strings" "text/template" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/ziti/cmd/ziti/cmd/create_config_router.go b/ziti/cmd/create_config_router.go similarity index 97% rename from ziti/cmd/ziti/cmd/create_config_router.go rename to ziti/cmd/create_config_router.go index 05c27a850..10ed476a3 100644 --- a/ziti/cmd/ziti/cmd/create_config_router.go +++ b/ziti/cmd/create_config_router.go @@ -18,10 +18,10 @@ package cmd import ( _ "embed" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "os" "strings" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/create_config_router_common.go b/ziti/cmd/create_config_router_common.go similarity index 96% rename from ziti/cmd/ziti/cmd/create_config_router_common.go rename to ziti/cmd/create_config_router_common.go index 0440384fb..378faeee1 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_common.go +++ b/ziti/cmd/create_config_router_common.go @@ -18,11 +18,10 @@ package cmd import ( _ "embed" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/constants" "log" "os" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" ) func SetZitiRouterIdentity(r *RouterTemplateValues, routerName string) { diff --git a/ziti/cmd/ziti/cmd/create_config_router_edge.go b/ziti/cmd/create_config_router_edge.go similarity index 97% rename from ziti/cmd/ziti/cmd/create_config_router_edge.go rename to ziti/cmd/create_config_router_edge.go index be0becc08..ca66e5f77 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_edge.go +++ b/ziti/cmd/create_config_router_edge.go @@ -18,13 +18,13 @@ package cmd import ( _ "embed" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "os" "path/filepath" "strings" "text/template" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/ziti/cmd/ziti/cmd/create_config_router_edge_test.go b/ziti/cmd/create_config_router_edge_test.go similarity index 99% rename from ziti/cmd/ziti/cmd/create_config_router_edge_test.go rename to ziti/cmd/create_config_router_edge_test.go index bebf5d2a4..ef9eca47f 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_edge_test.go +++ b/ziti/cmd/create_config_router_edge_test.go @@ -1,7 +1,7 @@ package cmd import ( - "github.com/openziti/ziti/ziti/cmd/ziti/constants" + "github.com/openziti/ziti/ziti/constants" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/ziti/cmd/ziti/cmd/create_config_router_fabric.go b/ziti/cmd/create_config_router_fabric.go similarity index 96% rename from ziti/cmd/ziti/cmd/create_config_router_fabric.go rename to ziti/cmd/create_config_router_fabric.go index 27e3e893a..de642a534 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_fabric.go +++ b/ziti/cmd/create_config_router_fabric.go @@ -18,8 +18,8 @@ package cmd import ( _ "embed" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/ziti/cmd/ziti/cmd/create_config_router_fabric_test.go b/ziti/cmd/create_config_router_fabric_test.go similarity index 99% rename from ziti/cmd/ziti/cmd/create_config_router_fabric_test.go rename to ziti/cmd/create_config_router_fabric_test.go index 2b1e0cf8a..2145b09cc 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_fabric_test.go +++ b/ziti/cmd/create_config_router_fabric_test.go @@ -1,7 +1,7 @@ package cmd import ( - "github.com/openziti/ziti/ziti/cmd/ziti/constants" + "github.com/openziti/ziti/ziti/constants" "github.com/stretchr/testify/assert" "os" "testing" diff --git a/ziti/cmd/ziti/cmd/create_config_router_test.go b/ziti/cmd/create_config_router_test.go similarity index 99% rename from ziti/cmd/ziti/cmd/create_config_router_test.go rename to ziti/cmd/create_config_router_test.go index 81ad11d25..7d0a18545 100644 --- a/ziti/cmd/ziti/cmd/create_config_router_test.go +++ b/ziti/cmd/create_config_router_test.go @@ -2,7 +2,7 @@ package cmd import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" + "github.com/openziti/ziti/ziti/constants" "github.com/stretchr/testify/assert" "gopkg.in/yaml.v3" "os" diff --git a/ziti/cmd/ziti/cmd/create_config_test.go b/ziti/cmd/create_config_test.go similarity index 100% rename from ziti/cmd/ziti/cmd/create_config_test.go rename to ziti/cmd/create_config_test.go diff --git a/ziti/cmd/ziti/cmd/create_environment.go b/ziti/cmd/create_environment.go similarity index 92% rename from ziti/cmd/ziti/cmd/create_environment.go rename to ziti/cmd/create_environment.go index fb22392ef..37e35a481 100644 --- a/ziti/cmd/ziti/cmd/create_environment.go +++ b/ziti/cmd/create_environment.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/util" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/database/cmd.go b/ziti/cmd/database/cmd.go similarity index 93% rename from ziti/cmd/ziti/cmd/database/cmd.go rename to ziti/cmd/database/cmd.go index 37f82f1c1..31e07b588 100644 --- a/ziti/cmd/ziti/cmd/database/cmd.go +++ b/ziti/cmd/database/cmd.go @@ -3,7 +3,7 @@ package database import ( "fmt" "github.com/openziti/ziti-db-explorer/cmd/ziti-db-explorer/zdecli" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/demo/echo-notes.txt b/ziti/cmd/demo/echo-notes.txt similarity index 100% rename from ziti/cmd/ziti/cmd/demo/echo-notes.txt rename to ziti/cmd/demo/echo-notes.txt diff --git a/ziti/cmd/ziti/cmd/demo/echo_server.go b/ziti/cmd/demo/echo_server.go similarity index 100% rename from ziti/cmd/ziti/cmd/demo/echo_server.go rename to ziti/cmd/demo/echo_server.go index 344c08424..bfc304060 100644 --- a/ziti/cmd/ziti/cmd/demo/echo_server.go +++ b/ziti/cmd/demo/echo_server.go @@ -20,8 +20,8 @@ import ( "bufio" "fmt" "github.com/michaelquigley/pfxlog" - "github.com/openziti/channel/v2" "github.com/openziti/agent" + "github.com/openziti/channel/v2" "github.com/openziti/identity" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/config" diff --git a/ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go b/ziti/cmd/demo/echo_server_update_terminator.go similarity index 93% rename from ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go rename to ziti/cmd/demo/echo_server_update_terminator.go index 1009bf581..4bd27c748 100644 --- a/ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go +++ b/ziti/cmd/demo/echo_server_update_terminator.go @@ -18,11 +18,11 @@ package demo import ( "fmt" - "github.com/openziti/channel/v2" "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/channel/v2" + "github.com/openziti/ziti/ziti/cmd/agentcli" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/spf13/cobra" "time" diff --git a/ziti/cmd/ziti/cmd/demo/root.go b/ziti/cmd/demo/root.go similarity index 93% rename from ziti/cmd/ziti/cmd/demo/root.go rename to ziti/cmd/demo/root.go index 6009dac6f..044976664 100644 --- a/ziti/cmd/ziti/cmd/demo/root.go +++ b/ziti/cmd/demo/root.go @@ -17,9 +17,9 @@ package demo import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/agentcli" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/agentcli" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-client.go b/ziti/cmd/demo/setup-client.go similarity index 91% rename from ziti/cmd/ziti/cmd/demo/setup-client.go rename to ziti/cmd/demo/setup-client.go index 28dedd95e..72d00c014 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-client.go +++ b/ziti/cmd/demo/setup-client.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-multi-router-tunneler-hosted-service.go b/ziti/cmd/demo/setup-multi-router-tunneler-hosted-service.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-multi-router-tunneler-hosted-service.go rename to ziti/cmd/demo/setup-multi-router-tunneler-hosted-service.go index 8e9ea2525..5a688f7c8 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-multi-router-tunneler-hosted-service.go +++ b/ziti/cmd/demo/setup-multi-router-tunneler-hosted-service.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-multi-sdk-service.go b/ziti/cmd/demo/setup-multi-sdk-service.go similarity index 91% rename from ziti/cmd/ziti/cmd/demo/setup-multi-sdk-service.go rename to ziti/cmd/demo/setup-multi-sdk-service.go index dfaf0f13d..85b15385a 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-multi-sdk-service.go +++ b/ziti/cmd/demo/setup-multi-sdk-service.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-multi-tunneler-hosted-service.go b/ziti/cmd/demo/setup-multi-tunneler-hosted-service.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-multi-tunneler-hosted-service.go rename to ziti/cmd/demo/setup-multi-tunneler-hosted-service.go index 6c28fc6fd..cc8d1c229 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-multi-tunneler-hosted-service.go +++ b/ziti/cmd/demo/setup-multi-tunneler-hosted-service.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-router-tunneler-both-sides.go b/ziti/cmd/demo/setup-router-tunneler-both-sides.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-router-tunneler-both-sides.go rename to ziti/cmd/demo/setup-router-tunneler-both-sides.go index b2d073e2a..98c546be7 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-router-tunneler-both-sides.go +++ b/ziti/cmd/demo/setup-router-tunneler-both-sides.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md b/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md rename to ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md b/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md rename to ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-tunneler-hosted.md b/ziti/cmd/demo/setup-scripts/multi-tunneler-hosted.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/multi-tunneler-hosted.md rename to ziti/cmd/demo/setup-scripts/multi-tunneler-hosted.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/router-tunneler-both-sides.md b/ziti/cmd/demo/setup-scripts/router-tunneler-both-sides.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/router-tunneler-both-sides.md rename to ziti/cmd/demo/setup-scripts/router-tunneler-both-sides.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/sdk-client.md b/ziti/cmd/demo/setup-scripts/sdk-client.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/sdk-client.md rename to ziti/cmd/demo/setup-scripts/sdk-client.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/single-router-tunneler-hosted.md b/ziti/cmd/demo/setup-scripts/single-router-tunneler-hosted.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/single-router-tunneler-hosted.md rename to ziti/cmd/demo/setup-scripts/single-router-tunneler-hosted.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md b/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md rename to ziti/cmd/demo/setup-scripts/single-sdk-hosted.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-addressable.md b/ziti/cmd/demo/setup-scripts/update-config-addressable.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-addressable.md rename to ziti/cmd/demo/setup-scripts/update-config-addressable.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-ha.md b/ziti/cmd/demo/setup-scripts/update-config-ha.md similarity index 100% rename from ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-ha.md rename to ziti/cmd/demo/setup-scripts/update-config-ha.md diff --git a/ziti/cmd/ziti/cmd/demo/setup-single-router-tunneler-hosted-service.go b/ziti/cmd/demo/setup-single-router-tunneler-hosted-service.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-single-router-tunneler-hosted-service.go rename to ziti/cmd/demo/setup-single-router-tunneler-hosted-service.go index 485b6e011..36f5ea69c 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-single-router-tunneler-hosted-service.go +++ b/ziti/cmd/demo/setup-single-router-tunneler-hosted-service.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-single-sdk-service.go b/ziti/cmd/demo/setup-single-sdk-service.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-single-sdk-service.go rename to ziti/cmd/demo/setup-single-sdk-service.go index 19d108f8a..db95e1640 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-single-sdk-service.go +++ b/ziti/cmd/demo/setup-single-sdk-service.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-update-config-addressable.go b/ziti/cmd/demo/setup-update-config-addressable.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-update-config-addressable.go rename to ziti/cmd/demo/setup-update-config-addressable.go index bd083a9fb..aa7320e5e 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-update-config-addressable.go +++ b/ziti/cmd/demo/setup-update-config-addressable.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/setup-update-config-ha.go b/ziti/cmd/demo/setup-update-config-ha.go similarity index 92% rename from ziti/cmd/ziti/cmd/demo/setup-update-config-ha.go rename to ziti/cmd/demo/setup-update-config-ha.go index 9e2cac205..b0bc6e961 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-update-config-ha.go +++ b/ziti/cmd/demo/setup-update-config-ha.go @@ -20,10 +20,10 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/tutorial" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/demo/zcat.go b/ziti/cmd/demo/zcat.go similarity index 100% rename from ziti/cmd/ziti/cmd/demo/zcat.go rename to ziti/cmd/demo/zcat.go diff --git a/ziti/cmd/ziti/cmd/edge/common.go b/ziti/cmd/edge/common.go similarity index 98% rename from ziti/cmd/ziti/cmd/edge/common.go rename to ziti/cmd/edge/common.go index 670e56e8f..1cc7b694e 100644 --- a/ziti/cmd/ziti/cmd/edge/common.go +++ b/ziti/cmd/edge/common.go @@ -18,7 +18,7 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" "github.com/pkg/errors" "os" "strings" diff --git a/ziti/cmd/ziti/cmd/edge/create.go b/ziti/cmd/edge/create.go similarity index 92% rename from ziti/cmd/ziti/cmd/edge/create.go rename to ziti/cmd/edge/create.go index c0abb240c..55f3b376b 100644 --- a/ziti/cmd/ziti/cmd/edge/create.go +++ b/ziti/cmd/edge/create.go @@ -18,11 +18,11 @@ package edge import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_authenticator.go b/ziti/cmd/edge/create_authenticator.go similarity index 92% rename from ziti/cmd/ziti/cmd/edge/create_authenticator.go rename to ziti/cmd/edge/create_authenticator.go index 457228efc..f8356257e 100644 --- a/ziti/cmd/ziti/cmd/edge/create_authenticator.go +++ b/ziti/cmd/edge/create_authenticator.go @@ -17,8 +17,8 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_authenticator_updb.go b/ziti/cmd/edge/create_authenticator_updb.go similarity index 96% rename from ziti/cmd/ziti/cmd/edge/create_authenticator_updb.go rename to ziti/cmd/edge/create_authenticator_updb.go index 3b5894ab9..be118dd0e 100644 --- a/ziti/cmd/ziti/cmd/edge/create_authenticator_updb.go +++ b/ziti/cmd/edge/create_authenticator_updb.go @@ -23,9 +23,9 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/edge/rest_management_api_client/authenticator" "github.com/openziti/foundation/v2/term" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_ca.go b/ziti/cmd/edge/create_ca.go similarity index 96% rename from ziti/cmd/ziti/cmd/edge/create_ca.go rename to ziti/cmd/edge/create_ca.go index 198b22c55..565969ce0 100644 --- a/ziti/cmd/ziti/cmd/edge/create_ca.go +++ b/ziti/cmd/edge/create_ca.go @@ -20,10 +20,10 @@ import ( "fmt" "github.com/openziti/edge/rest_management_api_client/certificate_authority" "github.com/openziti/edge/rest_model" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" "os" diff --git a/ziti/cmd/ziti/cmd/edge/create_config.go b/ziti/cmd/edge/create_config.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/create_config.go rename to ziti/cmd/edge/create_config.go index bd3eadf6e..a41285990 100644 --- a/ziti/cmd/ziti/cmd/edge/create_config.go +++ b/ziti/cmd/edge/create_config.go @@ -19,15 +19,15 @@ package edge import ( "encoding/json" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "io/ioutil" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_config_type.go b/ziti/cmd/edge/create_config_type.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/create_config_type.go rename to ziti/cmd/edge/create_config_type.go index 03b28da4b..bae8fd95a 100644 --- a/ziti/cmd/ziti/cmd/edge/create_config_type.go +++ b/ziti/cmd/edge/create_config_type.go @@ -19,15 +19,15 @@ package edge import ( "encoding/json" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "io/ioutil" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_edge_router.go b/ziti/cmd/edge/create_edge_router.go similarity index 96% rename from ziti/cmd/ziti/cmd/edge/create_edge_router.go rename to ziti/cmd/edge/create_edge_router.go index 6df6c80c6..3b7922ef5 100644 --- a/ziti/cmd/ziti/cmd/edge/create_edge_router.go +++ b/ziti/cmd/edge/create_edge_router.go @@ -18,14 +18,13 @@ package edge import ( "fmt" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "io/ioutil" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go b/ziti/cmd/edge/create_edge_router_policy.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go rename to ziti/cmd/edge/create_edge_router_policy.go index 84e90418b..b6505dcf2 100644 --- a/ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go +++ b/ziti/cmd/edge/create_edge_router_policy.go @@ -17,12 +17,12 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_enrollment.go b/ziti/cmd/edge/create_enrollment.go similarity index 96% rename from ziti/cmd/ziti/cmd/edge/create_enrollment.go rename to ziti/cmd/edge/create_enrollment.go index 05f23a89d..b00e23970 100644 --- a/ziti/cmd/ziti/cmd/edge/create_enrollment.go +++ b/ziti/cmd/edge/create_enrollment.go @@ -22,10 +22,10 @@ import ( "github.com/go-openapi/strfmt" "github.com/openziti/edge/rest_management_api_client/enrollment" "github.com/openziti/edge/rest_model" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" "time" diff --git a/ziti/cmd/ziti/cmd/edge/create_identity.go b/ziti/cmd/edge/create_identity.go similarity index 97% rename from ziti/cmd/ziti/cmd/edge/create_identity.go rename to ziti/cmd/edge/create_identity.go index 329a07114..036398376 100644 --- a/ziti/cmd/ziti/cmd/edge/create_identity.go +++ b/ziti/cmd/edge/create_identity.go @@ -18,7 +18,9 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" "io" "io/ioutil" @@ -27,8 +29,6 @@ import ( "strings" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_posture_check.go b/ziti/cmd/edge/create_posture_check.go similarity index 99% rename from ziti/cmd/ziti/cmd/edge/create_posture_check.go rename to ziti/cmd/edge/create_posture_check.go index 0b9dc9aa6..9b119ba33 100644 --- a/ziti/cmd/ziti/cmd/edge/create_posture_check.go +++ b/ziti/cmd/edge/create_posture_check.go @@ -21,10 +21,10 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/edge/rest_management_api_client/posture_checks" "github.com/openziti/edge/rest_model" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" "regexp" diff --git a/ziti/cmd/ziti/cmd/edge/create_service.go b/ziti/cmd/edge/create_service.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/create_service.go rename to ziti/cmd/edge/create_service.go index 75561f9dd..1a206fe63 100644 --- a/ziti/cmd/ziti/cmd/edge/create_service.go +++ b/ziti/cmd/edge/create_service.go @@ -18,9 +18,9 @@ package edge import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go b/ziti/cmd/edge/create_service_edge_router_policy.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go rename to ziti/cmd/edge/create_service_edge_router_policy.go index 7f0cf4b16..875dbfc97 100644 --- a/ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go +++ b/ziti/cmd/edge/create_service_edge_router_policy.go @@ -17,12 +17,12 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_service_policy.go b/ziti/cmd/edge/create_service_policy.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/create_service_policy.go rename to ziti/cmd/edge/create_service_policy.go index bd65a0a47..e23c37d46 100644 --- a/ziti/cmd/ziti/cmd/edge/create_service_policy.go +++ b/ziti/cmd/edge/create_service_policy.go @@ -17,15 +17,15 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "strings" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/create_terminator.go b/ziti/cmd/edge/create_terminator.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/create_terminator.go rename to ziti/cmd/edge/create_terminator.go index 7a1a610a1..7e4b7be18 100644 --- a/ziti/cmd/ziti/cmd/edge/create_terminator.go +++ b/ziti/cmd/edge/create_terminator.go @@ -21,9 +21,9 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/edge/router/xgress_edge_transport" "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "math" diff --git a/ziti/cmd/ziti/cmd/edge/db.go b/ziti/cmd/edge/db.go similarity index 88% rename from ziti/cmd/ziti/cmd/edge/db.go rename to ziti/cmd/edge/db.go index 907405bcb..b4b8f857f 100644 --- a/ziti/cmd/ziti/cmd/edge/db.go +++ b/ziti/cmd/edge/db.go @@ -1,7 +1,7 @@ package edge import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/db_check_integrity.go b/ziti/cmd/edge/db_check_integrity.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/db_check_integrity.go rename to ziti/cmd/edge/db_check_integrity.go index 910adf4ca..389946813 100644 --- a/ziti/cmd/ziti/cmd/edge/db_check_integrity.go +++ b/ziti/cmd/edge/db_check_integrity.go @@ -3,10 +3,10 @@ package edge import ( "fmt" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "github.com/spf13/cobra" "io" diff --git a/ziti/cmd/ziti/cmd/edge/db_snapshot.go b/ziti/cmd/edge/db_snapshot.go similarity index 87% rename from ziti/cmd/ziti/cmd/edge/db_snapshot.go rename to ziti/cmd/edge/db_snapshot.go index ad69263e2..e827491e1 100644 --- a/ziti/cmd/ziti/cmd/edge/db_snapshot.go +++ b/ziti/cmd/edge/db_snapshot.go @@ -17,10 +17,10 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" "net/http" diff --git a/ziti/cmd/ziti/cmd/edge/delete.go b/ziti/cmd/edge/delete.go similarity index 96% rename from ziti/cmd/ziti/cmd/edge/delete.go rename to ziti/cmd/edge/delete.go index 606a345b2..7908be24b 100644 --- a/ziti/cmd/ziti/cmd/edge/delete.go +++ b/ziti/cmd/edge/delete.go @@ -19,14 +19,14 @@ package edge import ( "github.com/fatih/color" "github.com/openziti/storage/boltz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "io" "net/url" "strings" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/detail.go b/ziti/cmd/edge/detail.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/detail.go rename to ziti/cmd/edge/detail.go index 03783f2b5..b01d5def8 100644 --- a/ziti/cmd/ziti/cmd/edge/detail.go +++ b/ziti/cmd/edge/detail.go @@ -18,7 +18,7 @@ package edge import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/util" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/encryption_var.go b/ziti/cmd/edge/encryption_var.go similarity index 100% rename from ziti/cmd/ziti/cmd/edge/encryption_var.go rename to ziti/cmd/edge/encryption_var.go diff --git a/ziti/cmd/ziti/cmd/edge/list.go b/ziti/cmd/edge/list.go similarity index 99% rename from ziti/cmd/ziti/cmd/edge/list.go rename to ziti/cmd/edge/list.go index a69268a32..2b122cc40 100644 --- a/ziti/cmd/ziti/cmd/edge/list.go +++ b/ziti/cmd/edge/list.go @@ -23,6 +23,10 @@ import ( "github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/text" "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "io" "net/url" "sort" @@ -32,10 +36,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/edge/rest_management_api_client/certificate_authority" "github.com/openziti/edge/rest_model" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/pkg/errors" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/login.go b/ziti/cmd/edge/login.go similarity index 97% rename from ziti/cmd/ziti/cmd/edge/login.go rename to ziti/cmd/edge/login.go index 0a9902678..f1fa783d3 100644 --- a/ziti/cmd/ziti/cmd/edge/login.go +++ b/ziti/cmd/edge/login.go @@ -20,10 +20,10 @@ import ( "fmt" "github.com/Jeffail/gabs" "github.com/openziti/foundation/v2/term" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "github.com/spf13/cobra" "io" diff --git a/ziti/cmd/ziti/cmd/edge/logout.go b/ziti/cmd/edge/logout.go similarity index 89% rename from ziti/cmd/ziti/cmd/edge/logout.go rename to ziti/cmd/edge/logout.go index 67cadfb51..10539ba67 100644 --- a/ziti/cmd/ziti/cmd/edge/logout.go +++ b/ziti/cmd/edge/logout.go @@ -17,10 +17,10 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/policy_advisor.go b/ziti/cmd/edge/policy_advisor.go similarity index 98% rename from ziti/cmd/ziti/cmd/edge/policy_advisor.go rename to ziti/cmd/edge/policy_advisor.go index d29b58148..6cabe3759 100644 --- a/ziti/cmd/ziti/cmd/edge/policy_advisor.go +++ b/ziti/cmd/edge/policy_advisor.go @@ -19,10 +19,10 @@ package edge import ( "fmt" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/root.go b/ziti/cmd/edge/root.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/root.go rename to ziti/cmd/edge/root.go index cf7137e42..b3beb2aee 100644 --- a/ziti/cmd/ziti/cmd/edge/root.go +++ b/ziti/cmd/edge/root.go @@ -17,12 +17,11 @@ package edge import ( + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/util" "io" "github.com/openziti/ziti/common/enrollment" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/show.go b/ziti/cmd/edge/show.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/show.go rename to ziti/cmd/edge/show.go index ba28936ad..eec144c6d 100644 --- a/ziti/cmd/ziti/cmd/edge/show.go +++ b/ziti/cmd/edge/show.go @@ -19,10 +19,10 @@ package edge import ( "encoding/json" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/trace_identity.go b/ziti/cmd/edge/trace_identity.go similarity index 94% rename from ziti/cmd/ziti/cmd/edge/trace_identity.go rename to ziti/cmd/edge/trace_identity.go index 0764f4818..384e94e73 100644 --- a/ziti/cmd/ziti/cmd/edge/trace_identity.go +++ b/ziti/cmd/edge/trace_identity.go @@ -19,9 +19,9 @@ package edge import ( "fmt" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/traceroute.go b/ziti/cmd/edge/traceroute.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/traceroute.go rename to ziti/cmd/edge/traceroute.go index 3f2396a88..25fe33c5b 100644 --- a/ziti/cmd/ziti/cmd/edge/traceroute.go +++ b/ziti/cmd/edge/traceroute.go @@ -4,9 +4,9 @@ import ( "fmt" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/config" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "io" diff --git a/ziti/cmd/ziti/cmd/edge/update.go b/ziti/cmd/edge/update.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update.go rename to ziti/cmd/edge/update.go index 73c14e297..903377156 100644 --- a/ziti/cmd/ziti/cmd/edge/update.go +++ b/ziti/cmd/edge/update.go @@ -18,9 +18,9 @@ package edge import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/cobra" "gopkg.in/resty.v1" "io" diff --git a/ziti/cmd/ziti/cmd/edge/update_authenticator.go b/ziti/cmd/edge/update_authenticator.go similarity index 92% rename from ziti/cmd/ziti/cmd/edge/update_authenticator.go rename to ziti/cmd/edge/update_authenticator.go index 87fdb9e43..1c6e55b72 100644 --- a/ziti/cmd/ziti/cmd/edge/update_authenticator.go +++ b/ziti/cmd/edge/update_authenticator.go @@ -17,8 +17,8 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_authenticator_updb.go b/ziti/cmd/edge/update_authenticator_updb.go similarity index 97% rename from ziti/cmd/ziti/cmd/edge/update_authenticator_updb.go rename to ziti/cmd/edge/update_authenticator_updb.go index 60ea8f008..2cb48b99c 100644 --- a/ziti/cmd/ziti/cmd/edge/update_authenticator_updb.go +++ b/ziti/cmd/edge/update_authenticator_updb.go @@ -23,11 +23,11 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/edge/rest_management_api_client/authenticator" "github.com/openziti/foundation/v2/term" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/cobra" ) -import cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" type updateUpdbOptions struct { api.Options diff --git a/ziti/cmd/ziti/cmd/edge/update_ca.go b/ziti/cmd/edge/update_ca.go similarity index 97% rename from ziti/cmd/ziti/cmd/edge/update_ca.go rename to ziti/cmd/edge/update_ca.go index ab43471ac..1cad4385e 100644 --- a/ziti/cmd/ziti/cmd/edge/update_ca.go +++ b/ziti/cmd/edge/update_ca.go @@ -20,10 +20,10 @@ import ( "fmt" "github.com/openziti/edge/rest_management_api_client/certificate_authority" "github.com/openziti/edge/rest_model" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "github.com/spf13/cobra" "gopkg.in/resty.v1" diff --git a/ziti/cmd/ziti/cmd/edge/update_config.go b/ziti/cmd/edge/update_config.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_config.go rename to ziti/cmd/edge/update_config.go index 320943cae..04bd4a4da 100644 --- a/ziti/cmd/ziti/cmd/edge/update_config.go +++ b/ziti/cmd/edge/update_config.go @@ -19,15 +19,15 @@ package edge import ( "encoding/json" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "io/ioutil" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_config_type.go b/ziti/cmd/edge/update_config_type.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_config_type.go rename to ziti/cmd/edge/update_config_type.go index cfb3c0f04..df4665c0f 100644 --- a/ziti/cmd/ziti/cmd/edge/update_config_type.go +++ b/ziti/cmd/edge/update_config_type.go @@ -19,15 +19,15 @@ package edge import ( "encoding/json" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "os" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_edge_router.go b/ziti/cmd/edge/update_edge_router.go similarity index 96% rename from ziti/cmd/ziti/cmd/edge/update_edge_router.go rename to ziti/cmd/edge/update_edge_router.go index bb88af44a..711706685 100644 --- a/ziti/cmd/ziti/cmd/edge/update_edge_router.go +++ b/ziti/cmd/edge/update_edge_router.go @@ -18,15 +18,14 @@ package edge import ( "fmt" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go b/ziti/cmd/edge/update_edge_router_policy.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go rename to ziti/cmd/edge/update_edge_router_policy.go index 17fea861f..0a208ebfa 100644 --- a/ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go +++ b/ziti/cmd/edge/update_edge_router_policy.go @@ -18,14 +18,14 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_identity.go b/ziti/cmd/edge/update_identity.go similarity index 97% rename from ziti/cmd/ziti/cmd/edge/update_identity.go rename to ziti/cmd/edge/update_identity.go index 547b30e37..5cda6d43c 100644 --- a/ziti/cmd/ziti/cmd/edge/update_identity.go +++ b/ziti/cmd/edge/update_identity.go @@ -19,7 +19,9 @@ package edge import ( "fmt" "github.com/openziti/sdk-golang/ziti" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "math" "strings" @@ -27,8 +29,6 @@ import ( "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_identity_configs.go b/ziti/cmd/edge/update_identity_configs.go similarity index 93% rename from ziti/cmd/ziti/cmd/edge/update_identity_configs.go rename to ziti/cmd/edge/update_identity_configs.go index 001199beb..3007b7492 100644 --- a/ziti/cmd/ziti/cmd/edge/update_identity_configs.go +++ b/ziti/cmd/edge/update_identity_configs.go @@ -18,12 +18,12 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_posture_check.go b/ziti/cmd/edge/update_posture_check.go similarity index 98% rename from ziti/cmd/ziti/cmd/edge/update_posture_check.go rename to ziti/cmd/edge/update_posture_check.go index 34ef82b6b..ffa47d162 100644 --- a/ziti/cmd/ziti/cmd/edge/update_posture_check.go +++ b/ziti/cmd/edge/update_posture_check.go @@ -18,14 +18,14 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_service.go b/ziti/cmd/edge/update_service.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_service.go rename to ziti/cmd/edge/update_service.go index 495b2dad2..bdeb93060 100644 --- a/ziti/cmd/ziti/cmd/edge/update_service.go +++ b/ziti/cmd/edge/update_service.go @@ -18,14 +18,14 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go b/ziti/cmd/edge/update_service_edge_router_policy.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go rename to ziti/cmd/edge/update_service_edge_router_policy.go index 8a34e3247..e24361a42 100644 --- a/ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go +++ b/ziti/cmd/edge/update_service_edge_router_policy.go @@ -18,14 +18,14 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_service_policy.go b/ziti/cmd/edge/update_service_policy.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_service_policy.go rename to ziti/cmd/edge/update_service_policy.go index 731ddc333..e5336aaa7 100644 --- a/ziti/cmd/ziti/cmd/edge/update_service_policy.go +++ b/ziti/cmd/edge/update_service_policy.go @@ -18,14 +18,14 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/update_terminator.go b/ziti/cmd/edge/update_terminator.go similarity index 95% rename from ziti/cmd/ziti/cmd/edge/update_terminator.go rename to ziti/cmd/edge/update_terminator.go index bfa758894..b826942e9 100644 --- a/ziti/cmd/ziti/cmd/edge/update_terminator.go +++ b/ziti/cmd/edge/update_terminator.go @@ -21,9 +21,9 @@ import ( "fmt" "github.com/Jeffail/gabs" "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" errors2 "github.com/pkg/errors" "github.com/spf13/cobra" "io" diff --git a/ziti/cmd/ziti/cmd/edge/use.go b/ziti/cmd/edge/use.go similarity index 90% rename from ziti/cmd/ziti/cmd/edge/use.go rename to ziti/cmd/edge/use.go index 8d7b679bc..7fa1eee87 100644 --- a/ziti/cmd/ziti/cmd/edge/use.go +++ b/ziti/cmd/edge/use.go @@ -17,10 +17,10 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" ) diff --git a/ziti/cmd/ziti/cmd/edge/verify.go b/ziti/cmd/edge/verify.go similarity index 89% rename from ziti/cmd/ziti/cmd/edge/verify.go rename to ziti/cmd/edge/verify.go index c28cddeb0..14c79fe6a 100644 --- a/ziti/cmd/ziti/cmd/edge/verify.go +++ b/ziti/cmd/edge/verify.go @@ -17,11 +17,11 @@ package edge import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/edge/verify_ca.go b/ziti/cmd/edge/verify_ca.go similarity index 97% rename from ziti/cmd/ziti/cmd/edge/verify_ca.go rename to ziti/cmd/edge/verify_ca.go index 505a17003..2a6ea51aa 100644 --- a/ziti/cmd/ziti/cmd/edge/verify_ca.go +++ b/ziti/cmd/edge/verify_ca.go @@ -28,10 +28,10 @@ import ( "fmt" nfpem "github.com/openziti/foundation/v2/pem" "github.com/openziti/foundation/v2/term" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "gopkg.in/resty.v1" "io" diff --git a/ziti/cmd/ziti/cmd/edge/version.go b/ziti/cmd/edge/version.go similarity index 89% rename from ziti/cmd/ziti/cmd/edge/version.go rename to ziti/cmd/edge/version.go index a2413ad23..8ac22309f 100644 --- a/ziti/cmd/ziti/cmd/edge/version.go +++ b/ziti/cmd/edge/version.go @@ -18,10 +18,10 @@ package edge import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "io" ) diff --git a/ziti/cmd/ziti/cmd/execute.go b/ziti/cmd/execute.go similarity index 93% rename from ziti/cmd/ziti/cmd/execute.go rename to ziti/cmd/execute.go index b31ac4c37..c52b3f066 100644 --- a/ziti/cmd/ziti/cmd/execute.go +++ b/ziti/cmd/execute.go @@ -17,12 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "io" "github.com/spf13/cobra" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" ) // ExecuteOptions contains the command line options diff --git a/ziti/cmd/ziti/cmd/execute_controller.go b/ziti/cmd/execute_controller.go similarity index 92% rename from ziti/cmd/ziti/cmd/execute_controller.go rename to ziti/cmd/execute_controller.go index 051fbc33d..3373bbd9a 100644 --- a/ziti/cmd/ziti/cmd/execute_controller.go +++ b/ziti/cmd/execute_controller.go @@ -17,15 +17,15 @@ package cmd import ( + 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/util" "io" "path/filepath" "github.com/spf13/cobra" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/viper" ) diff --git a/ziti/cmd/ziti/cmd/fabric/add_identity.go b/ziti/cmd/fabric/add_identity.go similarity index 96% rename from ziti/cmd/ziti/cmd/fabric/add_identity.go rename to ziti/cmd/fabric/add_identity.go index da88bf378..f70e03cf9 100644 --- a/ziti/cmd/ziti/cmd/fabric/add_identity.go +++ b/ziti/cmd/fabric/add_identity.go @@ -17,8 +17,8 @@ package fabric import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/create_router.go b/ziti/cmd/fabric/create_router.go similarity index 96% rename from ziti/cmd/ziti/cmd/fabric/create_router.go rename to ziti/cmd/fabric/create_router.go index c4a49feb2..30e229a34 100644 --- a/ziti/cmd/ziti/cmd/fabric/create_router.go +++ b/ziti/cmd/fabric/create_router.go @@ -19,11 +19,10 @@ package fabric import ( "crypto/sha1" "fmt" - "github.com/Jeffail/gabs" "github.com/openziti/identity/certtools" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/create_service.go b/ziti/cmd/fabric/create_service.go similarity index 95% rename from ziti/cmd/ziti/cmd/fabric/create_service.go rename to ziti/cmd/fabric/create_service.go index 296eaf5cd..cbde98cb4 100644 --- a/ziti/cmd/ziti/cmd/fabric/create_service.go +++ b/ziti/cmd/fabric/create_service.go @@ -18,8 +18,8 @@ package fabric import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/create_terminator.go b/ziti/cmd/fabric/create_terminator.go similarity index 94% rename from ziti/cmd/ziti/cmd/fabric/create_terminator.go rename to ziti/cmd/fabric/create_terminator.go index 704b2ed7d..f0babd273 100644 --- a/ziti/cmd/ziti/cmd/fabric/create_terminator.go +++ b/ziti/cmd/fabric/create_terminator.go @@ -21,10 +21,10 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/edge/router/xgress_edge_transport" "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "math" ) diff --git a/ziti/cmd/ziti/cmd/fabric/db.go b/ziti/cmd/fabric/db.go similarity index 80% rename from ziti/cmd/ziti/cmd/fabric/db.go rename to ziti/cmd/fabric/db.go index 849db59ff..fee817e91 100644 --- a/ziti/cmd/ziti/cmd/fabric/db.go +++ b/ziti/cmd/fabric/db.go @@ -1,8 +1,8 @@ package fabric import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/db_check_integrity.go b/ziti/cmd/fabric/db_check_integrity.go similarity index 94% rename from ziti/cmd/ziti/cmd/fabric/db_check_integrity.go rename to ziti/cmd/fabric/db_check_integrity.go index 46d9fb153..02bec1f33 100644 --- a/ziti/cmd/ziti/cmd/fabric/db_check_integrity.go +++ b/ziti/cmd/fabric/db_check_integrity.go @@ -3,10 +3,10 @@ package fabric import ( "fmt" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "github.com/spf13/cobra" "net/http" diff --git a/ziti/cmd/ziti/cmd/fabric/db_snapshot.go b/ziti/cmd/fabric/db_snapshot.go similarity index 87% rename from ziti/cmd/ziti/cmd/fabric/db_snapshot.go rename to ziti/cmd/fabric/db_snapshot.go index 75912a175..239215c0b 100644 --- a/ziti/cmd/ziti/cmd/fabric/db_snapshot.go +++ b/ziti/cmd/fabric/db_snapshot.go @@ -17,10 +17,10 @@ package fabric import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "net/http" ) diff --git a/ziti/cmd/ziti/cmd/fabric/delete.go b/ziti/cmd/fabric/delete.go similarity index 95% rename from ziti/cmd/ziti/cmd/fabric/delete.go rename to ziti/cmd/fabric/delete.go index 7c7a60e4c..2a514e180 100644 --- a/ziti/cmd/ziti/cmd/fabric/delete.go +++ b/ziti/cmd/fabric/delete.go @@ -18,10 +18,10 @@ package fabric import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" ) diff --git a/ziti/cmd/ziti/cmd/fabric/inspect.go b/ziti/cmd/fabric/inspect.go similarity index 96% rename from ziti/cmd/ziti/cmd/fabric/inspect.go rename to ziti/cmd/fabric/inspect.go index 8e07f9bd2..e39cdef71 100644 --- a/ziti/cmd/ziti/cmd/fabric/inspect.go +++ b/ziti/cmd/fabric/inspect.go @@ -7,9 +7,9 @@ import ( "github.com/openziti/fabric/rest_model" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/util" "github.com/spf13/cobra" "io" "os" diff --git a/ziti/cmd/ziti/cmd/fabric/list.go b/ziti/cmd/fabric/list.go similarity index 97% rename from ziti/cmd/ziti/cmd/fabric/list.go rename to ziti/cmd/fabric/list.go index a8c19803a..d41e9ad70 100644 --- a/ziti/cmd/ziti/cmd/fabric/list.go +++ b/ziti/cmd/fabric/list.go @@ -18,15 +18,15 @@ package fabric import ( "fmt" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "strings" "github.com/Jeffail/gabs" "github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/text" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/remove_identity.go b/ziti/cmd/fabric/remove_identity.go similarity index 91% rename from ziti/cmd/ziti/cmd/fabric/remove_identity.go rename to ziti/cmd/fabric/remove_identity.go index 6daa83260..9d4895ce4 100644 --- a/ziti/cmd/ziti/cmd/fabric/remove_identity.go +++ b/ziti/cmd/fabric/remove_identity.go @@ -17,9 +17,9 @@ package fabric import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "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" ) diff --git a/ziti/cmd/ziti/cmd/fabric/root.go b/ziti/cmd/fabric/root.go similarity index 94% rename from ziti/cmd/ziti/cmd/fabric/root.go rename to ziti/cmd/fabric/root.go index f5ddc17b0..8775a39ba 100644 --- a/ziti/cmd/ziti/cmd/fabric/root.go +++ b/ziti/cmd/fabric/root.go @@ -18,10 +18,10 @@ package fabric import ( "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "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" "gopkg.in/resty.v1" ) diff --git a/ziti/cmd/ziti/cmd/fabric/stream_circuits.go b/ziti/cmd/fabric/stream_circuits.go similarity index 96% rename from ziti/cmd/ziti/cmd/fabric/stream_circuits.go rename to ziti/cmd/fabric/stream_circuits.go index 8b12030fc..bde0ae5af 100644 --- a/ziti/cmd/ziti/cmd/fabric/stream_circuits.go +++ b/ziti/cmd/fabric/stream_circuits.go @@ -18,12 +18,12 @@ package fabric import ( "fmt" - "google.golang.org/protobuf/proto" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" + "google.golang.org/protobuf/proto" "time" ) diff --git a/ziti/cmd/ziti/cmd/fabric/stream_metrics.go b/ziti/cmd/fabric/stream_metrics.go similarity index 97% rename from ziti/cmd/ziti/cmd/fabric/stream_metrics.go rename to ziti/cmd/fabric/stream_metrics.go index b590abaf9..bbb8082bf 100644 --- a/ziti/cmd/ziti/cmd/fabric/stream_metrics.go +++ b/ziti/cmd/fabric/stream_metrics.go @@ -20,8 +20,8 @@ import ( "fmt" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" diff --git a/ziti/cmd/ziti/cmd/fabric/stream_toggle_pipe_traces.go b/ziti/cmd/fabric/stream_toggle_pipe_traces.go similarity index 96% rename from ziti/cmd/ziti/cmd/fabric/stream_toggle_pipe_traces.go rename to ziti/cmd/fabric/stream_toggle_pipe_traces.go index c4c14b51c..7113bee60 100644 --- a/ziti/cmd/ziti/cmd/fabric/stream_toggle_pipe_traces.go +++ b/ziti/cmd/fabric/stream_toggle_pipe_traces.go @@ -18,13 +18,13 @@ package fabric import ( "fmt" - "google.golang.org/protobuf/proto" "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/trace/pb" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" + "google.golang.org/protobuf/proto" "time" ) diff --git a/ziti/cmd/ziti/cmd/fabric/stream_traces.go b/ziti/cmd/fabric/stream_traces.go similarity index 98% rename from ziti/cmd/ziti/cmd/fabric/stream_traces.go rename to ziti/cmd/fabric/stream_traces.go index f902e2e6e..a9691f833 100644 --- a/ziti/cmd/ziti/cmd/fabric/stream_traces.go +++ b/ziti/cmd/fabric/stream_traces.go @@ -19,15 +19,15 @@ package fabric import ( "encoding/json" "fmt" - "google.golang.org/protobuf/proto" "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/trace/pb" "github.com/openziti/fabric/pb/ctrl_pb" "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/fabric/router/xgress" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/spf13/cobra" + "google.golang.org/protobuf/proto" "reflect" "sort" "time" diff --git a/ziti/cmd/ziti/cmd/fabric/update_link.go b/ziti/cmd/fabric/update_link.go similarity index 92% rename from ziti/cmd/ziti/cmd/fabric/update_link.go rename to ziti/cmd/fabric/update_link.go index adaafeccb..14c504386 100644 --- a/ziti/cmd/ziti/cmd/fabric/update_link.go +++ b/ziti/cmd/fabric/update_link.go @@ -18,12 +18,12 @@ package fabric import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/update_router.go b/ziti/cmd/fabric/update_router.go similarity index 93% rename from ziti/cmd/ziti/cmd/fabric/update_router.go rename to ziti/cmd/fabric/update_router.go index 4e8972183..693c9726a 100644 --- a/ziti/cmd/ziti/cmd/fabric/update_router.go +++ b/ziti/cmd/fabric/update_router.go @@ -18,14 +18,13 @@ package fabric import ( "fmt" - - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/update_service.go b/ziti/cmd/fabric/update_service.go similarity index 92% rename from ziti/cmd/ziti/cmd/fabric/update_service.go rename to ziti/cmd/fabric/update_service.go index 7459336da..a7d4dd007 100644 --- a/ziti/cmd/ziti/cmd/fabric/update_service.go +++ b/ziti/cmd/fabric/update_service.go @@ -18,13 +18,13 @@ package fabric import ( "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "github.com/pkg/errors" "github.com/Jeffail/gabs" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/fabric/update_terminator.go b/ziti/cmd/fabric/update_terminator.go similarity index 94% rename from ziti/cmd/ziti/cmd/fabric/update_terminator.go rename to ziti/cmd/fabric/update_terminator.go index 42e5e7a3a..9541f8d15 100644 --- a/ziti/cmd/ziti/cmd/fabric/update_terminator.go +++ b/ziti/cmd/fabric/update_terminator.go @@ -21,10 +21,10 @@ import ( "fmt" "github.com/Jeffail/gabs" "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" errors2 "github.com/pkg/errors" "github.com/spf13/cobra" "math" diff --git a/ziti/cmd/ziti/cmd/helpers/env_helpers.go b/ziti/cmd/helpers/env_helpers.go similarity index 99% rename from ziti/cmd/ziti/cmd/helpers/env_helpers.go rename to ziti/cmd/helpers/env_helpers.go index 21ee4d8e1..ba3afbfa2 100644 --- a/ziti/cmd/ziti/cmd/helpers/env_helpers.go +++ b/ziti/cmd/helpers/env_helpers.go @@ -18,7 +18,7 @@ package helpers import ( edge "github.com/openziti/edge/controller/config" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" + "github.com/openziti/ziti/ziti/constants" "github.com/pkg/errors" "os" "strconv" diff --git a/ziti/cmd/ziti/cmd/helpers/helpers.go b/ziti/cmd/helpers/helpers.go similarity index 100% rename from ziti/cmd/ziti/cmd/helpers/helpers.go rename to ziti/cmd/helpers/helpers.go diff --git a/ziti/cmd/ziti/cmd/helpers/helpers_test.go b/ziti/cmd/helpers/helpers_test.go similarity index 100% rename from ziti/cmd/ziti/cmd/helpers/helpers_test.go rename to ziti/cmd/helpers/helpers_test.go diff --git a/ziti/cmd/ziti/cmd/init.go b/ziti/cmd/init.go similarity index 92% rename from ziti/cmd/ziti/cmd/init.go rename to ziti/cmd/init.go index 73cb4d4b8..48c2b1815 100644 --- a/ziti/cmd/ziti/cmd/init.go +++ b/ziti/cmd/init.go @@ -17,9 +17,9 @@ package cmd import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/install.go b/ziti/cmd/install.go similarity index 94% rename from ziti/cmd/ziti/cmd/install.go rename to ziti/cmd/install.go index 283d037ac..753ae3e85 100644 --- a/ziti/cmd/ziti/cmd/install.go +++ b/ziti/cmd/install.go @@ -17,10 +17,10 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go b/ziti/cmd/install_terraform_provider_edge_controller.go similarity index 92% rename from ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go rename to ziti/cmd/install_terraform_provider_edge_controller.go index 71b6b84e5..a90747874 100644 --- a/ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go +++ b/ziti/cmd/install_terraform_provider_edge_controller.go @@ -17,13 +17,13 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_ziti_ALL.go b/ziti/cmd/install_ziti_ALL.go similarity index 92% rename from ziti/cmd/ziti/cmd/install_ziti_ALL.go rename to ziti/cmd/install_ziti_ALL.go index 0a1285df8..01fb32d7c 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_ALL.go +++ b/ziti/cmd/install_ziti_ALL.go @@ -17,14 +17,14 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_ziti_controller.go b/ziti/cmd/install_ziti_controller.go similarity index 91% rename from ziti/cmd/ziti/cmd/install_ziti_controller.go rename to ziti/cmd/install_ziti_controller.go index 48ec8b3c7..aa4f67bb6 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_controller.go +++ b/ziti/cmd/install_ziti_controller.go @@ -17,14 +17,14 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go b/ziti/cmd/install_ziti_edge_tunnel.go similarity index 91% rename from ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go rename to ziti/cmd/install_ziti_edge_tunnel.go index 9d7d7a4a0..144ea72da 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go +++ b/ziti/cmd/install_ziti_edge_tunnel.go @@ -17,13 +17,13 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_ziti_prox_c.go b/ziti/cmd/install_ziti_prox_c.go similarity index 91% rename from ziti/cmd/ziti/cmd/install_ziti_prox_c.go rename to ziti/cmd/install_ziti_prox_c.go index 5385d7ed5..0c87056aa 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_prox_c.go +++ b/ziti/cmd/install_ziti_prox_c.go @@ -17,13 +17,13 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_ziti_router.go b/ziti/cmd/install_ziti_router.go similarity index 91% rename from ziti/cmd/ziti/cmd/install_ziti_router.go rename to ziti/cmd/install_ziti_router.go index bebf4508b..1296e7b30 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_router.go +++ b/ziti/cmd/install_ziti_router.go @@ -17,14 +17,14 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/install_ziti_tunnel.go b/ziti/cmd/install_ziti_tunnel.go similarity index 91% rename from ziti/cmd/ziti/cmd/install_ziti_tunnel.go rename to ziti/cmd/install_ziti_tunnel.go index 2a635d8d5..4d5e4c1cc 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_tunnel.go +++ b/ziti/cmd/install_ziti_tunnel.go @@ -17,14 +17,14 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/KeyTypeVar.go b/ziti/cmd/lets_encrypt/KeyTypeVar.go similarity index 100% rename from ziti/cmd/ziti/cmd/lets_encrypt/KeyTypeVar.go rename to ziti/cmd/lets_encrypt/KeyTypeVar.go diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/account.go b/ziti/cmd/lets_encrypt/account.go similarity index 100% rename from ziti/cmd/ziti/cmd/lets_encrypt/account.go rename to ziti/cmd/lets_encrypt/account.go diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/accounts_storage.go b/ziti/cmd/lets_encrypt/accounts_storage.go similarity index 81% rename from ziti/cmd/ziti/cmd/lets_encrypt/accounts_storage.go rename to ziti/cmd/lets_encrypt/accounts_storage.go index 64f8ffba4..45faf02c4 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/accounts_storage.go +++ b/ziti/cmd/lets_encrypt/accounts_storage.go @@ -23,6 +23,7 @@ import ( "encoding/pem" "errors" "fmt" + "github.com/openziti/ziti/ziti/internal/log" "io/ioutil" "net/url" "os" @@ -32,7 +33,6 @@ import ( "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" ) const ( @@ -45,36 +45,35 @@ const ( // // rootPath: // -// ./.path/accounts/ -// │ └── root accounts directory -// └── "path" option +// ./.path/accounts/ +// │ └── root accounts directory +// └── "path" option // // rootUserPath: // -// ./.path/accounts/localhost_14000/hubert@hubert.com/ -// │ │ │ └── userID ("email" option) -// │ │ └── CA server ("server" option) -// │ └── root accounts directory -// └── "path" option +// ./.path/accounts/localhost_14000/hubert@hubert.com/ +// │ │ │ └── userID ("email" option) +// │ │ └── CA server ("server" option) +// │ └── root accounts directory +// └── "path" option // // keysPath: // -// ./.path/accounts/localhost_14000/hubert@hubert.com/keys/ -// │ │ │ │ └── root keys directory -// │ │ │ └── userID ("email" option) -// │ │ └── CA server ("server" option) -// │ └── root accounts directory -// └── "path" option +// ./.path/accounts/localhost_14000/hubert@hubert.com/keys/ +// │ │ │ │ └── root keys directory +// │ │ │ └── userID ("email" option) +// │ │ └── CA server ("server" option) +// │ └── root accounts directory +// └── "path" option // // accountFilePath: // -// ./.path/accounts/localhost_14000/hubert@hubert.com/account.json -// │ │ │ │ └── account file -// │ │ │ └── userID ("email" option) -// │ │ └── CA server ("server" option) -// │ └── root accounts directory -// └── "path" option -// +// ./.path/accounts/localhost_14000/hubert@hubert.com/account.json +// │ │ │ │ └── account file +// │ │ │ └── userID ("email" option) +// │ │ └── CA server ("server" option) +// │ └── root accounts directory +// └── "path" option type AccountsStorage struct { userID string rootPath string diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/certs_storage.go b/ziti/cmd/lets_encrypt/certs_storage.go similarity index 95% rename from ziti/cmd/ziti/cmd/lets_encrypt/certs_storage.go rename to ziti/cmd/lets_encrypt/certs_storage.go index 18b36f8b1..c19e2f3ab 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/certs_storage.go +++ b/ziti/cmd/lets_encrypt/certs_storage.go @@ -20,6 +20,7 @@ import ( "bytes" "crypto/x509" "encoding/json" + "github.com/openziti/ziti/ziti/internal/log" "io/ioutil" "os" "path/filepath" @@ -29,7 +30,6 @@ import ( "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "golang.org/x/net/idna" ) @@ -44,16 +44,15 @@ const ( // // rootPath: // -// ./.path/certificates/ -// │ └── root certificates directory -// └── "path" option +// ./.path/certificates/ +// │ └── root certificates directory +// └── "path" option // // archivePath: // -// ./.path/archives/ -// │ └── archived certificates directory -// └── "path" option -// +// ./.path/archives/ +// │ └── archived certificates directory +// └── "path" option type CertificatesStorage struct { rootPath string archivePath string diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/create.go b/ziti/cmd/lets_encrypt/create.go similarity index 97% rename from ziti/cmd/ziti/cmd/lets_encrypt/create.go rename to ziti/cmd/lets_encrypt/create.go index ec921a8d8..4f34029b2 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/create.go +++ b/ziti/cmd/lets_encrypt/create.go @@ -21,8 +21,8 @@ import ( "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "github.com/spf13/cobra" "io" ) diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/list.go b/ziti/cmd/lets_encrypt/list.go similarity index 98% rename from ziti/cmd/ziti/cmd/lets_encrypt/list.go rename to ziti/cmd/lets_encrypt/list.go index 257be1231..20aac1cdf 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/list.go +++ b/ziti/cmd/lets_encrypt/list.go @@ -19,6 +19,7 @@ package lets_encrypt import ( "encoding/json" "fmt" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "io" "io/ioutil" "net/url" @@ -26,7 +27,6 @@ import ( "strings" "github.com/go-acme/lego/v4/certcrypto" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/renew.go b/ziti/cmd/lets_encrypt/renew.go similarity index 97% rename from ziti/cmd/ziti/cmd/lets_encrypt/renew.go rename to ziti/cmd/lets_encrypt/renew.go index 8bff1691f..75e811e9c 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/renew.go +++ b/ziti/cmd/lets_encrypt/renew.go @@ -22,8 +22,8 @@ import ( "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "github.com/spf13/cobra" "io" "time" diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/revoke.go b/ziti/cmd/lets_encrypt/revoke.go similarity index 96% rename from ziti/cmd/ziti/cmd/lets_encrypt/revoke.go rename to ziti/cmd/lets_encrypt/revoke.go index 23e702b92..db2ccb288 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/revoke.go +++ b/ziti/cmd/lets_encrypt/revoke.go @@ -17,10 +17,10 @@ package lets_encrypt import ( - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/root.go b/ziti/cmd/lets_encrypt/root.go similarity index 97% rename from ziti/cmd/ziti/cmd/lets_encrypt/root.go rename to ziti/cmd/lets_encrypt/root.go index 3f9512d2f..d62f4d5a1 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/root.go +++ b/ziti/cmd/lets_encrypt/root.go @@ -17,9 +17,9 @@ package lets_encrypt import ( + "github.com/openziti/ziti/ziti/util" "io" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/setup.go b/ziti/cmd/lets_encrypt/setup.go similarity index 98% rename from ziti/cmd/ziti/cmd/lets_encrypt/setup.go rename to ziti/cmd/lets_encrypt/setup.go index eeeee2c08..c52bf3d4f 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/setup.go +++ b/ziti/cmd/lets_encrypt/setup.go @@ -20,6 +20,7 @@ import ( "crypto/x509" "encoding/pem" "fmt" + "github.com/openziti/ziti/ziti/internal/log" "io/ioutil" "os" "time" @@ -27,7 +28,6 @@ import ( "github.com/go-acme/lego/v4/challenge/http01" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" ) func setup(options *leOptions, accountsStorage *AccountsStorage) (*Account, *lego.Client) { diff --git a/ziti/cmd/ziti/cmd/log_filter.go b/ziti/cmd/log_filter.go similarity index 96% rename from ziti/cmd/ziti/cmd/log_filter.go rename to ziti/cmd/log_filter.go index b99df2006..ffff98bc1 100644 --- a/ziti/cmd/ziti/cmd/log_filter.go +++ b/ziti/cmd/log_filter.go @@ -18,7 +18,7 @@ package cmd import ( "github.com/michaelquigley/pfxlog" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" diff --git a/ziti/cmd/ziti/cmd/pki.go b/ziti/cmd/pki.go similarity index 92% rename from ziti/cmd/ziti/cmd/pki.go rename to ziti/cmd/pki.go index 10924e24a..6eec79dfd 100644 --- a/ziti/cmd/ziti/cmd/pki.go +++ b/ziti/cmd/pki.go @@ -17,13 +17,12 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/lets_encrypt" + "github.com/openziti/ziti/ziti/cmd/templates" + "github.com/openziti/ziti/ziti/pki/pki" "github.com/spf13/cobra" "io" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/lets_encrypt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - "github.com/openziti/ziti/ziti/pki/pki" ) // PKIOptions contains the command line options diff --git a/ziti/cmd/ziti/cmd/pki_create.go b/ziti/cmd/pki_create.go similarity index 99% rename from ziti/cmd/ziti/cmd/pki_create.go rename to ziti/cmd/pki_create.go index 739e03f89..4ad54c0d4 100644 --- a/ziti/cmd/ziti/cmd/pki_create.go +++ b/ziti/cmd/pki_create.go @@ -22,6 +22,8 @@ import ( "encoding/asn1" "errors" "fmt" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/util" "io" "io/ioutil" "net" @@ -31,8 +33,6 @@ import ( "github.com/spf13/cobra" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/viper" ) diff --git a/ziti/cmd/ziti/cmd/pki_create_ca.go b/ziti/cmd/pki_create_ca.go similarity index 96% rename from ziti/cmd/ziti/cmd/pki_create_ca.go rename to ziti/cmd/pki_create_ca.go index 35c14d0b8..c263ef0ba 100644 --- a/ziti/cmd/ziti/cmd/pki_create_ca.go +++ b/ziti/cmd/pki_create_ca.go @@ -17,17 +17,16 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/pki/certificate" + "github.com/openziti/ziti/ziti/pki/pki" + "github.com/openziti/ziti/ziti/pki/store" "github.com/pkg/errors" "github.com/spf13/cobra" "io" "net/url" "strings" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/pki/certificate" - "github.com/openziti/ziti/ziti/pki/pki" - "github.com/openziti/ziti/ziti/pki/store" ) // PKICreateCAOptions the options for the create spring command diff --git a/ziti/cmd/ziti/cmd/pki_create_client.go b/ziti/cmd/pki_create_client.go similarity index 97% rename from ziti/cmd/ziti/cmd/pki_create_client.go rename to ziti/cmd/pki_create_client.go index 38f785c95..8ed3c145c 100644 --- a/ziti/cmd/ziti/cmd/pki_create_client.go +++ b/ziti/cmd/pki_create_client.go @@ -17,16 +17,15 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/pki/certificate" + "github.com/openziti/ziti/ziti/pki/pki" + "github.com/openziti/ziti/ziti/pki/store" "github.com/pkg/errors" "github.com/spf13/cobra" "io" "net/url" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/pki/certificate" - "github.com/openziti/ziti/ziti/pki/pki" - "github.com/openziti/ziti/ziti/pki/store" ) // PKICreateClientOptions the options for the create spring command diff --git a/ziti/cmd/ziti/cmd/pki_create_csr.go b/ziti/cmd/pki_create_csr.go similarity index 96% rename from ziti/cmd/ziti/cmd/pki_create_csr.go rename to ziti/cmd/pki_create_csr.go index 3a7599456..e45fac863 100644 --- a/ziti/cmd/ziti/cmd/pki_create_csr.go +++ b/ziti/cmd/pki_create_csr.go @@ -18,13 +18,12 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" - "io" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "github.com/openziti/ziti/ziti/pki/pki" "github.com/openziti/ziti/ziti/pki/store" + "github.com/spf13/cobra" + "io" ) // PKICreateCSROptions the options for the create spring command diff --git a/ziti/cmd/ziti/cmd/pki_create_intermediate.go b/ziti/cmd/pki_create_intermediate.go similarity index 96% rename from ziti/cmd/ziti/cmd/pki_create_intermediate.go rename to ziti/cmd/pki_create_intermediate.go index d664c5bb2..21cad1e52 100644 --- a/ziti/cmd/ziti/cmd/pki_create_intermediate.go +++ b/ziti/cmd/pki_create_intermediate.go @@ -17,15 +17,14 @@ package cmd import ( - "github.com/pkg/errors" - "github.com/spf13/cobra" - "io" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "github.com/openziti/ziti/ziti/pki/certificate" "github.com/openziti/ziti/ziti/pki/pki" "github.com/openziti/ziti/ziti/pki/store" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "io" ) // PKICreateIntermediateOptions the options for the create spring command diff --git a/ziti/cmd/ziti/cmd/pki_create_key.go b/ziti/cmd/pki_create_key.go similarity index 96% rename from ziti/cmd/ziti/cmd/pki_create_key.go rename to ziti/cmd/pki_create_key.go index 29c721f7f..07954d88a 100644 --- a/ziti/cmd/ziti/cmd/pki_create_key.go +++ b/ziti/cmd/pki_create_key.go @@ -18,14 +18,13 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" - "io" - - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "github.com/openziti/ziti/ziti/pki/certificate" "github.com/openziti/ziti/ziti/pki/pki" "github.com/openziti/ziti/ziti/pki/store" + "github.com/spf13/cobra" + "io" ) // PKICreateKeyOptions the options for the create spring command diff --git a/ziti/cmd/ziti/cmd/pki_create_server.go b/ziti/cmd/pki_create_server.go similarity index 97% rename from ziti/cmd/ziti/cmd/pki_create_server.go rename to ziti/cmd/pki_create_server.go index e1b64a2f4..469248d58 100644 --- a/ziti/cmd/ziti/cmd/pki_create_server.go +++ b/ziti/cmd/pki_create_server.go @@ -17,8 +17,8 @@ package cmd import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/internal/log" "github.com/openziti/ziti/ziti/pki/certificate" "github.com/openziti/ziti/ziti/pki/pki" "github.com/openziti/ziti/ziti/pki/store" diff --git a/ziti/cmd/ziti/cmd/table/padding.go b/ziti/cmd/table/padding.go similarity index 100% rename from ziti/cmd/ziti/cmd/table/padding.go rename to ziti/cmd/table/padding.go diff --git a/ziti/cmd/ziti/cmd/table/table.go b/ziti/cmd/table/table.go similarity index 100% rename from ziti/cmd/ziti/cmd/table/table.go rename to ziti/cmd/table/table.go diff --git a/ziti/cmd/ziti/cmd/templates/command_groups.go b/ziti/cmd/templates/command_groups.go similarity index 100% rename from ziti/cmd/ziti/cmd/templates/command_groups.go rename to ziti/cmd/templates/command_groups.go diff --git a/ziti/cmd/ziti/cmd/templates/markdown.go b/ziti/cmd/templates/markdown.go similarity index 100% rename from ziti/cmd/ziti/cmd/templates/markdown.go rename to ziti/cmd/templates/markdown.go diff --git a/ziti/cmd/ziti/cmd/templates/normalizers.go b/ziti/cmd/templates/normalizers.go similarity index 100% rename from ziti/cmd/ziti/cmd/templates/normalizers.go rename to ziti/cmd/templates/normalizers.go diff --git a/ziti/cmd/ziti/cmd/templates/templater.go b/ziti/cmd/templates/templater.go similarity index 99% rename from ziti/cmd/ziti/cmd/templates/templater.go rename to ziti/cmd/templates/templater.go index ca1f76e71..deae8e1c2 100644 --- a/ziti/cmd/ziti/cmd/templates/templater.go +++ b/ziti/cmd/templates/templater.go @@ -19,7 +19,7 @@ package templates import ( "bytes" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/table" + "github.com/openziti/ziti/ziti/cmd/table" "io" "strings" "text/template" diff --git a/ziti/cmd/ziti/cmd/templates/templates.go b/ziti/cmd/templates/templates.go similarity index 100% rename from ziti/cmd/ziti/cmd/templates/templates.go rename to ziti/cmd/templates/templates.go diff --git a/ziti/cmd/ziti/cmd/tutorial/first-service-tutorial.go b/ziti/cmd/tutorial/first-service-tutorial.go similarity index 96% rename from ziti/cmd/ziti/cmd/tutorial/first-service-tutorial.go rename to ziti/cmd/tutorial/first-service-tutorial.go index 69e2f5650..3e37f9830 100644 --- a/ziti/cmd/ziti/cmd/tutorial/first-service-tutorial.go +++ b/ziti/cmd/tutorial/first-service-tutorial.go @@ -20,9 +20,9 @@ import ( _ "embed" "github.com/openziti/runzmd" "github.com/openziti/runzmd/actionz" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "time" diff --git a/ziti/cmd/ziti/cmd/tutorial/plain_echo_client.go b/ziti/cmd/tutorial/plain_echo_client.go similarity index 100% rename from ziti/cmd/ziti/cmd/tutorial/plain_echo_client.go rename to ziti/cmd/tutorial/plain_echo_client.go diff --git a/ziti/cmd/ziti/cmd/tutorial/plain_echo_client_cmd.go b/ziti/cmd/tutorial/plain_echo_client_cmd.go similarity index 93% rename from ziti/cmd/ziti/cmd/tutorial/plain_echo_client_cmd.go rename to ziti/cmd/tutorial/plain_echo_client_cmd.go index f15cf546d..39e4a2729 100644 --- a/ziti/cmd/ziti/cmd/tutorial/plain_echo_client_cmd.go +++ b/ziti/cmd/tutorial/plain_echo_client_cmd.go @@ -17,8 +17,8 @@ package tutorial import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "strings" ) diff --git a/ziti/cmd/ziti/cmd/tutorial/plain_echo_server.go b/ziti/cmd/tutorial/plain_echo_server.go similarity index 100% rename from ziti/cmd/ziti/cmd/tutorial/plain_echo_server.go rename to ziti/cmd/tutorial/plain_echo_server.go diff --git a/ziti/cmd/ziti/cmd/tutorial/plain_echo_server_cmd.go b/ziti/cmd/tutorial/plain_echo_server_cmd.go similarity index 93% rename from ziti/cmd/ziti/cmd/tutorial/plain_echo_server_cmd.go rename to ziti/cmd/tutorial/plain_echo_server_cmd.go index 514a95fd5..e76b7788e 100644 --- a/ziti/cmd/ziti/cmd/tutorial/plain_echo_server_cmd.go +++ b/ziti/cmd/tutorial/plain_echo_server_cmd.go @@ -17,8 +17,8 @@ package tutorial import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/tutorial/root.go b/ziti/cmd/tutorial/root.go similarity index 90% rename from ziti/cmd/ziti/cmd/tutorial/root.go rename to ziti/cmd/tutorial/root.go index 190a54fa9..2a735ce8f 100644 --- a/ziti/cmd/ziti/cmd/tutorial/root.go +++ b/ziti/cmd/tutorial/root.go @@ -17,9 +17,9 @@ package tutorial import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/edge" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/edge" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/tutorial/tutorials/first-service.md b/ziti/cmd/tutorial/tutorials/first-service.md similarity index 100% rename from ziti/cmd/ziti/cmd/tutorial/tutorials/first-service.md rename to ziti/cmd/tutorial/tutorials/first-service.md diff --git a/ziti/cmd/ziti/cmd/tutorial/tutorials/more-info.md b/ziti/cmd/tutorial/tutorials/more-info.md similarity index 100% rename from ziti/cmd/ziti/cmd/tutorial/tutorials/more-info.md rename to ziti/cmd/tutorial/tutorials/more-info.md diff --git a/ziti/cmd/ziti/cmd/tutorial/ziti_echo_client.go b/ziti/cmd/tutorial/ziti_echo_client.go similarity index 100% rename from ziti/cmd/ziti/cmd/tutorial/ziti_echo_client.go rename to ziti/cmd/tutorial/ziti_echo_client.go diff --git a/ziti/cmd/ziti/cmd/tutorial/ziti_echo_client_cmd.go b/ziti/cmd/tutorial/ziti_echo_client_cmd.go similarity index 93% rename from ziti/cmd/ziti/cmd/tutorial/ziti_echo_client_cmd.go rename to ziti/cmd/tutorial/ziti_echo_client_cmd.go index 2b089680e..2a0561db8 100644 --- a/ziti/cmd/ziti/cmd/tutorial/ziti_echo_client_cmd.go +++ b/ziti/cmd/tutorial/ziti_echo_client_cmd.go @@ -17,8 +17,8 @@ package tutorial import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "strings" diff --git a/ziti/cmd/ziti/cmd/tutorial/ziti_echo_server.go b/ziti/cmd/tutorial/ziti_echo_server.go similarity index 100% rename from ziti/cmd/ziti/cmd/tutorial/ziti_echo_server.go rename to ziti/cmd/tutorial/ziti_echo_server.go diff --git a/ziti/cmd/ziti/cmd/tutorial/ziti_echo_server_cmd.go b/ziti/cmd/tutorial/ziti_echo_server_cmd.go similarity index 93% rename from ziti/cmd/ziti/cmd/tutorial/ziti_echo_server_cmd.go rename to ziti/cmd/tutorial/ziti_echo_server_cmd.go index 274803227..7e6dcd30a 100644 --- a/ziti/cmd/ziti/cmd/tutorial/ziti_echo_server_cmd.go +++ b/ziti/cmd/tutorial/ziti_echo_server_cmd.go @@ -17,8 +17,8 @@ package tutorial import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "time" ) diff --git a/ziti/cmd/ziti/cmd/uninstall.go b/ziti/cmd/uninstall.go similarity index 94% rename from ziti/cmd/ziti/cmd/uninstall.go rename to ziti/cmd/uninstall.go index 452455e42..b3ce667ff 100644 --- a/ziti/cmd/ziti/cmd/uninstall.go +++ b/ziti/cmd/uninstall.go @@ -17,10 +17,10 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_controller.go b/ziti/cmd/uninstall_ziti_controller.go similarity index 91% rename from ziti/cmd/ziti/cmd/uninstall_ziti_controller.go rename to ziti/cmd/uninstall_ziti_controller.go index 94f7db23a..3ddd344f3 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_controller.go +++ b/ziti/cmd/uninstall_ziti_controller.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go b/ziti/cmd/uninstall_ziti_edge_tunnel.go similarity index 91% rename from ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go rename to ziti/cmd/uninstall_ziti_edge_tunnel.go index 0d9aa5423..3df0be1c4 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go +++ b/ziti/cmd/uninstall_ziti_edge_tunnel.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go b/ziti/cmd/uninstall_ziti_proxy_c.go similarity index 91% rename from ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go rename to ziti/cmd/uninstall_ziti_proxy_c.go index 98120ce79..e77ae62e4 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go +++ b/ziti/cmd/uninstall_ziti_proxy_c.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_router.go b/ziti/cmd/uninstall_ziti_router.go similarity index 91% rename from ziti/cmd/ziti/cmd/uninstall_ziti_router.go rename to ziti/cmd/uninstall_ziti_router.go index 9561cd97d..1e3e24ce2 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_router.go +++ b/ziti/cmd/uninstall_ziti_router.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go b/ziti/cmd/uninstall_ziti_tunnel.go similarity index 91% rename from ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go rename to ziti/cmd/uninstall_ziti_tunnel.go index 2a87951ec..3ed6af63d 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go +++ b/ziti/cmd/uninstall_ziti_tunnel.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/unwrap_identity.go b/ziti/cmd/unwrap_identity.go similarity index 100% rename from ziti/cmd/ziti/cmd/unwrap_identity.go rename to ziti/cmd/unwrap_identity.go diff --git a/ziti/cmd/ziti/cmd/upgrade.go b/ziti/cmd/upgrade.go similarity index 94% rename from ziti/cmd/ziti/cmd/upgrade.go rename to ziti/cmd/upgrade.go index 35539fc7c..d118a825a 100644 --- a/ziti/cmd/ziti/cmd/upgrade.go +++ b/ziti/cmd/upgrade.go @@ -17,10 +17,10 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti.go b/ziti/cmd/upgrade_ziti.go similarity index 92% rename from ziti/cmd/ziti/cmd/upgrade_ziti.go rename to ziti/cmd/upgrade_ziti.go index 6ed2ddfd1..b841946b0 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti.go +++ b/ziti/cmd/upgrade_ziti.go @@ -17,12 +17,12 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_controller.go b/ziti/cmd/upgrade_ziti_controller.go similarity index 93% rename from ziti/cmd/ziti/cmd/upgrade_ziti_controller.go rename to ziti/cmd/upgrade_ziti_controller.go index 6465a3531..e4acce6c0 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_controller.go +++ b/ziti/cmd/upgrade_ziti_controller.go @@ -17,12 +17,12 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go b/ziti/cmd/upgrade_ziti_edge_tunnel.go similarity index 92% rename from ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go rename to ziti/cmd/upgrade_ziti_edge_tunnel.go index 5001d904e..4de2689e7 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go +++ b/ziti/cmd/upgrade_ziti_edge_tunnel.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go b/ziti/cmd/upgrade_ziti_prox_c.go similarity index 92% rename from ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go rename to ziti/cmd/upgrade_ziti_prox_c.go index f6e542a03..a71baad45 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go +++ b/ziti/cmd/upgrade_ziti_prox_c.go @@ -17,11 +17,11 @@ package cmd import ( + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" "io" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_router.go b/ziti/cmd/upgrade_ziti_router.go similarity index 92% rename from ziti/cmd/ziti/cmd/upgrade_ziti_router.go rename to ziti/cmd/upgrade_ziti_router.go index faee574ad..a1bf3aad6 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_router.go +++ b/ziti/cmd/upgrade_ziti_router.go @@ -17,12 +17,12 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go b/ziti/cmd/upgrade_ziti_tunnel.go similarity index 92% rename from ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go rename to ziti/cmd/upgrade_ziti_tunnel.go index 4db8fbd76..349957bf7 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go +++ b/ziti/cmd/upgrade_ziti_tunnel.go @@ -17,12 +17,12 @@ package cmd import ( + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/use.go b/ziti/cmd/use.go similarity index 94% rename from ziti/cmd/ziti/cmd/use.go rename to ziti/cmd/use.go index 53fd343a3..5a15854d5 100644 --- a/ziti/cmd/ziti/cmd/use.go +++ b/ziti/cmd/use.go @@ -18,14 +18,14 @@ package cmd import ( "fmt" + 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" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" - "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/cmd/version.go b/ziti/cmd/version.go similarity index 95% rename from ziti/cmd/ziti/cmd/version.go rename to ziti/cmd/version.go index dae16dadb..268e6da81 100644 --- a/ziti/cmd/ziti/cmd/version.go +++ b/ziti/cmd/version.go @@ -19,18 +19,17 @@ package cmd import ( "fmt" "github.com/blang/semver" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/table" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/table" + c "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/util" "io" "os" // "strings" "github.com/openziti/ziti/common/version" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/util" - "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/main.go b/ziti/cmd/ziti/main.go deleted file mode 100644 index 366090131..000000000 --- a/ziti/cmd/ziti/main.go +++ /dev/null @@ -1,25 +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 main - -import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd" -) - -func main() { - cmd.Execute() -} diff --git a/ziti/cmd/ziti/constants/constants.go b/ziti/constants/constants.go similarity index 100% rename from ziti/cmd/ziti/constants/constants.go rename to ziti/constants/constants.go diff --git a/ziti-controller/subcmd/delete_sessions.go b/ziti/controller/delete_sessions.go similarity index 99% rename from ziti-controller/subcmd/delete_sessions.go rename to ziti/controller/delete_sessions.go index 8e990e501..d157f09e2 100644 --- a/ziti-controller/subcmd/delete_sessions.go +++ b/ziti/controller/delete_sessions.go @@ -14,7 +14,7 @@ limitations under the License. */ -package subcmd +package controller import ( "github.com/michaelquigley/pfxlog" diff --git a/ziti-controller/subcmd/root.go b/ziti/controller/root.go similarity index 95% rename from ziti-controller/subcmd/root.go rename to ziti/controller/root.go index cdaba127d..169dc140d 100644 --- a/ziti-controller/subcmd/root.go +++ b/ziti/controller/root.go @@ -14,15 +14,15 @@ limitations under the License. */ -package subcmd +package controller import ( "fmt" "github.com/michaelquigley/pfxlog" edgeSubCmd "github.com/openziti/edge/controller/subcmd" "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/util" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/ziti-controller/subcmd/run.go b/ziti/controller/run.go similarity index 99% rename from ziti-controller/subcmd/run.go rename to ziti/controller/run.go index 04039297a..d38812aed 100644 --- a/ziti-controller/subcmd/run.go +++ b/ziti/controller/run.go @@ -14,7 +14,7 @@ limitations under the License. */ -package subcmd +package controller import ( "fmt" diff --git a/ziti-controller/subcmd/version.go b/ziti/controller/version.go similarity index 97% rename from ziti-controller/subcmd/version.go rename to ziti/controller/version.go index a89b8e9b7..e93fd9d7d 100644 --- a/ziti-controller/subcmd/version.go +++ b/ziti/controller/version.go @@ -14,11 +14,11 @@ limitations under the License. */ -package subcmd +package controller import ( - "github.com/openziti/ziti/common/version" "fmt" + "github.com/openziti/ziti/common/version" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/internal/log/log.go b/ziti/internal/log/log.go similarity index 100% rename from ziti/cmd/ziti/internal/log/log.go rename to ziti/internal/log/log.go diff --git a/ziti/main.go b/ziti/main.go new file mode 100644 index 000000000..b49542760 --- /dev/null +++ b/ziti/main.go @@ -0,0 +1,52 @@ +/* + 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 main + +import ( + "github.com/michaelquigley/pfxlog" + "github.com/openziti/fabric/build" + "github.com/openziti/transport/v2" + "github.com/openziti/transport/v2/tcp" + "github.com/openziti/transport/v2/tls" + "github.com/openziti/transport/v2/transwarp" + "github.com/openziti/transport/v2/transwarptls" + "github.com/openziti/transport/v2/udp" + "github.com/openziti/transport/v2/ws" + "github.com/openziti/transport/v2/wss" + "github.com/openziti/ziti/common/version" + "github.com/openziti/ziti/ziti/cmd" + "github.com/sirupsen/logrus" +) + +func init() { + options := pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti/").NoColor() + pfxlog.GlobalInit(logrus.InfoLevel, options) + + transport.AddAddressParser(tls.AddressParser{}) + transport.AddAddressParser(tcp.AddressParser{}) + transport.AddAddressParser(transwarp.AddressParser{}) + transport.AddAddressParser(transwarptls.AddressParser{}) + transport.AddAddressParser(ws.AddressParser{}) + transport.AddAddressParser(wss.AddressParser{}) + transport.AddAddressParser(udp.AddressParser{}) + + build.InitBuildInfo(version.GetCmdBuildInfo()) +} + +func main() { + cmd.Execute() +} diff --git a/ziti/pki/pki/pki.go b/ziti/pki/pki/pki.go index 4b6143488..232daed0a 100644 --- a/ziti/pki/pki/pki.go +++ b/ziti/pki/pki/pki.go @@ -25,10 +25,10 @@ import ( "crypto/x509" "errors" "fmt" - "time" - "github.com/openziti/ziti/ziti/pki/certificate" "github.com/openziti/ziti/ziti/pki/store" + "time" + "github.com/openziti/identity/certtools" ) diff --git a/ziti/pki/store/local.go b/ziti/pki/store/local.go index 256a27834..3611ad3c3 100644 --- a/ziti/pki/store/local.go +++ b/ziti/pki/store/local.go @@ -21,6 +21,7 @@ import ( "crypto/x509/pkix" "encoding/pem" "fmt" + "github.com/openziti/ziti/ziti/pki/certificate" "io" "io/ioutil" "math/big" @@ -31,8 +32,6 @@ import ( "time" "crypto/x509" - - "github.com/openziti/ziti/ziti/pki/certificate" ) // Predifined directory names. @@ -424,16 +423,16 @@ func (l *Local) Revoked(caName string) ([]pkix.RevokedCertificate, error) { // InitCADir creates the basic structure of a CA subdirectory. // -// |- crlnumber -// |- index.txt -// |- index.txt.attr -// |- serial -// |- certs/ -// |- ca.cert -// |- name.cert -// |- keys/ -// |- ca.key -// |- name.key +// |- crlnumber +// |- index.txt +// |- index.txt.attr +// |- serial +// |- certs/ +// |- ca.cert +// |- name.cert +// |- keys/ +// |- ca.key +// |- name.key func InitCADir(path string) error { if _, err := os.Stat(path); err == nil { return nil diff --git a/ziti/pki/store/store.go b/ziti/pki/store/store.go index 9395c210c..d0aff3cfa 100644 --- a/ziti/pki/store/store.go +++ b/ziti/pki/store/store.go @@ -19,9 +19,8 @@ package store import ( "crypto/x509/pkix" - "math/big" - "github.com/openziti/ziti/ziti/pki/certificate" + "math/big" ) // Store reprents a way to store a Certificate Authority. diff --git a/ziti-router/subcmd/enrollgw.go b/ziti/router/enrollgw.go similarity index 99% rename from ziti-router/subcmd/enrollgw.go rename to ziti/router/enrollgw.go index 84b8b1a60..c35114636 100644 --- a/ziti-router/subcmd/enrollgw.go +++ b/ziti/router/enrollgw.go @@ -14,7 +14,7 @@ limitations under the License. */ -package subcmd +package router import ( "github.com/michaelquigley/pfxlog" diff --git a/ziti-router/subcmd/root.go b/ziti/router/root.go similarity index 94% rename from ziti-router/subcmd/root.go rename to ziti/router/root.go index aacb61535..36541e87d 100644 --- a/ziti-router/subcmd/root.go +++ b/ziti/router/root.go @@ -14,13 +14,13 @@ limitations under the License. */ -package subcmd +package router import ( "fmt" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/util" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/ziti-router/subcmd/run.go b/ziti/router/run.go similarity index 99% rename from ziti-router/subcmd/run.go rename to ziti/router/run.go index c9085fa07..d82fbfebb 100644 --- a/ziti-router/subcmd/run.go +++ b/ziti/router/run.go @@ -14,7 +14,7 @@ limitations under the License. */ -package subcmd +package router import ( "fmt" diff --git a/ziti-router/subcmd/version.go b/ziti/router/version.go similarity index 98% rename from ziti-router/subcmd/version.go rename to ziti/router/version.go index a89b8e9b7..54180f00c 100644 --- a/ziti-router/subcmd/version.go +++ b/ziti/router/version.go @@ -14,11 +14,11 @@ limitations under the License. */ -package subcmd +package router import ( - "github.com/openziti/ziti/common/version" "fmt" + "github.com/openziti/ziti/common/version" "github.com/spf13/cobra" ) diff --git a/ziti/cmd/ziti/util/certs.go b/ziti/util/certs.go similarity index 98% rename from ziti/cmd/ziti/util/certs.go rename to ziti/util/certs.go index adb7df84c..c72622361 100644 --- a/ziti/cmd/ziti/util/certs.go +++ b/ziti/util/certs.go @@ -7,6 +7,7 @@ import ( "encoding/base64" "encoding/pem" "fmt" + "github.com/openziti/ziti/ziti/cmd/common" "io/ioutil" "net/http" "net/url" @@ -17,7 +18,6 @@ import ( "strings" "github.com/fullsailor/pkcs7" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" "github.com/pkg/errors" ) diff --git a/ziti/cmd/ziti/util/colors.go b/ziti/util/colors.go similarity index 100% rename from ziti/cmd/ziti/util/colors.go rename to ziti/util/colors.go diff --git a/ziti/cmd/ziti/util/commands.go b/ziti/util/commands.go similarity index 98% rename from ziti/cmd/ziti/util/commands.go rename to ziti/util/commands.go index a0aa3e733..7135774d4 100644 --- a/ziti/cmd/ziti/util/commands.go +++ b/ziti/util/commands.go @@ -18,13 +18,12 @@ package util import ( "fmt" + "github.com/openziti/ziti/ziti/internal/log" "github.com/spf13/cobra" "github.com/spf13/viper" "os" "os/exec" "strings" - - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" ) const ( diff --git a/ziti/cmd/ziti/util/dirs.go b/ziti/util/dirs.go similarity index 100% rename from ziti/cmd/ziti/util/dirs.go rename to ziti/util/dirs.go diff --git a/ziti/cmd/ziti/util/files.go b/ziti/util/files.go similarity index 100% rename from ziti/cmd/ziti/util/files.go rename to ziti/util/files.go diff --git a/ziti/cmd/ziti/util/identities.go b/ziti/util/identities.go similarity index 99% rename from ziti/cmd/ziti/util/identities.go rename to ziti/util/identities.go index 7011d54ce..f56b4ad29 100644 --- a/ziti/cmd/ziti/util/identities.go +++ b/ziti/util/identities.go @@ -10,7 +10,7 @@ import ( fabric_rest_client "github.com/openziti/fabric/rest_client" "github.com/openziti/identity" "github.com/openziti/sdk-golang/ziti/constants" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + "github.com/openziti/ziti/ziti/cmd/common" "github.com/pkg/errors" "gopkg.in/resty.v1" "io/ioutil" diff --git a/ziti/cmd/ziti/util/pickers.go b/ziti/util/pickers.go similarity index 98% rename from ziti/cmd/ziti/util/pickers.go rename to ziti/util/pickers.go index 91cc17fb3..2099bfb05 100644 --- a/ziti/cmd/ziti/util/pickers.go +++ b/ziti/util/pickers.go @@ -18,10 +18,10 @@ package util import ( "fmt" + "github.com/openziti/ziti/ziti/internal/log" "sort" "strings" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "gopkg.in/AlecAivazis/survey.v1" ) diff --git a/ziti/cmd/ziti/util/rest.go b/ziti/util/rest.go similarity index 99% rename from ziti/cmd/ziti/util/rest.go rename to ziti/util/rest.go index 0665d40e2..350660fb4 100644 --- a/ziti/cmd/ziti/util/rest.go +++ b/ziti/util/rest.go @@ -31,8 +31,8 @@ import ( "github.com/openziti/edge/rest_model" fabric_rest_client "github.com/openziti/fabric/rest_client" "github.com/openziti/ziti/common/version" - cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - c "github.com/openziti/ziti/ziti/cmd/ziti/constants" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + c "github.com/openziti/ziti/ziti/constants" "github.com/pkg/errors" "gopkg.in/resty.v1" "io" diff --git a/ziti/cmd/ziti/util/session.go b/ziti/util/session.go similarity index 100% rename from ziti/cmd/ziti/util/session.go rename to ziti/util/session.go diff --git a/ziti/cmd/ziti/util/strings.go b/ziti/util/strings.go similarity index 100% rename from ziti/cmd/ziti/util/strings.go rename to ziti/util/strings.go diff --git a/ziti/cmd/ziti/util/suggestions.go b/ziti/util/suggestions.go similarity index 100% rename from ziti/cmd/ziti/util/suggestions.go rename to ziti/util/suggestions.go diff --git a/ziti/cmd/ziti/util/updates.go b/ziti/util/updates.go similarity index 98% rename from ziti/cmd/ziti/util/updates.go rename to ziti/util/updates.go index f8ab1fe80..7df9ca388 100644 --- a/ziti/cmd/ziti/util/updates.go +++ b/ziti/util/updates.go @@ -18,6 +18,7 @@ package util import ( "fmt" + "github.com/openziti/ziti/ziti/constants" "os" "github.com/fatih/color" @@ -25,7 +26,6 @@ import ( "github.com/blang/semver" "github.com/michaelquigley/pfxlog" "github.com/openziti/ziti/common/version" - "github.com/openziti/ziti/ziti/cmd/ziti/constants" ) func LogReleaseVersionCheck(ziti_component string) { From 3becfa8fd0ac72d47bca97c4b6ee1a2b5418b083 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 11:05:04 -0500 Subject: [PATCH 06/15] Allow controller and router to be run from ziti --- CHANGELOG.md | 3 + ziti/cmd/cmd.go | 8 ++- ziti/cmd/execute.go | 82 --------------------- ziti/cmd/execute_controller.go | 112 ----------------------------- ziti/controller/delete_sessions.go | 16 ++--- ziti/controller/root.go | 62 ++++++++-------- ziti/controller/run.go | 16 ++--- ziti/controller/version.go | 18 +++-- ziti/router/enrollgw.go | 17 ++--- ziti/router/root.go | 60 +++++++++------- ziti/router/run.go | 17 +++-- ziti/router/version.go | 18 +++-- 12 files changed, 123 insertions(+), 306 deletions(-) delete mode 100644 ziti/cmd/execute.go delete mode 100644 ziti/cmd/execute_controller.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 7112ac11f..9a41247ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ * The adhoc, ping and playbook commands have been removed. These were ansible and vagrant commands that were not widely used. * Make the art command hidden, doesn't need to be removed, leave it as an easter egg * Move ziti ps command under ziti agent. Remove all ziti ps subcommands, as they already exist as ziti agent subcommands +* Add `ziti controller` and `ziti router` commands + * They should work exactly the same as `ziti-controller` and `ziti router` + * The standalone binaries for `ziti-controller` and `ziti-router` are deprecated and will be removed in a future release # Release 0.26.11 diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 53edfd8c3..774f5d836 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -28,7 +28,9 @@ import ( "github.com/openziti/ziti/ziti/cmd/templates" "github.com/openziti/ziti/ziti/cmd/tutorial" c "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/controller" "github.com/openziti/ziti/ziti/internal/log" + "github.com/openziti/ziti/ziti/router" "github.com/openziti/ziti/ziti/util" "io" "os" @@ -121,7 +123,8 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com initCommands := NewCmdInit(out, err) createCommands := NewCmdCreate(out, err) - executeCommands := NewCmdExecute(out, err) + controllerCmd := controller.NewRunCmd() + routerCmd := router.NewRunCmd() agentCommands := agentcli.NewAgentCmd(p) pkiCommands := NewCmdPKI(out, err) fabricCommand := fabric.NewFabricCmd(p) @@ -153,8 +156,9 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com { Message: "Executing Ziti components:", Commands: []*cobra.Command{ - executeCommands, agentCommands, + controllerCmd, + routerCmd, pkiCommands, unwrapIdentityFileCommand, }, diff --git a/ziti/cmd/execute.go b/ziti/cmd/execute.go deleted file mode 100644 index c52b3f066..000000000 --- a/ziti/cmd/execute.go +++ /dev/null @@ -1,82 +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 cmd - -import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - "io" - - "github.com/spf13/cobra" -) - -// ExecuteOptions contains the command line options -type ExecuteOptions struct { - CommonOptions - - Flags ExecuteFlags - - DisableImport bool - OutDir string -} - -type ExecuteFlags struct { - Identity string -} - -var ( - executeLong = templates.LongDesc(` - Executes a component. - `) -) - -// NewCmdExecute Executes a command object for the "Execute" command -func NewCmdExecute(out io.Writer, errOut io.Writer) *cobra.Command { - options := &ExecuteOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "run", - Short: "Execute a Ziti component/app", - Long: executeLong, - Aliases: []string{}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - - cmd.AddCommand(NewCmdExecuteController(out, errOut)) - - options.addExecuteFlags(cmd) - return cmd -} - -func (options *ExecuteOptions) addExecuteFlags(cmd *cobra.Command) { - cmd.Flags().StringVarP(&options.Flags.Identity, "identity", "", "", "Which identity to use.") -} - -// Run implements this command -func (o *ExecuteOptions) Run() error { - return o.Cmd.Help() -} diff --git a/ziti/cmd/execute_controller.go b/ziti/cmd/execute_controller.go deleted file mode 100644 index 3373bbd9a..000000000 --- a/ziti/cmd/execute_controller.go +++ /dev/null @@ -1,112 +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 cmd - -import ( - 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/util" - "io" - "path/filepath" - - "github.com/spf13/cobra" - - "github.com/spf13/viper" -) - -var ( - executeControllerLong = templates.LongDesc(` - Executes the ziti-controller component - `) - - executeControllerExample = templates.Examples(` - # Execute the ziti-controller component - ziti execute ziti-controller - - `) -) - -// ExecuteControllerOptions the options for the create spring command -type ExecuteControllerOptions struct { - ExecuteOptions - - CtrlListener string -} - -// NewCmdExecuteController creates a command object for the "create" command -func NewCmdExecuteController(out io.Writer, errOut io.Writer) *cobra.Command { - options := &ExecuteControllerOptions{ - ExecuteOptions: ExecuteOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "controller", - Short: "'Execute the ziti-controller component'", - Aliases: []string{"c", "ctrl"}, - Long: executeControllerLong, - Example: executeControllerExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - - cmd.PersistentFlags().BoolVarP(&cliAgentEnabled, "cliagent", "a", false, "Enable CLI Agent (use in dev only)") - - options.AddCommonFlags(cmd) - - return cmd -} - -// Run implements the command -func (o *ExecuteControllerOptions) Run() error { - - viper := viper.New() - viper.SetConfigType("json") - viper.SetConfigName(c.CONFIGFILENAME) - zitiConfigDir, err := util.ZitiAppConfigDir(c.ZITI) - if err != nil { - return err - } - viper.AddConfigPath(zitiConfigDir) - err = viper.ReadInConfig() - if err != nil { - return err - } - - zitiControllerConfigDir, err := util.ZitiAppConfigDir(c.ZITI_CONTROLLER) - if err != nil { - return err - } - - zitiControllerConfigFileName := filepath.Join(zitiControllerConfigDir, c.CONFIGFILENAME) + ".yml" - - err = o.startCommandFromDir(viper.GetString("bin"), c.ZITI_CONTROLLER, "run", zitiControllerConfigFileName) - if err != nil { - return err - } - - return nil -} diff --git a/ziti/controller/delete_sessions.go b/ziti/controller/delete_sessions.go index d157f09e2..2b8b30d64 100644 --- a/ziti/controller/delete_sessions.go +++ b/ziti/controller/delete_sessions.go @@ -26,15 +26,13 @@ import ( "go.etcd.io/bbolt" ) -func init() { - root.AddCommand(deleteSessionsCmd) -} - -var deleteSessionsCmd = &cobra.Command{ - Use: "delete-sessions ", - Short: "Delete all API Sessions and Edge Sessions, controller must be shutdown", - Args: cobra.ExactArgs(1), - Run: deleteSessions, +func NewDeleteSessionsCmd() *cobra.Command { + return &cobra.Command{ + Use: "delete-sessions ", + Short: "Delete all API Sessions and Edge Sessions, controller must be shutdown", + Args: cobra.ExactArgs(1), + Run: deleteSessions, + } } const ( diff --git a/ziti/controller/root.go b/ziti/controller/root.go index 169dc140d..13396951b 100644 --- a/ziti/controller/root.go +++ b/ziti/controller/root.go @@ -27,37 +27,43 @@ import ( "github.com/spf13/cobra" ) -func init() { - root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging") - root.PersistentFlags().BoolVarP(&cliAgentEnabled, "cliagent", "a", true, "Enable/disabled CLI Agent (enabled by default)") - 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(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") - root.PersistentFlags().BoolVar(&syncRaftToDb, "sync-raft-to-db", false, "Sync the current database state to raft as a snapshot. Use when moving an existing controller to run in HA/Raft") +func NewControllerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "ziti-controller", + Short: "Ziti Fabric Controller", + PersistentPreRun: func(cmd *cobra.Command, args []string) { + if verbose { + logrus.SetLevel(logrus.DebugLevel) + } - edgeSubCmd.AddCommands(root, version.GetCmdBuildInfo()) -} + switch logFormatter { + case "pfxlog": + pfxlog.SetFormatter(pfxlog.NewFormatter(pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti/").StartingToday())) + case "json": + pfxlog.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "2006-01-02T15:04:05.000Z"}) + case "text": + pfxlog.SetFormatter(&logrus.TextFormatter{}) + default: + // let logrus do its own thing + } + util.LogReleaseVersionCheck(constants.ZITI_CONTROLLER) -var root = &cobra.Command{ - Use: "ziti-controller", - Short: "Ziti Fabric Controller", - PersistentPreRun: func(cmd *cobra.Command, args []string) { - if verbose { - logrus.SetLevel(logrus.DebugLevel) - } + }, + } - switch logFormatter { - case "pfxlog": - pfxlog.SetFormatter(pfxlog.NewFormatter(pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti/").StartingToday())) - case "json": - pfxlog.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "2006-01-02T15:04:05.000Z"}) - case "text": - pfxlog.SetFormatter(&logrus.TextFormatter{}) - default: - // let logrus do its own thing - } - util.LogReleaseVersionCheck(constants.ZITI_CONTROLLER) + cmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging") + cmd.PersistentFlags().BoolVarP(&cliAgentEnabled, "cliagent", "a", true, "Enable/disabled CLI Agent (enabled by default)") + cmd.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)") + cmd.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") + cmd.PersistentFlags().BoolVar(&syncRaftToDb, "sync-raft-to-db", false, "Sync the current database state to raft as a snapshot. Use when moving an existing controller to run in HA/Raft") - }, + cmd.AddCommand(NewRunCmd()) + cmd.AddCommand(NewDeleteSessionsCmd()) + cmd.AddCommand(NewVersionCmd()) + + edgeSubCmd.AddCommands(cmd, version.GetCmdBuildInfo()) + + return cmd } var verbose bool @@ -67,7 +73,7 @@ var logFormatter string var syncRaftToDb bool func Execute() { - if err := root.Execute(); err != nil { + if err := NewControllerCmd().Execute(); err != nil { fmt.Printf("error: %s\n", err) } } diff --git a/ziti/controller/run.go b/ziti/controller/run.go index d38812aed..a0292969e 100644 --- a/ziti/controller/run.go +++ b/ziti/controller/run.go @@ -32,15 +32,13 @@ import ( "github.com/spf13/cobra" ) -func init() { - root.AddCommand(runCmd) -} - -var runCmd = &cobra.Command{ - Use: "run ", - Short: "Run controller configuration", - Args: cobra.ExactArgs(1), - Run: run, +func NewRunCmd() *cobra.Command { + return &cobra.Command{ + Use: "run ", + Short: "Run controller configuration", + Args: cobra.ExactArgs(1), + Run: run, + } } func run(cmd *cobra.Command, args []string) { diff --git a/ziti/controller/version.go b/ziti/controller/version.go index e93fd9d7d..99128008e 100644 --- a/ziti/controller/version.go +++ b/ziti/controller/version.go @@ -22,14 +22,12 @@ import ( "github.com/spf13/cobra" ) -func init() { - root.AddCommand(versionCmd) -} - -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Show component version", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.GetBuildMetadata(verbose)) - }, +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/router/enrollgw.go b/ziti/router/enrollgw.go index c35114636..58b39b062 100644 --- a/ziti/router/enrollgw.go +++ b/ziti/router/enrollgw.go @@ -29,19 +29,20 @@ var jwtPath *string var engine *string var keyAlg config.KeyAlgVar -func init() { +func NewEnrollGwCmd() *cobra.Command { + var enrollEdgeRouterCmd = &cobra.Command{ + Use: "enroll ", + Short: "Enroll a router as an edge router", + Args: cobra.ExactArgs(1), + Run: enrollGw, + } + jwtPath = enrollEdgeRouterCmd.Flags().StringP("jwt", "j", "", "The path to a JWT file") engine = enrollEdgeRouterCmd.Flags().StringP("engine", "e", "", "An engine") keyAlg.Set("RSA") // set default enrollEdgeRouterCmd.Flags().VarP(&keyAlg, "keyAlg", "a", "Crypto algorithm to use when generating private key") - root.AddCommand(enrollEdgeRouterCmd) -} -var enrollEdgeRouterCmd = &cobra.Command{ - Use: "enroll ", - Short: "Enroll a router as an edge router", - Args: cobra.ExactArgs(1), - Run: enrollGw, + return enrollEdgeRouterCmd } func enrollGw(cmd *cobra.Command, args []string) { diff --git a/ziti/router/root.go b/ziti/router/root.go index 36541e87d..43cf57712 100644 --- a/ziti/router/root.go +++ b/ziti/router/root.go @@ -25,35 +25,41 @@ import ( "github.com/spf13/cobra" ) -func init() { - root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging") - root.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") - root.PersistentFlags().BoolVar(&cliAgentEnabled, "cli-agent", true, "Enable/disable CLI Agent (enabled by default)") - 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().BoolVar(&enableDebugOps, "debug-ops", false, "Enable/disable debug agent operations (disabled by default)") -} +func NewRouterCmd() *cobra.Command { + var routerCmd = &cobra.Command{ + Use: "ziti-router", + Short: "Ziti Fabric Router", + PersistentPreRun: func(cmd *cobra.Command, args []string) { + if verbose { + logrus.SetLevel(logrus.DebugLevel) + } -var root = &cobra.Command{ - Use: "ziti-router", - Short: "Ziti Fabric Router", - PersistentPreRun: func(cmd *cobra.Command, args []string) { - if verbose { - logrus.SetLevel(logrus.DebugLevel) - } + switch logFormatter { + case "pfxlog": + pfxlog.SetFormatter(pfxlog.NewFormatter(pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti/").StartingToday())) + case "json": + pfxlog.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "2006-01-02T15:04:05.000Z"}) + case "text": + pfxlog.SetFormatter(&logrus.TextFormatter{}) + default: + // let logrus do its own thing + } + util.LogReleaseVersionCheck(constants.ZITI_ROUTER) - switch logFormatter { - case "pfxlog": - pfxlog.SetFormatter(pfxlog.NewFormatter(pfxlog.DefaultOptions().SetTrimPrefix("github.com/openziti/").StartingToday())) - case "json": - pfxlog.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "2006-01-02T15:04:05.000Z"}) - case "text": - pfxlog.SetFormatter(&logrus.TextFormatter{}) - default: - // let logrus do its own thing - } - util.LogReleaseVersionCheck(constants.ZITI_ROUTER) + }, + } - }, + routerCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging") + routerCmd.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") + routerCmd.PersistentFlags().BoolVar(&cliAgentEnabled, "cli-agent", true, "Enable/disable CLI Agent (enabled by default)") + routerCmd.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)") + routerCmd.PersistentFlags().BoolVar(&enableDebugOps, "debug-ops", false, "Enable/disable debug agent operations (disabled by default)") + + routerCmd.AddCommand(NewRunCmd()) + routerCmd.AddCommand(NewEnrollGwCmd()) + routerCmd.AddCommand(NewVersionCmd()) + + return routerCmd } var verbose bool @@ -63,7 +69,7 @@ var enableDebugOps bool var cliAgentAddr string func Execute() { - if err := root.Execute(); err != nil { + if err := NewRouterCmd().Execute(); err != nil { fmt.Printf("error: %s\n", err) } } diff --git a/ziti/router/run.go b/ziti/router/run.go index d82fbfebb..9bab59655 100644 --- a/ziti/router/run.go +++ b/ziti/router/run.go @@ -39,19 +39,18 @@ import ( "syscall" ) -var forceEnrollmentExtension *bool +func NewRunCmd() *cobra.Command { + var runCmd = &cobra.Command{ + Use: "run ", + Short: "Run router configuration", + Args: cobra.ExactArgs(1), + Run: run, + } -func init() { //flags are added to an internal map and read later on, see getFlags() runCmd.Flags().BoolP("extend", "e", false, "force the router on startup to extend enrollment certificates") - root.AddCommand(runCmd) -} -var runCmd = &cobra.Command{ - Use: "run ", - Short: "Run router configuration", - Args: cobra.ExactArgs(1), - Run: run, + return runCmd } func run(cmd *cobra.Command, args []string) { diff --git a/ziti/router/version.go b/ziti/router/version.go index 54180f00c..8dad7e7e1 100644 --- a/ziti/router/version.go +++ b/ziti/router/version.go @@ -22,14 +22,12 @@ import ( "github.com/spf13/cobra" ) -func init() { - root.AddCommand(versionCmd) -} - -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Show component version", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.GetBuildMetadata(verbose)) - }, +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)) + }, + } } From ea3940bbfe23f2ef72e7c3c744bce789a09b59d6 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 11:26:51 -0500 Subject: [PATCH 07/15] Add `ziti tunnel` command --- CHANGELOG.md | 4 +++ ziti-tunnel/cmd/ziti-tunnel/main.go | 4 +-- ziti/cmd/cmd.go | 3 +++ .../subcmd => ziti/tunnel}/host.go | 25 +++++++++-------- .../subcmd => ziti/tunnel}/proxy.go | 25 +++++++++-------- .../subcmd => ziti/tunnel}/root.go | 27 ++++++++++++------- .../ziti-tunnel/subcmd => ziti/tunnel}/run.go | 23 ++++++++-------- .../subcmd => ziti/tunnel}/tproxy.go | 22 +++++++-------- .../subcmd => ziti/tunnel}/version.go | 22 +++++++-------- 9 files changed, 82 insertions(+), 73 deletions(-) rename {ziti-tunnel/cmd/ziti-tunnel/subcmd => ziti/tunnel}/host.go (70%) rename {ziti-tunnel/cmd/ziti-tunnel/subcmd => ziti/tunnel}/proxy.go (73%) rename {ziti-tunnel/cmd/ziti-tunnel/subcmd => ziti/tunnel}/root.go (92%) rename {ziti-tunnel/cmd/ziti-tunnel/subcmd => ziti/tunnel}/run.go (78%) rename {ziti-tunnel/cmd/ziti-tunnel/subcmd => ziti/tunnel}/tproxy.go (76%) rename {ziti-tunnel/cmd/ziti-tunnel/subcmd => ziti/tunnel}/version.go (73%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a41247ba..315c83f40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ * Add `ziti controller` and `ziti router` commands * They should work exactly the same as `ziti-controller` and `ziti router` * The standalone binaries for `ziti-controller` and `ziti-router` are deprecated and will be removed in a future release +* Add hidden `ziti tunnel` command + * Should work exactly the same as `ziti-tunnel` + * Is hidden as `ziti-edge-tunnel` is the preferred tunnelling application + * The standalone binary `ziti-tunnel` is deprecated and will be removed in a future release # Release 0.26.11 diff --git a/ziti-tunnel/cmd/ziti-tunnel/main.go b/ziti-tunnel/cmd/ziti-tunnel/main.go index f70c3f392..9b8d8c7de 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/main.go +++ b/ziti-tunnel/cmd/ziti-tunnel/main.go @@ -19,7 +19,7 @@ package main import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/foundation/v2/debugz" - "github.com/openziti/ziti/ziti-tunnel/cmd/ziti-tunnel/subcmd" + "github.com/openziti/ziti/ziti/tunnel" "github.com/sirupsen/logrus" ) @@ -29,5 +29,5 @@ func init() { func main() { debugz.AddStackDumpHandler() - subcmd.Execute() + tunnel.Execute() } diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 774f5d836..e4166eace 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -31,6 +31,7 @@ import ( "github.com/openziti/ziti/ziti/controller" "github.com/openziti/ziti/ziti/internal/log" "github.com/openziti/ziti/ziti/router" + "github.com/openziti/ziti/ziti/tunnel" "github.com/openziti/ziti/ziti/util" "io" "os" @@ -124,6 +125,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com initCommands := NewCmdInit(out, err) createCommands := NewCmdCreate(out, err) controllerCmd := controller.NewRunCmd() + tunnelCmd := tunnel.NewTunnelCmd() routerCmd := router.NewRunCmd() agentCommands := agentcli.NewAgentCmd(p) pkiCommands := NewCmdPKI(out, err) @@ -159,6 +161,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com agentCommands, controllerCmd, routerCmd, + tunnelCmd, pkiCommands, unwrapIdentityFileCommand, }, diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/host.go b/ziti/tunnel/host.go similarity index 70% rename from ziti-tunnel/cmd/ziti-tunnel/subcmd/host.go rename to ziti/tunnel/host.go index dea77cf03..9adf17130 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/host.go +++ b/ziti/tunnel/host.go @@ -14,27 +14,26 @@ limitations under the License. */ -package subcmd +package tunnel import ( "github.com/openziti/edge/tunnel/intercept/host" "github.com/spf13/cobra" ) -var runHostCmd = &cobra.Command{ - Use: "host", - Short: "Run in 'host' mode", - Long: "The 'host' mode will only host services", - Args: cobra.ExactArgs(0), - RunE: runHost, - PostRun: rootPostRun, +func NewHostCmd() *cobra.Command { + return &cobra.Command{ + Use: "host", + Short: "Run in 'host' mode", + Long: "The 'host' mode will only host services", + Args: cobra.ExactArgs(0), + RunE: runHost, + PostRun: rootPostRun, + } } -func init() { - root.AddCommand(runHostCmd) -} - -func runHost(_ *cobra.Command, args []string) error { +func runHost(cmd *cobra.Command, args []string) error { + root := cmd.Root() if !root.Flag(resolverCfgFlag).Changed { _ = root.PersistentFlags().Set(resolverCfgFlag, "") } diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/proxy.go b/ziti/tunnel/proxy.go similarity index 73% rename from ziti-tunnel/cmd/ziti-tunnel/subcmd/proxy.go rename to ziti/tunnel/proxy.go index f2f465c7d..33eb8a6ea 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/proxy.go +++ b/ziti/tunnel/proxy.go @@ -14,7 +14,7 @@ limitations under the License. */ -package subcmd +package tunnel import ( "github.com/openziti/edge/tunnel/intercept/proxy" @@ -25,20 +25,19 @@ import ( "strconv" ) -var runProxyCmd = &cobra.Command{ - Use: "proxy [sevice-name:port]", - Short: "Run in 'proxy' mode", - Long: "The 'proxy' intercept mode creates a network listener for each service that is intercepted.", - Args: cobra.MinimumNArgs(1), - RunE: runProxy, - PostRun: rootPostRun, +func NewProxyCmd() *cobra.Command { + return &cobra.Command{ + Use: "proxy [sevice-name:port]", + Short: "Run in 'proxy' mode", + Long: "The 'proxy' intercept mode creates a network listener for each service that is intercepted.", + Args: cobra.MinimumNArgs(1), + RunE: runProxy, + PostRun: rootPostRun, + } } -func init() { - root.AddCommand(runProxyCmd) -} - -func runProxy(_ *cobra.Command, args []string) error { +func runProxy(cmd *cobra.Command, args []string) error { + root := cmd.Root() // Fiddle with the poll rate and resolver settings if the user didn't wan't anything special. if !root.Flag(svcPollRateFlag).Changed { _ = root.PersistentFlags().Set(svcPollRateFlag, strconv.FormatUint(math.MaxUint32, 10)) diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go b/ziti/tunnel/root.go similarity index 92% rename from ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go rename to ziti/tunnel/root.go index f3c737526..0bef0a567 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go +++ b/ziti/tunnel/root.go @@ -14,13 +14,12 @@ limitations under the License. */ -package subcmd +package tunnel import ( "github.com/openziti/ziti/ziti/cmd/common" "github.com/openziti/ziti/ziti/constants" "github.com/openziti/ziti/ziti/util" - "io/ioutil" "os" "path/filepath" "time" @@ -45,7 +44,14 @@ const ( dnsSvcIpRangeFlag = "dnsSvcIpRange" ) -func init() { +func NewTunnelCmd() *cobra.Command { + var root = &cobra.Command{ + Use: filepath.Base(os.Args[0]), + Short: "Ziti Tunnel", + PersistentPreRun: rootPreRun, + Hidden: true, + } + root.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose mode") root.PersistentFlags().StringP("identity", "i", "", "Path to JSON file that contains an enrolled identity") root.PersistentFlags().String("identity-dir", "", "Path to directory file that contains one or more enrolled identities") @@ -58,12 +64,13 @@ func init() { p := common.NewOptionsProvider(os.Stdout, os.Stderr) root.AddCommand(enrollment.NewEnrollCommand(p)) -} + root.AddCommand(NewHostCmd()) + root.AddCommand(NewProxyCmd()) + root.AddCommand(NewRunCmd()) + root.AddCommand(NewTProxyCmd()) + root.AddCommand(NewVersionCmd()) -var root = &cobra.Command{ - Use: filepath.Base(os.Args[0]), - Short: "Ziti Tunnel", - PersistentPreRun: rootPreRun, + return root } var interceptor intercept.Interceptor @@ -72,7 +79,7 @@ var cliAgentEnabled bool var cliAgentAddr string func Execute() { - if err := root.Execute(); err != nil { + if err := NewTunnelCmd().Execute(); err != nil { pfxlog.Logger().Errorf("error: %s", err) os.Exit(1) } @@ -125,7 +132,7 @@ func rootPostRun(cmd *cobra.Command, _ []string) { } if idDir := cmd.Flag("identity-dir").Value.String(); idDir != "" { - files, err := ioutil.ReadDir(idDir) + files, err := os.ReadDir(idDir) if err != nil { log.Fatalf("failed to scan directory %s: %v", idDir, err) } diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go b/ziti/tunnel/run.go similarity index 78% rename from ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go rename to ziti/tunnel/run.go index cc833ec10..d776936b1 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go +++ b/ziti/tunnel/run.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux /* @@ -16,7 +17,7 @@ limitations under the License. */ -package subcmd +package tunnel import ( "github.com/michaelquigley/pfxlog" @@ -25,17 +26,15 @@ import ( "github.com/spf13/cobra" ) -var runCmd = &cobra.Command{ - Use: "run ", - Short: "Auto-select interceptor", - Long: "Provided for backwards compatibility with scripts that were coded around older ziti-tunnel versions.", - Args: cobra.MaximumNArgs(1), - Run: run, - PostRun: rootPostRun, -} - -func init() { - root.AddCommand(runCmd) +func NewRunCmd() *cobra.Command { + return &cobra.Command{ + Use: "run ", + Short: "Auto-select interceptor", + Long: "Provided for backwards compatibility with scripts that were coded around older ziti-tunnel versions.", + Args: cobra.MaximumNArgs(1), + Run: run, + PostRun: rootPostRun, + } } func run(cmd *cobra.Command, args []string) { diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go b/ziti/tunnel/tproxy.go similarity index 76% rename from ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go rename to ziti/tunnel/tproxy.go index 36e4a5f58..2b58102d7 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go +++ b/ziti/tunnel/tproxy.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux /* @@ -16,7 +17,7 @@ limitations under the License. */ -package subcmd +package tunnel import ( "fmt" @@ -24,17 +25,16 @@ import ( "github.com/spf13/cobra" ) -var runTProxyCmd = &cobra.Command{ - Use: "tproxy", - Short: "Use the 'tproxy' interceptor", - Long: "The 'tproxy' interceptor captures packets by using the TPROXY iptables target.", - RunE: runTProxy, - PostRun: rootPostRun, -} - -func init() { +func NewTProxyCmd() *cobra.Command { + var runTProxyCmd = &cobra.Command{ + Use: "tproxy", + Short: "Use the 'tproxy' interceptor", + Long: "The 'tproxy' interceptor captures packets by using the TPROXY iptables target.", + RunE: runTProxy, + PostRun: rootPostRun, + } runTProxyCmd.PersistentFlags().String("lanIf", "", "if specified, INPUT rules for intercepted service addresses are assigned to this interface ") - root.AddCommand(runTProxyCmd) + return runTProxyCmd } func runTProxy(cmd *cobra.Command, args []string) error { diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/version.go b/ziti/tunnel/version.go similarity index 73% rename from ziti-tunnel/cmd/ziti-tunnel/subcmd/version.go rename to ziti/tunnel/version.go index b490914ee..947ac932a 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/version.go +++ b/ziti/tunnel/version.go @@ -14,22 +14,20 @@ limitations under the License. */ -package subcmd +package tunnel import ( - "github.com/openziti/ziti/common/version" "fmt" + "github.com/openziti/ziti/common/version" "github.com/spf13/cobra" ) -func init() { - root.AddCommand(versionCmd) -} - -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Show component version", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.GetVersion()) - }, +func NewVersionCmd() *cobra.Command { + return &cobra.Command{ + Use: "version", + Short: "Show component version", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(version.GetVersion()) + }, + } } From ccad024523843a7f3856e93c3e9e6876df16fc35 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 11:32:45 -0500 Subject: [PATCH 08/15] Remove most of install/upgrade/uninstall commands as well as use and version --- ziti/cmd/cmd.go | 4 - ziti/cmd/create.go | 1 - ziti/cmd/create_environment.go | 83 -------- ziti/cmd/install.go | 10 - ziti/cmd/install_ziti_ALL.go | 122 ------------ ziti/cmd/install_ziti_controller.go | 92 --------- ziti/cmd/install_ziti_edge_tunnel.go | 97 ---------- ziti/cmd/install_ziti_prox_c.go | 97 ---------- ziti/cmd/install_ziti_router.go | 92 --------- ziti/cmd/install_ziti_tunnel.go | 92 --------- ziti/cmd/uninstall.go | 79 -------- ziti/cmd/uninstall_ziti_controller.go | 77 -------- ziti/cmd/uninstall_ziti_edge_tunnel.go | 77 -------- ziti/cmd/uninstall_ziti_proxy_c.go | 77 -------- ziti/cmd/uninstall_ziti_router.go | 77 -------- ziti/cmd/uninstall_ziti_tunnel.go | 77 -------- ziti/cmd/upgrade.go | 80 -------- ziti/cmd/upgrade_ziti.go | 90 --------- ziti/cmd/upgrade_ziti_controller.go | 90 --------- ziti/cmd/upgrade_ziti_edge_tunnel.go | 89 --------- ziti/cmd/upgrade_ziti_prox_c.go | 89 --------- ziti/cmd/upgrade_ziti_router.go | 90 --------- ziti/cmd/upgrade_ziti_tunnel.go | 90 --------- ziti/cmd/use.go | 153 --------------- ziti/cmd/version.go | 250 ------------------------- 25 files changed, 2175 deletions(-) delete mode 100644 ziti/cmd/create_environment.go delete mode 100644 ziti/cmd/install_ziti_ALL.go delete mode 100644 ziti/cmd/install_ziti_controller.go delete mode 100644 ziti/cmd/install_ziti_edge_tunnel.go delete mode 100644 ziti/cmd/install_ziti_prox_c.go delete mode 100644 ziti/cmd/install_ziti_router.go delete mode 100644 ziti/cmd/install_ziti_tunnel.go delete mode 100644 ziti/cmd/uninstall.go delete mode 100644 ziti/cmd/uninstall_ziti_controller.go delete mode 100644 ziti/cmd/uninstall_ziti_edge_tunnel.go delete mode 100644 ziti/cmd/uninstall_ziti_proxy_c.go delete mode 100644 ziti/cmd/uninstall_ziti_router.go delete mode 100644 ziti/cmd/uninstall_ziti_tunnel.go delete mode 100644 ziti/cmd/upgrade.go delete mode 100644 ziti/cmd/upgrade_ziti.go delete mode 100644 ziti/cmd/upgrade_ziti_controller.go delete mode 100644 ziti/cmd/upgrade_ziti_edge_tunnel.go delete mode 100644 ziti/cmd/upgrade_ziti_prox_c.go delete mode 100644 ziti/cmd/upgrade_ziti_router.go delete mode 100644 ziti/cmd/upgrade_ziti_tunnel.go delete mode 100644 ziti/cmd/use.go delete mode 100644 ziti/cmd/version.go diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index e4166eace..99a457269 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -139,8 +139,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com installCommands := []*cobra.Command{ NewCmdInstall(out, err), - NewCmdUnInstall(out, err), - NewCmdUpgrade(out, err), } groups := templates.CommandGroups{ @@ -191,11 +189,9 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com groups.Add(cmd) - cmd.AddCommand(NewCmdVersion(out, err)) cmd.Version = version.GetVersion() cmd.SetVersionTemplate("{{printf .Version}}\n") cmd.AddCommand(NewCmdArt(out, err)) - cmd.AddCommand(NewCmdUse(out, err)) return cmd } diff --git a/ziti/cmd/create.go b/ziti/cmd/create.go index 03e786054..3fde148bd 100644 --- a/ziti/cmd/create.go +++ b/ziti/cmd/create.go @@ -42,7 +42,6 @@ func NewCmdCreate(out io.Writer, errOut io.Writer) *cobra.Command { } cmd.AddCommand(NewCmdCreateConfig()) - cmd.AddCommand(NewCmdCreateEnvironment(out, errOut)) cmd.AddCommand(NewCmdPKICreateCA(out, errOut)) cmd.AddCommand(NewCmdPKICreateIntermediate(out, errOut)) diff --git a/ziti/cmd/create_environment.go b/ziti/cmd/create_environment.go deleted file mode 100644 index 37e35a481..000000000 --- a/ziti/cmd/create_environment.go +++ /dev/null @@ -1,83 +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 cmd - -import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/openziti/ziti/ziti/util" - "io" - - "github.com/spf13/cobra" -) - -// CreateEnvironmentOptions the options for the create spring command -type CreateEnvironmentOptions struct { - CommonOptions - - EnvName string -} - -// NewCmdCreateEnvironment creates a command object for the "create" command -func NewCmdCreateEnvironment(out io.Writer, errOut io.Writer) *cobra.Command { - options := &CreateEnvironmentOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "environment", - Short: "Creates a 'deployment environment' directory, and seed files", - Aliases: []string{"env"}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - - options.addFlags(cmd, "", "") - return cmd -} - -// Add flags that are global to all "create config" commands -func (o *CreateEnvironmentOptions) addFlags(cmd *cobra.Command, defaultNamespace string, defaultOptionRelease string) { - cmd.Flags().StringVarP(&o.EnvName, "name", "", "", "Name of new 'environment'") - cmd.MarkFlagRequired("name") -} - -// Run implements this command -func (o *CreateEnvironmentOptions) Run() error { - deps := make([]string, 0) - deps = append(deps, "ansible") - err := o.installMissingDependencies(deps) - if err != nil { - return err - } - - envDir, err := util.NewEnvironmentDir(o.EnvName) - if err != nil { - return err - } - - log.Infoln(envDir + " successfully created") - - return nil -} diff --git a/ziti/cmd/install.go b/ziti/cmd/install.go index 753ae3e85..a098b1109 100644 --- a/ziti/cmd/install.go +++ b/ziti/cmd/install.go @@ -64,16 +64,6 @@ func NewCmdInstall(out io.Writer, errOut io.Writer) *cobra.Command { SuggestFor: []string{"up"}, } - 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(NewCmdInstallAnsible(out, errOut)) // Disable/hide this for now - cmd.AddCommand(NewCmdInstallTerraformProviderEdgeController(out, errOut)) options.AddCommonFlags(cmd) diff --git a/ziti/cmd/install_ziti_ALL.go b/ziti/cmd/install_ziti_ALL.go deleted file mode 100644 index 01fb32d7c..000000000 --- a/ziti/cmd/install_ziti_ALL.go +++ /dev/null @@ -1,122 +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 cmd - -import ( - 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 ( - 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: 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) - } - - 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_ziti_controller.go b/ziti/cmd/install_ziti_controller.go deleted file mode 100644 index aa4f67bb6..000000000 --- a/ziti/cmd/install_ziti_controller.go +++ /dev/null @@ -1,92 +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 cmd - -import ( - 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 ( - 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: 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) - } - - 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_ziti_edge_tunnel.go b/ziti/cmd/install_ziti_edge_tunnel.go deleted file mode 100644 index 144ea72da..000000000 --- a/ziti/cmd/install_ziti_edge_tunnel.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 cmd - -import ( - 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 ( - 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: 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 { - newVersion, err := o.getLatestGitHubReleaseVersion(c.ZITI_EDGE_TUNNEL_GITHUB) - if err != nil { - return err - } - - if targetVersion != "" { - newVersion, err = semver.Make(targetVersion) - } - - log.Infoln("Attempting to install '" + c.ZITI_EDGE_TUNNEL + "' version: " + newVersion.String()) - - return o.findVersionAndInstallGitHubRelease(c.ZITI_EDGE_TUNNEL, c.ZITI_EDGE_TUNNEL_GITHUB, false, newVersion.String()) - -} - -// Run implements the command -func (o *InstallZitiEdgeTunnelOptions) Run() error { - return o.installZitiEdgeTunnel(o.Version) -} diff --git a/ziti/cmd/install_ziti_prox_c.go b/ziti/cmd/install_ziti_prox_c.go deleted file mode 100644 index 0c87056aa..000000000 --- a/ziti/cmd/install_ziti_prox_c.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 cmd - -import ( - 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 ( - 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: 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 { - if targetVersion != "" { - version, err := semver.Make(targetVersion) - if err != nil { - return err - } - return o.findVersionAndInstallGitHubRelease(c.ZITI_PROX_C, c.ZITI_SDK_C_GITHUB, false, version.String()) - } - - release, err := o.getHighestVersionGitHubReleaseInfo(c.ZITI_SDK_C_GITHUB) - if err != nil { - return err - } - log.Infoln("Attempting to install '" + c.ZITI_PROX_C + "' version: " + release.SemVer.String()) - return o.installGitHubRelease(c.ZITI_PROX_C, false, release) -} - -// Run implements the command -func (o *InstallZitiProxCOptions) Run() error { - return o.installZitiProxC(o.Version) -} diff --git a/ziti/cmd/install_ziti_router.go b/ziti/cmd/install_ziti_router.go deleted file mode 100644 index 1296e7b30..000000000 --- a/ziti/cmd/install_ziti_router.go +++ /dev/null @@ -1,92 +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 cmd - -import ( - 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: 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) - } - - 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_ziti_tunnel.go b/ziti/cmd/install_ziti_tunnel.go deleted file mode 100644 index 4d5e4c1cc..000000000 --- a/ziti/cmd/install_ziti_tunnel.go +++ /dev/null @@ -1,92 +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 cmd - -import ( - 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: 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) - } - - 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/uninstall.go b/ziti/cmd/uninstall.go deleted file mode 100644 index b3ce667ff..000000000 --- a/ziti/cmd/uninstall.go +++ /dev/null @@ -1,79 +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 cmd - -import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - "io" - - "github.com/spf13/cobra" -) - -// UnInstallOptions are the flags for delete commands -type UnInstallOptions struct { - CommonOptions -} - -var ( - uninstall_long = templates.LongDesc(` - UnInstall the Ziti platform binaries. -`) - - uninstall_example = templates.Examples(` - # uninstall the Ziti router - ziti uninstall ziti-router - `) -) - -// NewCmdUnInstall creates the command -func NewCmdUnInstall(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UnInstallOptions{ - CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "uninstall [flags]", - Short: "Un-Installs a Ziti component/app", - Long: uninstall_long, - Example: uninstall_example, - Aliases: []string{"uninstall"}, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - SuggestFor: []string{"up"}, - } - - cmd.AddCommand(NewCmdUnInstallZitiController(out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiRouter(out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiTunnel(out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiEdgeTunnel(out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiProxC(out, errOut)) - - return cmd -} - -// Run implements this command -func (o *UnInstallOptions) Run() error { - return o.Cmd.Help() -} diff --git a/ziti/cmd/uninstall_ziti_controller.go b/ziti/cmd/uninstall_ziti_controller.go deleted file mode 100644 index 3ddd344f3..000000000 --- a/ziti/cmd/uninstall_ziti_controller.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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - uninstallZitiControllerLong = templates.LongDesc(` - UnInstalls the Ziti Controller app if it has previously been installed -`) - - uninstallZitiControllerExample = templates.Examples(` - # UnInstall the Ziti Controller app - ziti uninstall ziti-controller - `) -) - -// UnInstallZitiControllerOptions the options for the upgrade ziti-controller command -type UnInstallZitiControllerOptions struct { - UnInstallOptions - - Version string -} - -// NewCmdUnInstallZitiController defines the command -func NewCmdUnInstallZitiController(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UnInstallZitiControllerOptions{ - UnInstallOptions: UnInstallOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-controller", - Short: "UnInstalls the Ziti Controller app - if it has previously been installed", - Aliases: []string{"controller"}, - Long: uninstallZitiControllerLong, - Example: uninstallZitiControllerExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - return cmd -} - -// Run implements the command -func (o *UnInstallZitiControllerOptions) Run() error { - o.deleteInstalledBinary(c.ZITI_CONTROLLER) - return nil -} diff --git a/ziti/cmd/uninstall_ziti_edge_tunnel.go b/ziti/cmd/uninstall_ziti_edge_tunnel.go deleted file mode 100644 index 3df0be1c4..000000000 --- a/ziti/cmd/uninstall_ziti_edge_tunnel.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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - uninstallZitiEdgeTunnelLong = templates.LongDesc(` - UnInstalls the Ziti Edge Tunnel app if it has previously been installed -`) - - uninstallZitiEdgeTunnelExample = templates.Examples(` - # UnInstall the Ziti Edge Tunnel app - ziti uninstall ziti-edge-tunnel - `) -) - -// UnInstallZitiEdgeTunnelOptions the options for the upgrade ziti-edge-tunnel command -type UnInstallZitiEdgeTunnelOptions struct { - UnInstallOptions - - Version string -} - -// NewCmdUnInstallZitiEdgeTunnel defines the command -func NewCmdUnInstallZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UnInstallZitiEdgeTunnelOptions{ - UnInstallOptions: UnInstallOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-edge-tunnel", - Short: "UnInstalls the Ziti Edge Tunnel app - if it has previously been installed", - Aliases: []string{"edge-tunnel"}, - Long: uninstallZitiEdgeTunnelLong, - Example: uninstallZitiEdgeTunnelExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - return cmd -} - -// Run implements the command -func (o *UnInstallZitiEdgeTunnelOptions) Run() error { - o.deleteInstalledBinary(c.ZITI_EDGE_TUNNEL) - return nil -} diff --git a/ziti/cmd/uninstall_ziti_proxy_c.go b/ziti/cmd/uninstall_ziti_proxy_c.go deleted file mode 100644 index e77ae62e4..000000000 --- a/ziti/cmd/uninstall_ziti_proxy_c.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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - uninstallZitiProxCLong = templates.LongDesc(` - UnInstalls the Ziti ProxC app if it has previously been installed -`) - - uninstallZitiProxCExample = templates.Examples(` - # UnInstall the Ziti ProxC app - ziti uninstall ziti-prox-c - `) -) - -// UnInstallZitiProxCOptions the options for the upgrade ziti-prox-c command -type UnInstallZitiProxCOptions struct { - UnInstallOptions - - Version string -} - -// NewCmdUnInstallZitiProxC defines the command -func NewCmdUnInstallZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UnInstallZitiProxCOptions{ - UnInstallOptions: UnInstallOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-prox-c", - Short: "UnInstalls the Ziti ProxC app - if it has previously been installed", - Aliases: []string{"proxc"}, - Long: uninstallZitiProxCLong, - Example: uninstallZitiProxCExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - return cmd -} - -// Run implements the command -func (o *UnInstallZitiProxCOptions) Run() error { - o.deleteInstalledBinary(c.ZITI_PROX_C) - return nil -} diff --git a/ziti/cmd/uninstall_ziti_router.go b/ziti/cmd/uninstall_ziti_router.go deleted file mode 100644 index 1e3e24ce2..000000000 --- a/ziti/cmd/uninstall_ziti_router.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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - uninstallZitiRouterLong = templates.LongDesc(` - UnInstalls the Ziti Router app if it has previously been installed -`) - - uninstallZitiRouterExample = templates.Examples(` - # UnInstall the Ziti Router app - ziti uninstall ziti-router - `) -) - -// UnInstallZitiRouterOptions the options for the upgrade ziti-router command -type UnInstallZitiRouterOptions struct { - UnInstallOptions - - Version string -} - -// NewCmdUnInstallZitiRouter defines the command -func NewCmdUnInstallZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UnInstallZitiRouterOptions{ - UnInstallOptions: UnInstallOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-router", - Short: "UnInstalls the Ziti Router app - if it has previously been installed", - Aliases: []string{"router"}, - Long: uninstallZitiRouterLong, - Example: uninstallZitiRouterExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - return cmd -} - -// Run implements the command -func (o *UnInstallZitiRouterOptions) Run() error { - o.deleteInstalledBinary(c.ZITI_ROUTER) - return nil -} diff --git a/ziti/cmd/uninstall_ziti_tunnel.go b/ziti/cmd/uninstall_ziti_tunnel.go deleted file mode 100644 index 3ed6af63d..000000000 --- a/ziti/cmd/uninstall_ziti_tunnel.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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - uninstallZitiTunnelLong = templates.LongDesc(` - UnInstalls the Ziti Tunnel app if it has previously been installed -`) - - uninstallZitiTunnelExample = templates.Examples(` - # UnInstall the Ziti Tunnel app - ziti uninstall ziti-tunnel - `) -) - -// UnInstallZitiTunnelOptions the options for the upgrade ziti-tunnel command -type UnInstallZitiTunnelOptions struct { - UnInstallOptions - - Version string -} - -// NewCmdUnInstallZitiTunnel defines the command -func NewCmdUnInstallZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UnInstallZitiTunnelOptions{ - UnInstallOptions: UnInstallOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-tunnel", - Short: "UnInstalls the Ziti Tunnel app - if it has previously been installed", - Aliases: []string{"tunnel"}, - Long: uninstallZitiTunnelLong, - Example: uninstallZitiTunnelExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - return cmd -} - -// Run implements the command -func (o *UnInstallZitiTunnelOptions) Run() error { - o.deleteInstalledBinary(c.ZITI_TUNNEL) - return nil -} diff --git a/ziti/cmd/upgrade.go b/ziti/cmd/upgrade.go deleted file mode 100644 index d118a825a..000000000 --- a/ziti/cmd/upgrade.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 cmd - -import ( - 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 { - 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{ - 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"}, - } - - cmd.AddCommand(NewCmdUpgradeZiti(out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiController(out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiRouter(out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiTunnel(out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiProxC(out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiEdgeTunnel(out, errOut)) - - return cmd -} - -// Run implements this command -func (o *UpgradeOptions) Run() error { - return o.Cmd.Help() -} diff --git a/ziti/cmd/upgrade_ziti.go b/ziti/cmd/upgrade_ziti.go deleted file mode 100644 index b841946b0..000000000 --- a/ziti/cmd/upgrade_ziti.go +++ /dev/null @@ -1,90 +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 cmd - -import ( - 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 { - CommonOptions - - Version string -} - -// NewCmdUpgradeZiti defines the command -func NewCmdUpgradeZiti(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiOptions{ - CommonOptions: 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/upgrade_ziti_controller.go b/ziti/cmd/upgrade_ziti_controller.go deleted file mode 100644 index e4acce6c0..000000000 --- a/ziti/cmd/upgrade_ziti_controller.go +++ /dev/null @@ -1,90 +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 cmd - -import ( - 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 ( - upgradeZitiControllerLong = templates.LongDesc(` - Upgrades the Ziti Controller app if there is a newer release -`) - - upgradeZitiControllerExample = templates.Examples(` - # Upgrades the Ziti Controller app - ziti upgrade ziti-controller - `) -) - -// UpgradeZitiControllerOptions the options for the upgrade ziti-controller command -type UpgradeZitiControllerOptions struct { - CommonOptions - - Version string -} - -// NewCmdUpgradeZitiController defines the command -func NewCmdUpgradeZitiController(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiControllerOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-controller", - Short: "Upgrades the Ziti Controller app - if there is a new version available", - Aliases: []string{"controller", "ctrl", "zc"}, - Long: upgradeZitiControllerLong, - Example: upgradeZitiControllerExample, - 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 *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/upgrade_ziti_edge_tunnel.go b/ziti/cmd/upgrade_ziti_edge_tunnel.go deleted file mode 100644 index 4de2689e7..000000000 --- a/ziti/cmd/upgrade_ziti_edge_tunnel.go +++ /dev/null @@ -1,89 +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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - upgradeZitiEdgeTunnelLong = templates.LongDesc(` - Upgrades the Ziti Edge Tunnel app if there is a newer release -`) - - upgradeZitiEdgeTunnelExample = templates.Examples(` - # Upgrades the Ziti Edge Tunnel app - ziti upgrade ziti-edge-tunnel - `) -) - -// UpgradeZitiEdgeTunnelOptions the options for the upgrade ziti-edge-tunnel command -type UpgradeZitiEdgeTunnelOptions struct { - CommonOptions - - Version string -} - -// NewCmdUpgradeZitiEdgeTunnel defines the command -func NewCmdUpgradeZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiEdgeTunnelOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-edge-tunnel", - Short: "Upgrades the Ziti Edge Tunnel app - if there is a new version available", - Aliases: []string{"edge-tunnel", "et"}, - Long: upgradeZitiEdgeTunnelLong, - Example: upgradeZitiEdgeTunnelExample, - 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 *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(c.ZITI_EDGE_TUNNEL, c.ZITI_EDGE_TUNNEL_GITHUB, true, newVersionStr) -} diff --git a/ziti/cmd/upgrade_ziti_prox_c.go b/ziti/cmd/upgrade_ziti_prox_c.go deleted file mode 100644 index a71baad45..000000000 --- a/ziti/cmd/upgrade_ziti_prox_c.go +++ /dev/null @@ -1,89 +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 cmd - -import ( - 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/spf13/cobra" -) - -var ( - upgradeZitiProxCLong = templates.LongDesc(` - Upgrades the Ziti ProxC app if there is a newer release -`) - - upgradeZitiProxCExample = templates.Examples(` - # Upgrades the Ziti ProxC app - ziti upgrade ziti-prox-c - `) -) - -// UpgradeZitiProxCOptions the options for the upgrade ziti-prox-c command -type UpgradeZitiProxCOptions struct { - CommonOptions - - Version string -} - -// NewCmdUpgradeZitiProxC defines the command -func NewCmdUpgradeZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiProxCOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-prox-c", - Short: "Upgrades the Ziti ProxC app - if there is a new version available", - Aliases: []string{"proxc"}, - Long: upgradeZitiProxCLong, - Example: upgradeZitiProxCExample, - 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 *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(c.ZITI_PROX_C, c.ZITI_SDK_C_GITHUB, true, newVersionStr) -} diff --git a/ziti/cmd/upgrade_ziti_router.go b/ziti/cmd/upgrade_ziti_router.go deleted file mode 100644 index a1bf3aad6..000000000 --- a/ziti/cmd/upgrade_ziti_router.go +++ /dev/null @@ -1,90 +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 cmd - -import ( - 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 ( - upgradeZitiRouterLong = templates.LongDesc(` - Upgrades the Ziti Router app if there is a newer release -`) - - upgradeZitiRouterExample = templates.Examples(` - # Upgrades the Ziti Router app - ziti upgrade ziti-router - `) -) - -// UpgradeZitiRouterOptions the options for the upgrade ziti-router command -type UpgradeZitiRouterOptions struct { - CommonOptions - - Version string -} - -// NewCmdUpgradeZitiRouter defines the command -func NewCmdUpgradeZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiRouterOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-router", - Short: "Upgrades the Ziti Router app - if there is a new version available", - Aliases: []string{"router", "rtr", "r"}, - Long: upgradeZitiRouterLong, - Example: upgradeZitiRouterExample, - 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 *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/upgrade_ziti_tunnel.go b/ziti/cmd/upgrade_ziti_tunnel.go deleted file mode 100644 index 349957bf7..000000000 --- a/ziti/cmd/upgrade_ziti_tunnel.go +++ /dev/null @@ -1,90 +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 cmd - -import ( - 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 ( - upgradeZitiTunnelLong = templates.LongDesc(` - Upgrades the Ziti Tunnel app if there is a newer release -`) - - upgradeZitiTunnelExample = templates.Examples(` - # Upgrades the Ziti Tunnel app - ziti upgrade ziti-tunnel - `) -) - -// UpgradeZitiTunnelOptions the options for the upgrade ziti-tunnel command -type UpgradeZitiTunnelOptions struct { - CommonOptions - - Version string -} - -// NewCmdUpgradeZitiTunnel defines the command -func NewCmdUpgradeZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &UpgradeZitiTunnelOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "ziti-tunnel", - Short: "Upgrades the Ziti Tunnel app - if there is a new version available", - Aliases: []string{"tunnel", "rtr", "r"}, - Long: upgradeZitiTunnelLong, - Example: upgradeZitiTunnelExample, - 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 *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/use.go b/ziti/cmd/use.go deleted file mode 100644 index 5a15854d5..000000000 --- a/ziti/cmd/use.go +++ /dev/null @@ -1,153 +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 cmd - -import ( - "fmt" - 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: 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{}, - } - - 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) - } - - 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() - 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/version.go b/ziti/cmd/version.go deleted file mode 100644 index 268e6da81..000000000 --- a/ziti/cmd/version.go +++ /dev/null @@ -1,250 +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 cmd - -import ( - "fmt" - "github.com/blang/semver" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/table" - c "github.com/openziti/ziti/ziti/constants" - "github.com/openziti/ziti/ziti/internal/log" - "github.com/openziti/ziti/ziti/util" - "io" - "os" - - // "strings" - - "github.com/openziti/ziti/common/version" - "github.com/spf13/cobra" -) - -const () - -type VersionOptions struct { - CommonOptions - - Container string - NoVersionCheck bool -} - -func NewCmdVersion(out io.Writer, errOut io.Writer) *cobra.Command { - options := &VersionOptions{ - CommonOptions: 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) - }, - } - options.AddCommonFlags(cmd) - - cmd.Flags().BoolVarP(&options.NoVersionCheck, "no-update", "n", false, - "disable update check") - - return cmd -} - -// Run ... -func (o *VersionOptions) Run() error { - - util.ConfigDir() - - 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 { - o.versionCheckZitiApp(c.ZITI) - o.versionCheckZitiApp(c.ZITI_CONTROLLER) - o.versionCheckZitiApp(c.ZITI_PROX_C) - o.versionCheckZitiApp(c.ZITI_ROUTER) - o.versionCheckZitiApp(c.ZITI_TUNNEL) - o.versionCheckZitiApp(c.ZITI_EDGE_TUNNEL) - 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{ - CommonOptions: o.CommonOptions, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiController() error { - options := &UpgradeZitiControllerOptions{ - CommonOptions: o.CommonOptions, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiProxC() error { - options := &UpgradeZitiProxCOptions{ - CommonOptions: o.CommonOptions, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiRouter() error { - options := &UpgradeZitiRouterOptions{ - CommonOptions: o.CommonOptions, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiTunnel() error { - options := &UpgradeZitiTunnelOptions{ - CommonOptions: o.CommonOptions, - } - return options.Run() -} - -func (o *VersionOptions) upgradeZitiEdgeTunnel() error { - options := &UpgradeZitiEdgeTunnelOptions{ - CommonOptions: o.CommonOptions, - } - return options.Run() -} From d73cb54f60fb322406cb208410457000b28b3980 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 11:36:46 -0500 Subject: [PATCH 09/15] Fix controller/router commands --- ziti/cmd/cmd.go | 4 ++-- ziti/controller/root.go | 6 +++--- ziti/router/root.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 99a457269..dc3f8545e 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -124,9 +124,9 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com initCommands := NewCmdInit(out, err) createCommands := NewCmdCreate(out, err) - controllerCmd := controller.NewRunCmd() + controllerCmd := controller.NewControllerCmd() tunnelCmd := tunnel.NewTunnelCmd() - routerCmd := router.NewRunCmd() + routerCmd := router.NewRouterCmd() agentCommands := agentcli.NewAgentCmd(p) pkiCommands := NewCmdPKI(out, err) fabricCommand := fabric.NewFabricCmd(p) diff --git a/ziti/controller/root.go b/ziti/controller/root.go index 13396951b..01ec3ac3e 100644 --- a/ziti/controller/root.go +++ b/ziti/controller/root.go @@ -29,8 +29,8 @@ import ( func NewControllerCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "ziti-controller", - Short: "Ziti Fabric Controller", + Use: "controller", + Short: "Ziti Controller", PersistentPreRun: func(cmd *cobra.Command, args []string) { if verbose { logrus.SetLevel(logrus.DebugLevel) @@ -46,8 +46,8 @@ func NewControllerCmd() *cobra.Command { default: // let logrus do its own thing } - util.LogReleaseVersionCheck(constants.ZITI_CONTROLLER) + util.LogReleaseVersionCheck(constants.ZITI_CONTROLLER) }, } diff --git a/ziti/router/root.go b/ziti/router/root.go index 43cf57712..eb962e88a 100644 --- a/ziti/router/root.go +++ b/ziti/router/root.go @@ -27,8 +27,8 @@ import ( func NewRouterCmd() *cobra.Command { var routerCmd = &cobra.Command{ - Use: "ziti-router", - Short: "Ziti Fabric Router", + Use: "router", + Short: "Ziti Router", PersistentPreRun: func(cmd *cobra.Command, args []string) { if verbose { logrus.SetLevel(logrus.DebugLevel) @@ -44,8 +44,8 @@ func NewRouterCmd() *cobra.Command { default: // let logrus do its own thing } - util.LogReleaseVersionCheck(constants.ZITI_ROUTER) + util.LogReleaseVersionCheck(constants.ZITI_ROUTER) }, } From 0d1846defcc5225d2ec35254d9193f1189704071 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 11:43:07 -0500 Subject: [PATCH 10/15] Move db, log-filter and unwrap under ops command --- CHANGELOG.md | 1 + ziti/cmd/cmd.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 315c83f40..d3b2ad411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * Should work exactly the same as `ziti-tunnel` * Is hidden as `ziti-edge-tunnel` is the preferred tunnelling application * The standalone binary `ziti-tunnel` is deprecated and will be removed in a future release +* The db, log-format and unwrap commands have been moved under a new ops command # Release 0.26.11 diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index dc3f8545e..999d6a03e 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -133,9 +133,15 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com edgeCommand := edge.NewCmdEdge(out, err) tutorialCmd := tutorial.NewTutorialCmd(p) demoCmd := demo.NewDemoCmd(p) - logFilter := NewCmdLogFormat(out, err) - unwrapIdentityFileCommand := NewUnwrapIdentityFileCommand(out, err) - dbCommand := database.NewCmdDb(out, err) + + opsCommands := &cobra.Command{ + Use: "ops ", + Short: "Various utilities useful when operating a Ziti network", + } + + opsCommands.AddCommand(database.NewCmdDb(out, err)) + opsCommands.AddCommand(NewCmdLogFormat(out, err)) + opsCommands.AddCommand(NewUnwrapIdentityFileCommand(out, err)) installCommands := []*cobra.Command{ NewCmdInstall(out, err), @@ -161,7 +167,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com routerCmd, tunnelCmd, pkiCommands, - unwrapIdentityFileCommand, }, }, { @@ -174,8 +179,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com { Message: "Utilities", Commands: []*cobra.Command{ - logFilter, - dbCommand, + opsCommands, }, }, { From fc2ddda738464c97b08c213d6a5daf3f6e559390 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 12:15:08 -0500 Subject: [PATCH 11/15] Move demo and tutorial under a new learn subcommand --- CHANGELOG.md | 3 ++ ziti/cmd/cmd.go | 13 ++++-- ziti/cmd/init.go | 109 ----------------------------------------------- 3 files changed, 12 insertions(+), 113 deletions(-) delete mode 100644 ziti/cmd/init.go diff --git a/CHANGELOG.md b/CHANGELOG.md index d3b2ad411..58342a875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ * Is hidden as `ziti-edge-tunnel` is the preferred tunnelling application * The standalone binary `ziti-tunnel` is deprecated and will be removed in a future release * The db, log-format and unwrap commands have been moved under a new ops command +* The init, install, upgrade, uninstall, use and version commands have been removed + * These were used mange downloads of ziti executables and were not widely used +* The demo and tutorial commands have been moved under the new learn subcommand # Release 0.26.11 diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 999d6a03e..595c056aa 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -122,7 +122,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com p := common.NewOptionsProvider(out, err) - initCommands := NewCmdInit(out, err) createCommands := NewCmdCreate(out, err) controllerCmd := controller.NewControllerCmd() tunnelCmd := tunnel.NewTunnelCmd() @@ -143,6 +142,14 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com opsCommands.AddCommand(NewCmdLogFormat(out, err)) opsCommands.AddCommand(NewUnwrapIdentityFileCommand(out, err)) + learnCommands := &cobra.Command{ + Use: "learn ", + Short: "Tutorials and demos to help you learn about Ziti", + } + + learnCommands.AddCommand(demoCmd) + learnCommands.AddCommand(tutorialCmd) + installCommands := []*cobra.Command{ NewCmdInstall(out, err), } @@ -155,7 +162,6 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com { Message: "Working with Ziti resources:", Commands: []*cobra.Command{ - initCommands, createCommands, }, }, @@ -185,8 +191,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com { Message: "Learning Ziti", Commands: []*cobra.Command{ - demoCmd, - tutorialCmd, + learnCommands, }, }, } diff --git a/ziti/cmd/init.go b/ziti/cmd/init.go deleted file mode 100644 index 48c2b1815..000000000 --- a/ziti/cmd/init.go +++ /dev/null @@ -1,109 +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 cmd - -import ( - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/templates" - c "github.com/openziti/ziti/ziti/constants" - "github.com/spf13/cobra" - "io" -) - -// InitOptions the flags for running init -type InitOptions struct { - CommonOptions - Flags InitFlags -} - -type InitFlags struct { - Component string -} - -var ( - initLong = templates.LongDesc(` - This command installs a Ziti configuration template for a selected Ziti component - `) - - initExample = templates.Examples(` - ziti init - `) -) - -// NewCmdInit creates a command object for the generic "init" action -func NewCmdInit(out io.Writer, errOut io.Writer) *cobra.Command { - options := &InitOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, - } - - cmd := &cobra.Command{ - Use: "init", - Short: "Initialize a Ziti Configuration", - Long: initLong, - Example: initExample, - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) - }, - } - - options.AddCommonFlags(cmd) - - options.addInitFlags(cmd) - return cmd -} - -func (options *InitOptions) addInitFlags(cmd *cobra.Command) { - cmd.Flags().StringVarP(&options.Flags.Component, "component", "", "", "Ziti component being initialized.") -} - -func (o *InitOptions) Run() error { - - var err error - if o.Flags.Component == "" { - o.Flags.Component, err = o.GetZitiComponent(o.Flags.Component) - if err != nil { - return err - } - } - - err = o.installRequirements("") - if err != nil { - return err - } - - switch o.Flags.Component { - case c.ZITI_CONTROLLER: - err = o.createInitialControllerConfig() - case c.ZITI_ROUTER: - return nil - case c.ZITI: - err = o.createInitialZitiConfig() - default: - } - - if err != nil { - return err - } - - return nil -} From c8eeb57824f6e03be06a6a71b035e3b6ce499fed Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 13:21:22 -0500 Subject: [PATCH 12/15] Fix non-linux builds --- ziti/cmd/cmd.go | 2 +- ziti/tunnel/root.go | 15 ++++++++++----- ziti/tunnel/run.go | 4 ++++ ziti/tunnel/tproxy.go | 4 ++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 595c056aa..4bf467cae 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -124,7 +124,7 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com createCommands := NewCmdCreate(out, err) controllerCmd := controller.NewControllerCmd() - tunnelCmd := tunnel.NewTunnelCmd() + tunnelCmd := tunnel.NewTunnelCmd(false) routerCmd := router.NewRouterCmd() agentCommands := agentcli.NewAgentCmd(p) pkiCommands := NewCmdPKI(out, err) diff --git a/ziti/tunnel/root.go b/ziti/tunnel/root.go index 0bef0a567..d2b59e63c 100644 --- a/ziti/tunnel/root.go +++ b/ziti/tunnel/root.go @@ -44,9 +44,15 @@ const ( dnsSvcIpRangeFlag = "dnsSvcIpRange" ) -func NewTunnelCmd() *cobra.Command { +var hostSpecificCmds []*cobra.Command + +func NewTunnelCmd(standalone bool) *cobra.Command { + use := "tunnel " + if standalone { + use = filepath.Base(os.Args[0]) + } var root = &cobra.Command{ - Use: filepath.Base(os.Args[0]), + Use: use, Short: "Ziti Tunnel", PersistentPreRun: rootPreRun, Hidden: true, @@ -66,8 +72,7 @@ func NewTunnelCmd() *cobra.Command { root.AddCommand(enrollment.NewEnrollCommand(p)) root.AddCommand(NewHostCmd()) root.AddCommand(NewProxyCmd()) - root.AddCommand(NewRunCmd()) - root.AddCommand(NewTProxyCmd()) + root.AddCommand(hostSpecificCmds...) root.AddCommand(NewVersionCmd()) return root @@ -79,7 +84,7 @@ var cliAgentEnabled bool var cliAgentAddr string func Execute() { - if err := NewTunnelCmd().Execute(); err != nil { + if err := NewTunnelCmd(true).Execute(); err != nil { pfxlog.Logger().Errorf("error: %s", err) os.Exit(1) } diff --git a/ziti/tunnel/run.go b/ziti/tunnel/run.go index d776936b1..55a2841b7 100644 --- a/ziti/tunnel/run.go +++ b/ziti/tunnel/run.go @@ -26,6 +26,10 @@ import ( "github.com/spf13/cobra" ) +func init() { + hostSpecificCmds = append(hostSpecificCmds, NewRunCmd()) +} + func NewRunCmd() *cobra.Command { return &cobra.Command{ Use: "run ", diff --git a/ziti/tunnel/tproxy.go b/ziti/tunnel/tproxy.go index 2b58102d7..1d884dde0 100644 --- a/ziti/tunnel/tproxy.go +++ b/ziti/tunnel/tproxy.go @@ -25,6 +25,10 @@ import ( "github.com/spf13/cobra" ) +func init() { + hostSpecificCmds = append(hostSpecificCmds, NewTProxyCmd()) +} + func NewTProxyCmd() *cobra.Command { var runTProxyCmd = &cobra.Command{ Use: "tproxy", From cfaf402c03e80633728cf0efc36635f680dac7de Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 14 Nov 2022 13:35:19 -0500 Subject: [PATCH 13/15] Update edge and fabric command descriptions --- ziti/cmd/edge/root.go | 2 +- ziti/cmd/fabric/root.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ziti/cmd/edge/root.go b/ziti/cmd/edge/root.go index b3beb2aee..d488a170e 100644 --- a/ziti/cmd/edge/root.go +++ b/ziti/cmd/edge/root.go @@ -29,7 +29,7 @@ var ExtraEdgeCommands []func(p common.OptionsProvider) *cobra.Command // NewCmdEdge creates a command object for the "controller" command func NewCmdEdge(out io.Writer, errOut io.Writer) *cobra.Command { - cmd := util.NewEmptyParentCmd("edge", "Interact with Ziti Edge Components") + cmd := util.NewEmptyParentCmd("edge", "Manage the Edge components of a Ziti network using the Ziti Edge REST API") populateEdgeCommands(out, errOut, cmd) return cmd } diff --git a/ziti/cmd/fabric/root.go b/ziti/cmd/fabric/root.go index 8775a39ba..ec26a7335 100644 --- a/ziti/cmd/fabric/root.go +++ b/ziti/cmd/fabric/root.go @@ -28,7 +28,7 @@ import ( // NewFabricCmd creates a command object for the fabric command func NewFabricCmd(p common.OptionsProvider) *cobra.Command { - fabricCmd := util.NewEmptyParentCmd("fabric", "Interact with Ziti Fabric Components") + 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)) From 32372405d5ce4a9d86c6e2bf1b4b7a16a8c9341c Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 15 Nov 2022 09:27:45 -0500 Subject: [PATCH 14/15] Add back install, upgrade, version and use, but hide them. --- CHANGELOG.md | 7 +- ziti/cmd/cmd.go | 6 +- ziti/cmd/common/options.go | 9 + ziti/cmd/{ => install}/common_install.go | 40 +-- ziti/cmd/{ => install}/install.go | 37 ++- ...tall_terraform_provider_edge_controller.go | 5 +- ziti/cmd/install/install_ziti_ALL.go | 123 ++++++++ ziti/cmd/install/install_ziti_controller.go | 93 +++++++ ziti/cmd/install/install_ziti_edge_tunnel.go | 98 +++++++ ziti/cmd/install/install_ziti_prox_c.go | 98 +++++++ ziti/cmd/install/install_ziti_router.go | 93 +++++++ ziti/cmd/install/install_ziti_tunnel.go | 93 +++++++ ziti/cmd/install/upgrade.go | 77 +++++ ziti/cmd/install/upgrade_ziti.go | 93 +++++++ ziti/cmd/install/upgrade_ziti_controller.go | 93 +++++++ ziti/cmd/install/upgrade_ziti_edge_tunnel.go | 92 ++++++ ziti/cmd/install/upgrade_ziti_prox_c.go | 92 ++++++ ziti/cmd/install/upgrade_ziti_router.go | 93 +++++++ ziti/cmd/install/upgrade_ziti_tunnel.go | 93 +++++++ ziti/cmd/install/use.go | 155 +++++++++++ ziti/cmd/install/version.go | 263 ++++++++++++++++++ 21 files changed, 1724 insertions(+), 29 deletions(-) rename ziti/cmd/{ => install}/common_install.go (83%) rename ziti/cmd/{ => install}/install.go (62%) rename ziti/cmd/{ => install}/install_terraform_provider_edge_controller.go (96%) create mode 100644 ziti/cmd/install/install_ziti_ALL.go create mode 100644 ziti/cmd/install/install_ziti_controller.go create mode 100644 ziti/cmd/install/install_ziti_edge_tunnel.go create mode 100644 ziti/cmd/install/install_ziti_prox_c.go create mode 100644 ziti/cmd/install/install_ziti_router.go create mode 100644 ziti/cmd/install/install_ziti_tunnel.go create mode 100644 ziti/cmd/install/upgrade.go create mode 100644 ziti/cmd/install/upgrade_ziti.go create mode 100644 ziti/cmd/install/upgrade_ziti_controller.go create mode 100644 ziti/cmd/install/upgrade_ziti_edge_tunnel.go create mode 100644 ziti/cmd/install/upgrade_ziti_prox_c.go create mode 100644 ziti/cmd/install/upgrade_ziti_router.go create mode 100644 ziti/cmd/install/upgrade_ziti_tunnel.go create mode 100644 ziti/cmd/install/use.go create mode 100644 ziti/cmd/install/version.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 58342a875..7934c17d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## What's New * Ziti CLI - * The CLI has been cleaned up and unused, unusable and underused components have been removed + * The CLI has been cleaned up and unused, unusable and underused components have been removed or hidden ## Ziti CLI @@ -19,8 +19,9 @@ * Is hidden as `ziti-edge-tunnel` is the preferred tunnelling application * The standalone binary `ziti-tunnel` is deprecated and will be removed in a future release * The db, log-format and unwrap commands have been moved under a new ops command -* The init, install, upgrade, uninstall, use and version commands have been removed - * These were used mange downloads of ziti executables and were not widely used +* ziti executable download management has been deprecated + * The init and uninstall commands have been removed + * The install, upgrade, use and version commands have been hidden and will be hidden once tests using them are updated or replaced * The demo and tutorial commands have been moved under the new learn subcommand # Release 0.26.11 diff --git a/ziti/cmd/cmd.go b/ziti/cmd/cmd.go index 4bf467cae..36422f450 100644 --- a/ziti/cmd/cmd.go +++ b/ziti/cmd/cmd.go @@ -25,6 +25,7 @@ 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/templates" "github.com/openziti/ziti/ziti/cmd/tutorial" c "github.com/openziti/ziti/ziti/constants" @@ -151,7 +152,10 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com learnCommands.AddCommand(tutorialCmd) installCommands := []*cobra.Command{ - NewCmdInstall(out, err), + install.NewCmdInstall(out, err), + install.NewCmdUpgrade(out, err), + install.NewCmdUse(out, err), + install.NewCmdVersion(out, err), } groups := templates.CommandGroups{ diff --git a/ziti/cmd/common/options.go b/ziti/cmd/common/options.go index 8cf0c3832..116b797e1 100644 --- a/ziti/cmd/common/options.go +++ b/ziti/cmd/common/options.go @@ -54,6 +54,15 @@ type CommonOptions struct { Identity string } +func (options *CommonOptions) AddCommonFlags(cmd *cobra.Command) { + cmd.Flags().BoolVarP(&options.BatchMode, "batch-mode", "b", false, "In batch mode the command never prompts for user input") + cmd.Flags().BoolVarP(&options.Verbose, "verbose", "", false, "Enable verbose logging") + cmd.Flags().BoolVarP(&options.Staging, "staging", "", false, "Install/Upgrade components from the ziti-staging repo") + cmd.Flags().StringVarP(&options.ConfigIdentity, "configIdentity", "i", "", "Which configIdentity to use") + cmd.Flags().IntVarP(&options.Timeout, "timeout", "t", 5, "Timeout for REST operations (specified in seconds)") + options.Cmd = cmd +} + func (options *CommonOptions) TimeoutContext() (context.Context, context.CancelFunc) { timeout := time.Duration(options.Timeout) * time.Second diff --git a/ziti/cmd/common_install.go b/ziti/cmd/install/common_install.go similarity index 83% rename from ziti/cmd/common_install.go rename to ziti/cmd/install/common_install.go index 243d339ae..bcc915817 100644 --- a/ziti/cmd/common_install.go +++ b/ziti/cmd/install/common_install.go @@ -14,7 +14,7 @@ limitations under the License. */ -package cmd +package install import ( "fmt" @@ -32,7 +32,7 @@ import ( ) // installRequirements installs any requirements needed to run the ziti CLI -func (o *CommonOptions) installRequirements(extraDependencies ...string) error { +func (o *InstallOptions) installRequirements(extraDependencies ...string) error { var deps []string for _, dep := range extraDependencies { @@ -42,7 +42,7 @@ func (o *CommonOptions) installRequirements(extraDependencies ...string) error { return o.installMissingDependencies(deps) } -func (o *CommonOptions) addRequiredBinary(binName string, deps []string) []string { +func (o *InstallOptions) addRequiredBinary(binName string, deps []string) []string { d := binaryShouldBeInstalled(binName) if d != "" && util.StringArrayIndex(deps, d) < 0 { deps = append(deps, d) @@ -87,7 +87,7 @@ func isBinaryInstalled(d string) bool { return false } -func (o *CommonOptions) deleteInstalledBinary(d string) bool { +func (o *InstallOptions) deleteInstalledBinary(d string) bool { binDir, err := util.BinaryLocation() if err == nil { exists, err := util.FileExists(filepath.Join(binDir, d)) @@ -103,7 +103,7 @@ func (o *CommonOptions) deleteInstalledBinary(d string) bool { return false } -func (o *CommonOptions) installMissingDependencies(deps []string) error { +func (o *InstallOptions) installMissingDependencies(deps []string) error { if len(deps) == 0 { return nil @@ -123,7 +123,7 @@ func (o *CommonOptions) installMissingDependencies(deps []string) error { return o.doInstallMissingDependencies(install) } -func (o *CommonOptions) doInstallMissingDependencies(install []string) error { +func (o *InstallOptions) doInstallMissingDependencies(install []string) error { for _, i := range install { var err error @@ -140,11 +140,11 @@ func (o *CommonOptions) doInstallMissingDependencies(install []string) error { return nil } -func (o *CommonOptions) installAWSCli() error { +func (o *InstallOptions) installAWSCli() error { return fmt.Errorf("Ziti's ability to auto-install the AWS CLI is curently un-implemented; For now, you must manually install the AWS CLI") } -func (o *CommonOptions) shouldInstallBinary(binDir string, name string) (fileName string, download bool, err error) { +func (o *InstallOptions) shouldInstallBinary(binDir string, name string) (fileName string, download bool, err error) { fileName = name download = false if runtime.GOOS == "windows" { @@ -169,7 +169,7 @@ func (o *CommonOptions) shouldInstallBinary(binDir string, name string) (fileNam return } -func (o *CommonOptions) downloadFile(clientURL string, fullPath string) error { +func (o *InstallOptions) downloadFile(clientURL string, fullPath string) error { log.Infof("Downloading %s to %s...\n", util.ColorInfo(clientURL), util.ColorInfo(fullPath)) err := util.DownloadFile(fullPath, clientURL) if err != nil { @@ -179,23 +179,23 @@ func (o *CommonOptions) downloadFile(clientURL string, fullPath string) error { return nil } -func (o *CommonOptions) getLatestZitiVersion(branch string) (semver.Version, error) { +func (o *InstallOptions) getLatestZitiVersion(branch string) (semver.Version, error) { return util.GetLatestVersionFromArtifactory(o.Verbose, o.Staging, branch, c.ZITI) } -func (o *CommonOptions) getLatestZitiAppVersion(branch string, zitiApp string) (semver.Version, error) { +func (o *InstallOptions) getLatestZitiAppVersion(branch string, zitiApp string) (semver.Version, error) { return util.GetLatestVersionFromArtifactory(o.Verbose, o.Staging, branch, zitiApp) } -func (o *CommonOptions) getLatestZitiAppVersionForBranch(branch string, zitiApp string) (semver.Version, error) { +func (o *InstallOptions) getLatestZitiAppVersionForBranch(branch string, zitiApp string) (semver.Version, error) { return util.GetLatestVersionFromArtifactory(o.Verbose, o.Staging, branch, zitiApp) } -func (o *CommonOptions) getLatestTerraformProviderVersion(branch string, provider string) (semver.Version, error) { +func (o *InstallOptions) getLatestTerraformProviderVersion(branch string, provider string) (semver.Version, error) { return util.GetLatestTerraformProviderVersionFromArtifactory(branch, provider) } -func (o *CommonOptions) getLatestGitHubReleaseVersion(zitiApp string) (semver.Version, error) { +func (o *InstallOptions) getLatestGitHubReleaseVersion(zitiApp string) (semver.Version, error) { var result semver.Version release, err := util.GetHighestVersionGitHubReleaseInfo(o.Verbose, zitiApp) if release != nil { @@ -204,11 +204,11 @@ func (o *CommonOptions) getLatestGitHubReleaseVersion(zitiApp string) (semver.Ve return result, err } -func (o *CommonOptions) getHighestVersionGitHubReleaseInfo(zitiApp string) (*util.GitHubReleasesData, error) { +func (o *InstallOptions) getHighestVersionGitHubReleaseInfo(zitiApp string) (*util.GitHubReleasesData, error) { return util.GetHighestVersionGitHubReleaseInfo(o.Verbose, zitiApp) } -func (o *CommonOptions) getCurrentZitiSnapshotList() ([]string, error) { +func (o *InstallOptions) getCurrentZitiSnapshotList() ([]string, error) { children, err := util.GetCurrentSnapshotListFromArtifactory(o.Verbose) list := make([]string, 0) @@ -222,7 +222,7 @@ func (o *CommonOptions) getCurrentZitiSnapshotList() ([]string, error) { return list, err } -func (o *CommonOptions) installZitiApp(branch string, zitiApp string, upgrade bool, version string) error { +func (o *InstallOptions) installZitiApp(branch string, zitiApp string, upgrade bool, version string) error { binDir, err := util.BinaryLocation() if err != nil { return err @@ -280,7 +280,7 @@ func (o *CommonOptions) installZitiApp(branch string, zitiApp string, upgrade bo return os.Chmod(fullPath, 0755) } -func (o *CommonOptions) installTerraformProvider(branch string, provider string, upgrade bool, version string) error { +func (o *InstallOptions) installTerraformProvider(branch string, provider string, upgrade bool, version string) error { resty.SetDebug(o.Verbose) binDir, err := util.TerraformProviderBinaryLocation() if err != nil { @@ -330,7 +330,7 @@ func (o *CommonOptions) installTerraformProvider(branch string, provider string, return os.Chmod(fileToChmod, 0755) } -func (o *CommonOptions) findVersionAndInstallGitHubRelease(zitiApp string, zitiAppGitHub string, upgrade bool, version string) error { +func (o *InstallOptions) findVersionAndInstallGitHubRelease(zitiApp string, zitiAppGitHub string, upgrade bool, version string) error { var latestVersion semver.Version var err error if version != "" { @@ -356,7 +356,7 @@ func (o *CommonOptions) findVersionAndInstallGitHubRelease(zitiApp string, zitiA return o.installGitHubRelease(zitiApp, upgrade, release) } -func (o *CommonOptions) installGitHubRelease(zitiApp string, upgrade bool, release *util.GitHubReleasesData) error { +func (o *InstallOptions) installGitHubRelease(zitiApp string, upgrade bool, release *util.GitHubReleasesData) error { binDir, err := util.BinaryLocation() if err != nil { return err diff --git a/ziti/cmd/install.go b/ziti/cmd/install/install.go similarity index 62% rename from ziti/cmd/install.go rename to ziti/cmd/install/install.go index a098b1109..1873aa1b6 100644 --- a/ziti/cmd/install.go +++ b/ziti/cmd/install/install.go @@ -14,19 +14,25 @@ limitations under the License. */ -package cmd +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 { - CommonOptions + common.CommonOptions } var ( @@ -40,10 +46,26 @@ var ( `) ) +// 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{ - CommonOptions{ + common.CommonOptions{ Out: out, Err: errOut, }, @@ -62,8 +84,17 @@ func NewCmdInstall(out io.Writer, errOut io.Writer) *cobra.Command { 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) diff --git a/ziti/cmd/install_terraform_provider_edge_controller.go b/ziti/cmd/install/install_terraform_provider_edge_controller.go similarity index 96% rename from ziti/cmd/install_terraform_provider_edge_controller.go rename to ziti/cmd/install/install_terraform_provider_edge_controller.go index a90747874..56c7f0557 100644 --- a/ziti/cmd/install_terraform_provider_edge_controller.go +++ b/ziti/cmd/install/install_terraform_provider_edge_controller.go @@ -14,9 +14,10 @@ limitations under the License. */ -package cmd +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" @@ -50,7 +51,7 @@ type InstallTerraformProviderEdgeControllerOptions struct { func NewCmdInstallTerraformProviderEdgeController(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallTerraformProviderEdgeControllerOptions{ InstallOptions: InstallOptions{ - CommonOptions: CommonOptions{ + CommonOptions: common.CommonOptions{ Out: out, Err: errOut, }, diff --git a/ziti/cmd/install/install_ziti_ALL.go b/ziti/cmd/install/install_ziti_ALL.go new file mode 100644 index 000000000..5416d7960 --- /dev/null +++ b/ziti/cmd/install/install_ziti_ALL.go @@ -0,0 +1,123 @@ +/* + 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) + } + + 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 new file mode 100644 index 000000000..fd84463cc --- /dev/null +++ b/ziti/cmd/install/install_ziti_controller.go @@ -0,0 +1,93 @@ +/* + 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) + } + + 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 new file mode 100644 index 000000000..bf42c6143 --- /dev/null +++ b/ziti/cmd/install/install_ziti_edge_tunnel.go @@ -0,0 +1,98 @@ +/* + 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/blang/semver" + c "github.com/openziti/ziti/ziti/constants" + "github.com/openziti/ziti/ziti/internal/log" + "github.com/spf13/cobra" +) + +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 { + newVersion, err := o.getLatestGitHubReleaseVersion(c.ZITI_EDGE_TUNNEL_GITHUB) + if err != nil { + return err + } + + if targetVersion != "" { + newVersion, err = semver.Make(targetVersion) + } + + log.Infoln("Attempting to install '" + c.ZITI_EDGE_TUNNEL + "' version: " + newVersion.String()) + + return o.findVersionAndInstallGitHubRelease(c.ZITI_EDGE_TUNNEL, c.ZITI_EDGE_TUNNEL_GITHUB, false, 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 new file mode 100644 index 000000000..50de6ff70 --- /dev/null +++ b/ziti/cmd/install/install_ziti_prox_c.go @@ -0,0 +1,98 @@ +/* + 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 ( + 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 { + if targetVersion != "" { + version, err := semver.Make(targetVersion) + if err != nil { + return err + } + return o.findVersionAndInstallGitHubRelease(c.ZITI_PROX_C, c.ZITI_SDK_C_GITHUB, false, version.String()) + } + + release, err := o.getHighestVersionGitHubReleaseInfo(c.ZITI_SDK_C_GITHUB) + if err != nil { + return err + } + log.Infoln("Attempting to install '" + c.ZITI_PROX_C + "' version: " + release.SemVer.String()) + return o.installGitHubRelease(c.ZITI_PROX_C, false, release) +} + +// 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 new file mode 100644 index 000000000..26610adc6 --- /dev/null +++ b/ziti/cmd/install/install_ziti_router.go @@ -0,0 +1,93 @@ +/* + 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) + } + + 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 new file mode 100644 index 000000000..809908770 --- /dev/null +++ b/ziti/cmd/install/install_ziti_tunnel.go @@ -0,0 +1,93 @@ +/* + 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) + } + + 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 new file mode 100644 index 000000000..f681b93ad --- /dev/null +++ b/ziti/cmd/install/upgrade.go @@ -0,0 +1,77 @@ +/* + 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 new file mode 100644 index 000000000..916c835ea --- /dev/null +++ b/ziti/cmd/install/upgrade_ziti.go @@ -0,0 +1,93 @@ +/* + 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 new file mode 100644 index 000000000..b42e3aa80 --- /dev/null +++ b/ziti/cmd/install/upgrade_ziti_controller.go @@ -0,0 +1,93 @@ +/* + 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/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/spf13/cobra" +) + +var ( + upgradeZitiControllerLong = templates.LongDesc(` + Upgrades the Ziti Controller app if there is a newer release +`) + + upgradeZitiControllerExample = templates.Examples(` + # Upgrades the Ziti Controller app + ziti upgrade ziti-controller + `) +) + +// UpgradeZitiControllerOptions the options for the upgrade ziti-controller command +type UpgradeZitiControllerOptions struct { + InstallOptions + + Version string +} + +// NewCmdUpgradeZitiController defines the command +func NewCmdUpgradeZitiController(out io.Writer, errOut io.Writer) *cobra.Command { + options := &UpgradeZitiControllerOptions{ + InstallOptions: InstallOptions{ + CommonOptions: common.CommonOptions{ + Out: out, + Err: errOut, + }, + }, + } + + cmd := &cobra.Command{ + Use: "ziti-controller", + Short: "Upgrades the Ziti Controller app - if there is a new version available", + Aliases: []string{"controller", "ctrl", "zc"}, + Long: upgradeZitiControllerLong, + Example: upgradeZitiControllerExample, + 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 *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 new file mode 100644 index 000000000..0bd73af45 --- /dev/null +++ b/ziti/cmd/install/upgrade_ziti_edge_tunnel.go @@ -0,0 +1,92 @@ +/* + 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" + + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" + "github.com/spf13/cobra" +) + +var ( + upgradeZitiEdgeTunnelLong = templates.LongDesc(` + Upgrades the Ziti Edge Tunnel app if there is a newer release +`) + + upgradeZitiEdgeTunnelExample = templates.Examples(` + # Upgrades the Ziti Edge Tunnel app + ziti upgrade ziti-edge-tunnel + `) +) + +// UpgradeZitiEdgeTunnelOptions the options for the upgrade ziti-edge-tunnel command +type UpgradeZitiEdgeTunnelOptions struct { + InstallOptions + + Version string +} + +// NewCmdUpgradeZitiEdgeTunnel defines the command +func NewCmdUpgradeZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { + options := &UpgradeZitiEdgeTunnelOptions{ + InstallOptions: InstallOptions{ + CommonOptions: common.CommonOptions{ + Out: out, + Err: errOut, + }, + }, + } + + cmd := &cobra.Command{ + Use: "ziti-edge-tunnel", + Short: "Upgrades the Ziti Edge Tunnel app - if there is a new version available", + Aliases: []string{"edge-tunnel", "et"}, + Long: upgradeZitiEdgeTunnelLong, + Example: upgradeZitiEdgeTunnelExample, + 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 *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(c.ZITI_EDGE_TUNNEL, c.ZITI_EDGE_TUNNEL_GITHUB, true, newVersionStr) +} diff --git a/ziti/cmd/install/upgrade_ziti_prox_c.go b/ziti/cmd/install/upgrade_ziti_prox_c.go new file mode 100644 index 000000000..db6ae533f --- /dev/null +++ b/ziti/cmd/install/upgrade_ziti_prox_c.go @@ -0,0 +1,92 @@ +/* + 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" + + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/templates" + c "github.com/openziti/ziti/ziti/constants" + "github.com/spf13/cobra" +) + +var ( + upgradeZitiProxCLong = templates.LongDesc(` + Upgrades the Ziti ProxC app if there is a newer release +`) + + upgradeZitiProxCExample = templates.Examples(` + # Upgrades the Ziti ProxC app + ziti upgrade ziti-prox-c + `) +) + +// UpgradeZitiProxCOptions the options for the upgrade ziti-prox-c command +type UpgradeZitiProxCOptions struct { + InstallOptions + + Version string +} + +// NewCmdUpgradeZitiProxC defines the command +func NewCmdUpgradeZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { + options := &UpgradeZitiProxCOptions{ + InstallOptions: InstallOptions{ + CommonOptions: common.CommonOptions{ + Out: out, + Err: errOut, + }, + }, + } + + cmd := &cobra.Command{ + Use: "ziti-prox-c", + Short: "Upgrades the Ziti ProxC app - if there is a new version available", + Aliases: []string{"proxc"}, + Long: upgradeZitiProxCLong, + Example: upgradeZitiProxCExample, + 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 *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(c.ZITI_PROX_C, c.ZITI_SDK_C_GITHUB, true, newVersionStr) +} diff --git a/ziti/cmd/install/upgrade_ziti_router.go b/ziti/cmd/install/upgrade_ziti_router.go new file mode 100644 index 000000000..43aaabfc3 --- /dev/null +++ b/ziti/cmd/install/upgrade_ziti_router.go @@ -0,0 +1,93 @@ +/* + 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/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/spf13/cobra" +) + +var ( + upgradeZitiRouterLong = templates.LongDesc(` + Upgrades the Ziti Router app if there is a newer release +`) + + upgradeZitiRouterExample = templates.Examples(` + # Upgrades the Ziti Router app + ziti upgrade ziti-router + `) +) + +// UpgradeZitiRouterOptions the options for the upgrade ziti-router command +type UpgradeZitiRouterOptions struct { + InstallOptions + + Version string +} + +// NewCmdUpgradeZitiRouter defines the command +func NewCmdUpgradeZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { + options := &UpgradeZitiRouterOptions{ + InstallOptions: InstallOptions{ + CommonOptions: common.CommonOptions{ + Out: out, + Err: errOut, + }, + }, + } + + cmd := &cobra.Command{ + Use: "ziti-router", + Short: "Upgrades the Ziti Router app - if there is a new version available", + Aliases: []string{"router", "rtr", "r"}, + Long: upgradeZitiRouterLong, + Example: upgradeZitiRouterExample, + 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 *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 new file mode 100644 index 000000000..6cd16cc35 --- /dev/null +++ b/ziti/cmd/install/upgrade_ziti_tunnel.go @@ -0,0 +1,93 @@ +/* + 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/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/spf13/cobra" +) + +var ( + upgradeZitiTunnelLong = templates.LongDesc(` + Upgrades the Ziti Tunnel app if there is a newer release +`) + + upgradeZitiTunnelExample = templates.Examples(` + # Upgrades the Ziti Tunnel app + ziti upgrade ziti-tunnel + `) +) + +// UpgradeZitiTunnelOptions the options for the upgrade ziti-tunnel command +type UpgradeZitiTunnelOptions struct { + InstallOptions + + Version string +} + +// NewCmdUpgradeZitiTunnel defines the command +func NewCmdUpgradeZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { + options := &UpgradeZitiTunnelOptions{ + InstallOptions: InstallOptions{ + CommonOptions: common.CommonOptions{ + Out: out, + Err: errOut, + }, + }, + } + + cmd := &cobra.Command{ + Use: "ziti-tunnel", + Short: "Upgrades the Ziti Tunnel app - if there is a new version available", + Aliases: []string{"tunnel", "rtr", "r"}, + Long: upgradeZitiTunnelLong, + Example: upgradeZitiTunnelExample, + 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 *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 new file mode 100644 index 000000000..ce14bde86 --- /dev/null +++ b/ziti/cmd/install/use.go @@ -0,0 +1,155 @@ +/* + 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) + } + + 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() + 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 new file mode 100644 index 000000000..1c46ecdca --- /dev/null +++ b/ziti/cmd/install/version.go @@ -0,0 +1,263 @@ +/* + 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 { + + util.ConfigDir() + + 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 { + o.versionCheckZitiApp(c.ZITI) + o.versionCheckZitiApp(c.ZITI_CONTROLLER) + o.versionCheckZitiApp(c.ZITI_PROX_C) + o.versionCheckZitiApp(c.ZITI_ROUTER) + o.versionCheckZitiApp(c.ZITI_TUNNEL) + o.versionCheckZitiApp(c.ZITI_EDGE_TUNNEL) + 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() +} From fb03b88adf92f13ceb09d38cd1245c61d7752782 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 15 Nov 2022 22:51:59 -0500 Subject: [PATCH 15/15] Replace use of `ziti version` with `ziti --version` in quickstart --- quickstart/docker/README.md | 4 ++-- quickstart/docker/buildLocalDev.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstart/docker/README.md b/quickstart/docker/README.md index cd6f7023a..dd853f242 100644 --- a/quickstart/docker/README.md +++ b/quickstart/docker/README.md @@ -17,10 +17,10 @@ Build Docker Image For Publication 1. issue this function to pull the latest ziti binaries: `getLatestZiti` 1. move the ziti binaries: `mv ziti-bin/ziti image/ziti.ignore/` 1. build the docker image: `docker build image -t openziti/quickstart` -1. exec into a container and make sure it's the version you expect: `docker run --rm -it openziti/quickstart ziti version` +1. exec into a container and make sure it's the version you expect: `docker run --rm -it openziti/quickstart ziti --version` 1. cleanup: `rm ziti-*tar.gz; rm -rf ziti-bin` 2. Push Docker Image to dockerhub ------------------ 1. `source ./image/ziti-cli-functions.sh` -1. just run `./pushLatestDocker.sh` \ No newline at end of file +1. just run `./pushLatestDocker.sh` diff --git a/quickstart/docker/buildLocalDev.sh b/quickstart/docker/buildLocalDev.sh index 8dc9a0bad..5e709cf24 100755 --- a/quickstart/docker/buildLocalDev.sh +++ b/quickstart/docker/buildLocalDev.sh @@ -54,7 +54,7 @@ if [ -d "${ZITI_DOCKER_ROOT}/image/ziti.ignore" ]; then rm -rf "${ZITI_DOCKER_ROOT}/image/ziti.ignore" fi -docker run --rm -it openziti/quickstart:dev /openziti/ziti-bin/ziti version +echo "Ziti Version: $(docker run --rm -it openziti/quickstart:dev /openziti/ziti-bin/ziti --version)" vers="$(echo "${ZITI_BINARIES_VERSION}" | cut -c 2-100)" docker tag "openziti/quickstart:dev" "openziti/quickstart:dev"