From 674363f03beb29aa54d348cd8db5495ad0bf5bcd Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 12 Apr 2022 17:38:15 -0400 Subject: [PATCH] Add demo agent and echo-server health checks. Do some cli tidying --- .gitignore | 1 + go.mod | 18 +-- go.sum | 35 +++-- ziti/cmd/ziti/cmd/adhoc.go | 8 +- ziti/cmd/ziti/cmd/agent.go | 40 ++--- ziti/cmd/ziti/cmd/agent_router_add_route.go | 34 ++--- ziti/cmd/ziti/cmd/agent_simple.go | 30 ++-- ziti/cmd/ziti/cmd/agentcli/agent.go | 59 ++++++++ .../agent_clear_channel_log_level.go} | 33 ++-- .../cmd/{ps_gc.go => agentcli/agent_gc.go} | 34 ++--- .../cmd/{ps_get.go => agentcli/agent_get.go} | 39 ++--- .../agent_go_version_action.go} | 33 ++-- .../agent_memstats.go} | 31 ++-- .../agent_pprof_cpu.go} | 37 ++--- .../agent_pprof_heap.go} | 36 ++--- .../agent_set_channel_log_level.go} | 43 +++--- .../agent_set_log_level.go} | 40 ++--- .../{ps_setgc.go => agentcli/agent_setgc.go} | 32 ++-- .../{ps_stack.go => agentcli/agent_stack.go} | 33 ++-- .../{ps_stats.go => agentcli/agent_stats.go} | 34 ++--- .../{ps_trace.go => agentcli/agent_trace.go} | 33 ++-- ziti/cmd/ziti/cmd/art.go | 10 +- ziti/cmd/ziti/cmd/cmd.go | 48 +++--- ziti/cmd/ziti/cmd/common.go | 120 +-------------- ziti/cmd/ziti/cmd/common/options.go | 6 - ziti/cmd/ziti/cmd/create.go | 15 +- ziti/cmd/ziti/cmd/create_environment.go | 8 +- ziti/cmd/ziti/cmd/demo/echo_server.go | 143 +++++++++++++++++- .../cmd/demo/echo_server_update_terminator.go | 101 +++++++++++++ ziti/cmd/ziti/cmd/demo/root.go | 24 ++- .../multi-router-tunneler-hosted.md | 9 +- .../demo/setup-scripts/multi-sdk-hosted.md | 5 +- .../demo/setup-scripts/single-sdk-hosted.md | 2 +- .../update-config-addressable.md | 4 +- .../demo/setup-scripts/update-config-ha.md | 4 +- ziti/cmd/ziti/cmd/edge/create.go | 23 ++- .../cmd/ziti/cmd/edge/create_authenticator.go | 5 +- ziti/cmd/ziti/cmd/edge/create_ca.go | 8 +- ziti/cmd/ziti/cmd/edge/create_config.go | 5 +- ziti/cmd/ziti/cmd/edge/create_config_type.go | 5 +- ziti/cmd/ziti/cmd/edge/create_edge_router.go | 5 +- .../cmd/edge/create_edge_router_policy.go | 5 +- ziti/cmd/ziti/cmd/edge/create_identity.go | 5 +- ziti/cmd/ziti/cmd/edge/create_service.go | 8 +- .../edge/create_service_edge_router_policy.go | 5 +- ziti/cmd/ziti/cmd/edge/create_terminator.go | 8 +- ziti/cmd/ziti/cmd/edge/list.go | 6 +- ziti/cmd/ziti/cmd/edge/root.go | 11 +- ziti/cmd/ziti/cmd/edge/update.go | 25 ++- .../cmd/ziti/cmd/edge/update_authenticator.go | 5 +- ziti/cmd/ziti/cmd/edge/update_ca.go | 5 +- ziti/cmd/ziti/cmd/edge/update_config.go | 5 +- ziti/cmd/ziti/cmd/edge/update_edge_router.go | 5 +- .../cmd/edge/update_edge_router_policy.go | 5 +- ziti/cmd/ziti/cmd/edge/update_identity.go | 5 +- .../ziti/cmd/edge/update_identity_configs.go | 5 +- ziti/cmd/ziti/cmd/edge/update_service.go | 5 +- .../edge/update_service_edge_router_policy.go | 5 +- .../ziti/cmd/edge/update_service_policy.go | 5 +- ziti/cmd/ziti/cmd/edge/update_terminator.go | 8 +- ziti/cmd/ziti/cmd/execute.go | 10 +- ziti/cmd/ziti/cmd/execute_controller.go | 10 +- ziti/cmd/ziti/cmd/fabric/list.go | 5 +- ziti/cmd/ziti/cmd/factory/factory.go | 55 ------- ziti/cmd/ziti/cmd/init.go | 10 +- ziti/cmd/ziti/cmd/install.go | 28 ++-- ziti/cmd/ziti/cmd/install_ansible.go | 8 +- ...tall_terraform_provider_edge_controller.go | 10 +- ziti/cmd/ziti/cmd/install_ziti_ALL.go | 10 +- ziti/cmd/ziti/cmd/install_ziti_controller.go | 14 +- ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go | 10 +- ziti/cmd/ziti/cmd/install_ziti_fabric.go | 14 +- ziti/cmd/ziti/cmd/install_ziti_prox_c.go | 10 +- ziti/cmd/ziti/cmd/install_ziti_router.go | 14 +- ziti/cmd/ziti/cmd/install_ziti_tunnel.go | 14 +- ziti/cmd/ziti/cmd/lets_encrypt/create.go | 3 +- ziti/cmd/ziti/cmd/lets_encrypt/list.go | 3 +- ziti/cmd/ziti/cmd/lets_encrypt/renew.go | 3 +- ziti/cmd/ziti/cmd/lets_encrypt/revoke.go | 3 +- ziti/cmd/ziti/cmd/lets_encrypt/root.go | 16 +- ziti/cmd/ziti/cmd/log_filter.go | 10 +- ziti/cmd/ziti/cmd/ping.go | 8 +- ziti/cmd/ziti/cmd/pki.go | 12 +- ziti/cmd/ziti/cmd/pki_create.go | 20 ++- ziti/cmd/ziti/cmd/pki_create_ca.go | 8 +- ziti/cmd/ziti/cmd/pki_create_client.go | 8 +- ziti/cmd/ziti/cmd/pki_create_csr.go | 8 +- ziti/cmd/ziti/cmd/pki_create_intermediate.go | 8 +- ziti/cmd/ziti/cmd/pki_create_key.go | 8 +- ziti/cmd/ziti/cmd/pki_create_server.go | 8 +- ziti/cmd/ziti/cmd/playbook.go | 10 +- ziti/cmd/ziti/cmd/ps.go | 66 ++++---- ziti/cmd/ziti/cmd/uninstall.go | 20 ++- .../cmd/ziti/cmd/uninstall_ziti_controller.go | 8 +- .../ziti/cmd/uninstall_ziti_edge_tunnel.go | 8 +- ziti/cmd/ziti/cmd/uninstall_ziti_fabric.go | 8 +- ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go | 8 +- ziti/cmd/ziti/cmd/uninstall_ziti_router.go | 8 +- ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go | 8 +- ziti/cmd/ziti/cmd/unwrap_identity.go | 3 +- ziti/cmd/ziti/cmd/update.go | 8 +- ziti/cmd/ziti/cmd/upgrade.go | 22 ++- ziti/cmd/ziti/cmd/upgrade_ziti.go | 10 +- ziti/cmd/ziti/cmd/upgrade_ziti_controller.go | 10 +- ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go | 10 +- ziti/cmd/ziti/cmd/upgrade_ziti_fabric.go | 10 +- ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go | 10 +- ziti/cmd/ziti/cmd/upgrade_ziti_router.go | 10 +- ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go | 10 +- ziti/cmd/ziti/cmd/use.go | 8 +- ziti/cmd/ziti/cmd/version.go | 10 +- 111 files changed, 922 insertions(+), 1055 deletions(-) create mode 100644 ziti/cmd/ziti/cmd/agentcli/agent.go rename ziti/cmd/ziti/cmd/{ps_clear_channel_log_level.go => agentcli/agent_clear_channel_log_level.go} (71%) rename ziti/cmd/ziti/cmd/{ps_gc.go => agentcli/agent_gc.go} (66%) rename ziti/cmd/ziti/cmd/{ps_get.go => agentcli/agent_get.go} (75%) rename ziti/cmd/ziti/cmd/{ps_goversion.go => agentcli/agent_go_version_action.go} (66%) rename ziti/cmd/ziti/cmd/{ps_memstats.go => agentcli/agent_memstats.go} (68%) rename ziti/cmd/ziti/cmd/{ps_pprof_cpu.go => agentcli/agent_pprof_cpu.go} (65%) rename ziti/cmd/ziti/cmd/{ps_pprof_heap.go => agentcli/agent_pprof_heap.go} (64%) rename ziti/cmd/ziti/cmd/{ps_set_channel_log_level.go => agentcli/agent_set_channel_log_level.go} (72%) rename ziti/cmd/ziti/cmd/{ps_set_log_level.go => agentcli/agent_set_log_level.go} (70%) rename ziti/cmd/ziti/cmd/{ps_setgc.go => agentcli/agent_setgc.go} (74%) rename ziti/cmd/ziti/cmd/{ps_stack.go => agentcli/agent_stack.go} (66%) rename ziti/cmd/ziti/cmd/{ps_stats.go => agentcli/agent_stats.go} (66%) rename ziti/cmd/ziti/cmd/{ps_trace.go => agentcli/agent_trace.go} (65%) create mode 100644 ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go delete mode 100644 ziti/cmd/ziti/cmd/factory/factory.go diff --git a/.gitignore b/.gitignore index 8fe9a3062..fb701d2ed 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ linux-build *.log /build/ go.work +go.work.sum diff --git a/go.mod b/go.mod index c624c417b..119950483 100644 --- a/go.mod +++ b/go.mod @@ -36,13 +36,13 @@ require ( github.com/jedib0t/go-pretty/v6 v6.2.4 github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.6.9 - github.com/openziti/channel v0.18.23 - github.com/openziti/edge v0.21.174 - github.com/openziti/fabric v0.17.93 + github.com/openziti/channel v0.18.25 + github.com/openziti/edge v0.21.186 + github.com/openziti/fabric v0.17.97 github.com/openziti/foundation v0.17.22 - github.com/openziti/sdk-golang v0.16.44 + github.com/openziti/sdk-golang v0.16.47 github.com/openziti/storage v0.1.4 - github.com/openziti/transport v0.1.3 + github.com/openziti/transport v0.1.4 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 @@ -66,13 +66,11 @@ require ( require ( github.com/AppsFlyer/go-sundheit v0.5.0 // indirect github.com/MichaelMure/go-term-text v0.3.1 // indirect - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/andybalholm/brotli v1.0.4 // indirect github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211106181442-e4c1a74c66bd // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/biogo/store v0.0.0-20200525035639-8c94ae1e7c9c // indirect - github.com/cenkalti/backoff/v4 v4.1.2 // indirect + github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/coreos/go-iptables v0.6.0 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -90,9 +88,9 @@ require ( github.com/go-openapi/analysis v0.21.2 // indirect github.com/go-openapi/errors v0.20.2 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/loads v0.21.1 // indirect - github.com/go-openapi/spec v0.20.4 // indirect + github.com/go-openapi/spec v0.20.5 // indirect github.com/go-openapi/swag v0.21.1 // indirect github.com/go-openapi/validate v0.21.0 // indirect github.com/go-stack/stack v1.8.1 // indirect diff --git a/go.sum b/go.sum index 9737cf446..80d3253d2 100644 --- a/go.sum +++ b/go.sum @@ -90,9 +90,7 @@ github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87/go.mod h1:iGLljf5n9GjT6kc0HBvyI1nOKnGQbNB66VzSNbK5iks= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -154,8 +152,9 @@ github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBW github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -320,8 +319,9 @@ github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3Hfo github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= -github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= @@ -354,8 +354,9 @@ github.com/go-openapi/spec v0.19.15/go.mod h1:+81FIL1JwC5P3/Iuuozq3pPE9dXdIEGxFu github.com/go-openapi/spec v0.20.0/go.mod h1:+81FIL1JwC5P3/Iuuozq3pPE9dXdIEGxFutcFKaVbmU= github.com/go-openapi/spec v0.20.1/go.mod h1:93x7oh+d+FQsmsieroS4cmR3u0p/ywH649a3qwC9OsQ= github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg= -github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.5 h1:skHa8av4VnAtJU5zyAUXrrdK/NDiVX8lchbG+BfcdrE= +github.com/go-openapi/spec v0.20.5/go.mod h1:QbfOSIVt3/sac+a1wzmKbbcLXm5NdZnyBZYtCijp43o= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= @@ -809,26 +810,24 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openziti/channel v0.18.21/go.mod h1:P6hCAQuuhTA5UGCZZWK/tro4L8WN5exPocC7gyc+7Ms= -github.com/openziti/channel v0.18.23 h1:5JsD5mwtprPRDDniwoLQrQSlUM2nJlIOpWaG0c/ew7o= -github.com/openziti/channel v0.18.23/go.mod h1:GnMk+jbZ/I6/98mAUo+5iq3TZamrAKzLP/6LxWuicuQ= +github.com/openziti/channel v0.18.24/go.mod h1:GnMk+jbZ/I6/98mAUo+5iq3TZamrAKzLP/6LxWuicuQ= +github.com/openziti/channel v0.18.25 h1:dcwPcQ17sa9i8rV7xbkmswS81Vjjwgn3lw/cPV7joCs= +github.com/openziti/channel v0.18.25/go.mod h1:WT35GAbpPEhzwtgEU6KYkStUZVoNuk5XEDbv5SYnVtM= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge v0.21.174 h1:tRRfQKcAq31E8UUy2w9PMQ43EdLP5gCG221K9Kr30aM= -github.com/openziti/edge v0.21.174/go.mod h1:jHSwfe65MANZLyei6h80w3c0VNEIo+L1w8toghxyIOg= -github.com/openziti/fabric v0.17.93 h1:POAYjSBLrJ2J77VChd92FWttXHKDYK+n3Jy0WUhwR7o= -github.com/openziti/fabric v0.17.93/go.mod h1:31hewCwTmm/6ZpTzSlsbKw0aadl+OhUNDxqmD1K6j80= -github.com/openziti/foundation v0.17.20/go.mod h1:Nnr0vsqovHJimkdBHf2s4ZJAgvNhg6UdVqP+s0nY3P4= +github.com/openziti/edge v0.21.186 h1:aVdQ5E7ZyiJ8S+SDFlS0d6UQMkCv2W4GSm9k0bfDTf4= +github.com/openziti/edge v0.21.186/go.mod h1:o25nulRGG0N6npWCwH56a1RoNWm/bjGOdPogklQH1SM= +github.com/openziti/fabric v0.17.97 h1:JQB9FA6BIE/bBWe5krRGZdQ8hfgonNwrI+MXytahy/k= +github.com/openziti/fabric v0.17.97/go.mod h1:KfQitm+XCyc79i4oeQmTRuPRtedp0aY1UZjV5BNrBzM= github.com/openziti/foundation v0.17.22 h1:zFfgNHdLocEcoBqtognpJnYsVQaTm28EwqMNjBw8avk= github.com/openziti/foundation v0.17.22/go.mod h1:Nnr0vsqovHJimkdBHf2s4ZJAgvNhg6UdVqP+s0nY3P4= -github.com/openziti/sdk-golang v0.16.42/go.mod h1:iYDQW7vbLhAaZBMiBXAsAoKzNyBX0m/zDlnF5s/xa3Y= -github.com/openziti/sdk-golang v0.16.44 h1:1FfRrk8JjxOk2/JAl5Hi/sBM/QiGPruNjIFztbZ/5iw= -github.com/openziti/sdk-golang v0.16.44/go.mod h1:YLf7qITZMK0Y3REj7CbQTOP53SX/iDxo5QG1YeoQ8ow= +github.com/openziti/sdk-golang v0.16.47 h1:mN5gK2+rh7IUZbYYoLW1DnUTlssHaXKtuzP97KQUy8M= +github.com/openziti/sdk-golang v0.16.47/go.mod h1:Kq2DXOxWuPS0PE21fxER2p1NdiTSKdEk6USdkKvGM+c= github.com/openziti/storage v0.1.4 h1:horz3P0fABJH6R2Orvl2OLksmhXHpCaHP+0TCKfbGPM= github.com/openziti/storage v0.1.4/go.mod h1:aMf2fqWAyXjXH7N0CxfpeGMrlLIDCT7nRSR3cGrsEoI= -github.com/openziti/transport v0.1.0/go.mod h1:2n6p2AZu3H9NzbJbQ7vOGFwtZKpvy8tIp+x+J7G5Sw0= -github.com/openziti/transport v0.1.3 h1:IEAOyJaGzgDGzGpJAXKRGX8SKmRO6T+C73PsJEE+UYY= github.com/openziti/transport v0.1.3/go.mod h1:NK1wWR16q1IBgvItzruGtvDc2C7AaJpRQqryC2tGIgA= +github.com/openziti/transport v0.1.4 h1:/nCssPGHHFmGGQ2hdFkWXJpMT35sj9xN3IQ39MRZ5qs= +github.com/openziti/transport v0.1.4/go.mod h1:NK1wWR16q1IBgvItzruGtvDc2C7AaJpRQqryC2tGIgA= github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= diff --git a/ziti/cmd/ziti/cmd/adhoc.go b/ziti/cmd/ziti/cmd/adhoc.go index 189d1acba..8ea48b62a 100644 --- a/ziti/cmd/ziti/cmd/adhoc.go +++ b/ziti/cmd/ziti/cmd/adhoc.go @@ -24,7 +24,6 @@ import ( "path/filepath" "github.com/openziti/ziti/ziti/ansible" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -37,12 +36,11 @@ type AdhocOptions struct { var adhocOptions = &ansible.Options{} // NewCmdAdhoc creates the command -func NewCmdAdhoc(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdAdhoc(out io.Writer, errOut io.Writer) *cobra.Command { options := &AdhocOptions{ CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } diff --git a/ziti/cmd/ziti/cmd/agent.go b/ziti/cmd/ziti/cmd/agent.go index 38dd96693..7ca2b332a 100644 --- a/ziti/cmd/ziti/cmd/agent.go +++ b/ziti/cmd/ziti/cmd/agent.go @@ -20,9 +20,10 @@ import ( "github.com/openziti/edge/router/debugops" "github.com/openziti/fabric/controller" "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" - "io" ) type AgentAppId byte @@ -32,14 +33,8 @@ const ( AgentAppRouter = AgentAppId(router.AgentAppId) ) -func NewAgentCmd(out io.Writer, errOut io.Writer) *cobra.Command { - agentCmd := &cobra.Command{ - Use: "agent", - Short: "Interact with ziti processes using the the IPC agent", - Run: func(cmd *cobra.Command, args []string) { - cmdhelper.CheckErr(cmd.Help()) - }, - } +func NewAgentCmd(p common.OptionsProvider) *cobra.Command { + agentCmd := agentcli.NewAgentCmd(p) ctrlCmd := &cobra.Command{ Use: "controller", @@ -51,7 +46,7 @@ func NewAgentCmd(out io.Writer, errOut io.Writer) *cobra.Command { } agentCmd.AddCommand(ctrlCmd) - ctrlCmd.AddCommand(NewSimpleAgentCustomCmd("snapshot-db", AgentAppController, controller.AgentOpSnapshotDbSnaps, out, errOut)) + ctrlCmd.AddCommand(NewSimpleAgentCustomCmd("snapshot-db", AgentAppController, controller.AgentOpSnapshotDbSnaps, p)) routerCmd := &cobra.Command{ Use: "router", @@ -64,25 +59,12 @@ func NewAgentCmd(out io.Writer, errOut io.Writer) *cobra.Command { agentCmd.AddCommand(routerCmd) - routerCmd.AddCommand(NewCmdPsRoute(out, errOut)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-routes", AgentAppRouter, router.DumpForwarderTables, out, errOut)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("disconnect", AgentAppRouter, router.CloseControlChannel, out, errOut)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("reconnect", AgentAppRouter, router.OpenControlChannel, out, errOut)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-api-sessions", AgentAppRouter, debugops.DumpApiSessions, out, errOut)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-links", AgentAppRouter, router.DumpLinks, out, errOut)) - - agentCmd.AddCommand(NewCmdPsGoversion(out, errOut)) - agentCmd.AddCommand(NewCmdPsGc(out, errOut)) - agentCmd.AddCommand(NewCmdPsSetgc(out, errOut)) - agentCmd.AddCommand(NewCmdPsStack(out, errOut)) - agentCmd.AddCommand(NewCmdPsMemstats(out, errOut)) - agentCmd.AddCommand(NewCmdPsStats(out, errOut)) - agentCmd.AddCommand(NewCmdPsPprofHeap(out, errOut)) - agentCmd.AddCommand(NewCmdPsPprofCpu(out, errOut)) - agentCmd.AddCommand(NewCmdPsTrace(out, errOut)) - agentCmd.AddCommand(NewCmdPsSetLogLevel(out, errOut)) - agentCmd.AddCommand(NewCmdPsSetChannelLogLevel(out, errOut)) - agentCmd.AddCommand(NewCmdPsClearChannelLogLevel(out, errOut)) + 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)) return agentCmd } diff --git a/ziti/cmd/ziti/cmd/agent_router_add_route.go b/ziti/cmd/ziti/cmd/agent_router_add_route.go index 19cb804a8..08260d664 100644 --- a/ziti/cmd/ziti/cmd/agent_router_add_route.go +++ b/ziti/cmd/ziti/cmd/agent_router_add_route.go @@ -22,26 +22,22 @@ import ( "github.com/openziti/fabric/pb/ctrl_pb" "github.com/openziti/fabric/router" "github.com/openziti/foundation/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" - "io" "os" ) -// PsRouteOptions the options for the create spring command -type PsRouteOptions struct { - PsOptions +type AgentRouteAction struct { + agentcli.AgentOptions CtrlListener string } -// NewCmdPsRoute creates a command object for the "create" command -func NewCmdPsRoute(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsRouteOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewRouteCmd(p common.OptionsProvider) *cobra.Command { + options := &AgentRouteAction{ + AgentOptions: agentcli.AgentOptions{ + CommonOptions: p(), }, } @@ -56,19 +52,17 @@ func NewCmdPsRoute(out io.Writer, errOut io.Writer) *cobra.Command { }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsRouteOptions) Run() error { +func (self *AgentRouteAction) Run() error { var addr string var err error offset := 0 - if len(o.Args) == 4 { - addr, err = agent.ParseGopsAddress(o.Args) + if len(self.Args) == 4 { + addr, err = agent.ParseGopsAddress(self.Args) if err != nil { return err } @@ -76,11 +70,11 @@ func (o *PsRouteOptions) Run() error { } route := &ctrl_pb.Route{ - CircuitId: o.Args[offset], + CircuitId: self.Args[offset], Forwards: []*ctrl_pb.Route_Forward{ { - SrcAddress: o.Args[offset+1], - DstAddress: o.Args[offset+2], + SrcAddress: self.Args[offset+1], + DstAddress: self.Args[offset+2], }, }, } diff --git a/ziti/cmd/ziti/cmd/agent_simple.go b/ziti/cmd/ziti/cmd/agent_simple.go index f5257f473..1a3507b98 100644 --- a/ziti/cmd/ziti/cmd/agent_simple.go +++ b/ziti/cmd/ziti/cmd/agent_simple.go @@ -18,23 +18,21 @@ package cmd import ( "github.com/openziti/foundation/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" - "io" "os" ) -type SimpleAgentCmdOptions struct { - PsOptions +type SimpleAgentAction struct { + agentcli.AgentOptions } -func NewSimpleAgentCustomCmd(name string, appId AgentAppId, op byte, out io.Writer, errOut io.Writer) *cobra.Command { - options := &SimpleAgentCmdOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewSimpleAgentCustomCmd(name string, appId AgentAppId, op byte, p common.OptionsProvider) *cobra.Command { + action := &SimpleAgentAction{ + AgentOptions: agentcli.AgentOptions{ + CommonOptions: p(), }, } @@ -42,21 +40,19 @@ func NewSimpleAgentCustomCmd(name string, appId AgentAppId, op byte, out io.Writ Args: cobra.MaximumNArgs(1), Use: name + " ", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run(appId, op) + action.Cmd = cmd + action.Args = args + err := action.Run(appId, op) cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *SimpleAgentCmdOptions) Run(appId AgentAppId, op byte) error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *SimpleAgentAction) Run(appId AgentAppId, op byte) error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/agentcli/agent.go b/ziti/cmd/ziti/cmd/agentcli/agent.go new file mode 100644 index 000000000..da9955e3d --- /dev/null +++ b/ziti/cmd/ziti/cmd/agentcli/agent.go @@ -0,0 +1,59 @@ +package agentcli + +import ( + "github.com/openziti/channel" + "github.com/openziti/foundation/agent" + "github.com/openziti/foundation/identity/identity" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/spf13/cobra" + "net" + "time" +) + +func NewAgentCmd(p common.OptionsProvider) *cobra.Command { + agentCmd := &cobra.Command{ + Use: "agent", + Short: "Interact with ziti processes using the the IPC agent", + Run: func(cmd *cobra.Command, args []string) { + cmdhelper.CheckErr(cmd.Help()) + }, + } + + agentCmd.AddCommand(NewGoVersionCmd(p)) + agentCmd.AddCommand(NewGcCmd(p)) + agentCmd.AddCommand(NewSetGcCmd(p)) + agentCmd.AddCommand(NewStackCmd(p)) + agentCmd.AddCommand(NewMemstatsCmd(p)) + agentCmd.AddCommand(NewStatsCmd(p)) + agentCmd.AddCommand(NewPprofHeapCmd(p)) + agentCmd.AddCommand(NewPprofCpuCmd(p)) + agentCmd.AddCommand(NewTraceCmd(p)) + agentCmd.AddCommand(NewSetLogLevelCmd(p)) + agentCmd.AddCommand(NewSetChannelLogLevelCmd(p)) + agentCmd.AddCommand(NewClearChannelLogLevelCmd(p)) + + return agentCmd +} + +// AgentOptions contains the command line options +type AgentOptions struct { + common.CommonOptions +} + +func NewAgentChannel(conn net.Conn) (channel.Channel, error) { + options := channel.DefaultOptions() + options.ConnectTimeout = time.Second + dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) + return channel.NewChannel("agent", dialer, nil, options) +} + +func MakeAgentChannelRequest(addr string, signal byte, params []byte, f func(ch channel.Channel) error) error { + return agent.MakeRequestF(addr, signal, params, func(conn net.Conn) error { + ch, err := NewAgentChannel(conn) + if err != nil { + return err + } + return f(ch) + }) +} diff --git a/ziti/cmd/ziti/cmd/ps_clear_channel_log_level.go b/ziti/cmd/ziti/cmd/agentcli/agent_clear_channel_log_level.go similarity index 71% rename from ziti/cmd/ziti/cmd/ps_clear_channel_log_level.go rename to ziti/cmd/ziti/cmd/agentcli/agent_clear_channel_log_level.go index 391dc1076..6fff36158 100644 --- a/ziti/cmd/ziti/cmd/ps_clear_channel_log_level.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_clear_channel_log_level.go @@ -14,31 +14,26 @@ limitations under the License. */ -package cmd +package agentcli import ( "bytes" "encoding/binary" "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" ) -type PsClearChannelLogLevelOptions struct { - PsOptions - CtrlListener string +type AgentClearChannelLogLevelAction struct { + AgentOptions } -// NewCmdPsClearChannelLogLevel creates a command object for the "create" command -func NewCmdPsClearChannelLogLevel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsClearChannelLogLevelOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewClearChannelLogLevelCmd(p common.OptionsProvider) *cobra.Command { + options := &AgentClearChannelLogLevelAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -54,22 +49,20 @@ func NewCmdPsClearChannelLogLevel(out io.Writer, errOut io.Writer) *cobra.Comman }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsClearChannelLogLevelOptions) Run() error { +func (self *AgentClearChannelLogLevelAction) Run() error { var addr string var err error var channelArg string - if len(o.Args) == 1 { + if len(self.Args) == 1 { addr, err = agent.ParseGopsAddress(nil) - channelArg = o.Args[0] + channelArg = self.Args[0] } else { - addr, err = agent.ParseGopsAddress(o.Args) - channelArg = o.Args[1] + addr, err = agent.ParseGopsAddress(self.Args) + channelArg = self.Args[1] } if err != nil { diff --git a/ziti/cmd/ziti/cmd/ps_gc.go b/ziti/cmd/ziti/cmd/agentcli/agent_gc.go similarity index 66% rename from ziti/cmd/ziti/cmd/ps_gc.go rename to ziti/cmd/ziti/cmd/agentcli/agent_gc.go index 3b00584b4..8f9d97de4 100644 --- a/ziti/cmd/ziti/cmd/ps_gc.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_gc.go @@ -14,30 +14,24 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" ) -// PsGcOptions the options for the create spring command -type PsGcOptions struct { - PsOptions - CtrlListener string +type AgentGcAction struct { + AgentOptions } -// NewCmdPsGc creates a command object for the "create" command -func NewCmdPsGc(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsGcOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewGcCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentGcAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -46,21 +40,19 @@ func NewCmdPsGc(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Run garbage collection in the target application", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsGcOptions) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *AgentGcAction) Run() error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/ps_get.go b/ziti/cmd/ziti/cmd/agentcli/agent_get.go similarity index 75% rename from ziti/cmd/ziti/cmd/ps_get.go rename to ziti/cmd/ziti/cmd/agentcli/agent_get.go index 546415686..b2a5dbcd2 100644 --- a/ziti/cmd/ziti/cmd/ps_get.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_get.go @@ -14,34 +14,28 @@ limitations under the License. */ -package cmd +package agentcli import ( "fmt" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" "github.com/shirou/gopsutil/process" "github.com/spf13/cobra" - "io" "strconv" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" ) -// PsGetOptions the options for the create spring command -type PsGetOptions struct { - PsOptions - - CtrlListener string +type AgentGetOptionsAction struct { + AgentOptions + Pid string } -// NewCmdPsGet creates a command object for the "create" command -func NewCmdPsGet(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsGetOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewGetCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentGetOptionsAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -49,23 +43,22 @@ func NewCmdPsGet(out io.Writer, errOut io.Writer) *cobra.Command { Use: "get", Short: "Returns information about the target process", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - cmd.Flags().StringVarP(&options.Flags.Pid, "pid", "", "", "pid (target of sub-cmd)") + cmd.Flags().StringVarP(&action.Pid, "pid", "", "", "pid (target of sub-cmd)") return cmd } // Run implements the command -func (o *PsGetOptions) Run() error { - pidStr := o.Args[0] - _, err := strconv.Atoi(o.Args[0]) +func (self *AgentGetOptionsAction) Run() error { + pidStr := self.Args[0] + _, err := strconv.Atoi(self.Args[0]) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/ps_goversion.go b/ziti/cmd/ziti/cmd/agentcli/agent_go_version_action.go similarity index 66% rename from ziti/cmd/ziti/cmd/ps_goversion.go rename to ziti/cmd/ziti/cmd/agentcli/agent_go_version_action.go index c846d8e64..16a37e435 100644 --- a/ziti/cmd/ziti/cmd/ps_goversion.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_go_version_action.go @@ -14,30 +14,25 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" ) -// PsGoversionOptions the options for the create spring command -type PsGoversionOptions struct { - PsOptions +type AgentGoVersionAction struct { + AgentOptions CtrlListener string } -// NewCmdPsGoversion creates a command object for the "create" command -func NewCmdPsGoversion(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsGoversionOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewGoVersionCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentGoVersionAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -46,21 +41,19 @@ func NewCmdPsGoversion(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Returns the golang version of the target application", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsGoversionOptions) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *AgentGoVersionAction) Run() error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/ps_memstats.go b/ziti/cmd/ziti/cmd/agentcli/agent_memstats.go similarity index 68% rename from ziti/cmd/ziti/cmd/ps_memstats.go rename to ziti/cmd/ziti/cmd/agentcli/agent_memstats.go index 733e5e3fc..9e2337a71 100644 --- a/ziti/cmd/ziti/cmd/ps_memstats.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_memstats.go @@ -14,30 +14,25 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" ) -// PsMemstatsOptions the options for the create spring command -type PsMemstatsOptions struct { - PsOptions +type AgentMemstatsAction struct { + AgentOptions CtrlListener string } -// NewCmdPsMemstats creates a command object for the "create" command -func NewCmdPsMemstats(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsMemstatsOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewMemstatsCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentMemstatsAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -46,20 +41,18 @@ func NewCmdPsMemstats(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Returns memory use summary of the target application", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsMemstatsOptions) Run() error { +func (o *AgentMemstatsAction) Run() error { addr, err := agent.ParseGopsAddress(o.Args) if err != nil { return err diff --git a/ziti/cmd/ziti/cmd/ps_pprof_cpu.go b/ziti/cmd/ziti/cmd/agentcli/agent_pprof_cpu.go similarity index 65% rename from ziti/cmd/ziti/cmd/ps_pprof_cpu.go rename to ziti/cmd/ziti/cmd/agentcli/agent_pprof_cpu.go index 6abb8e9c7..46d7b2e6e 100644 --- a/ziti/cmd/ziti/cmd/ps_pprof_cpu.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_pprof_cpu.go @@ -14,30 +14,25 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" ) -// PsPprofCpuOptions the options for the create spring command -type PsPprofCpuOptions struct { - PsOptions - CtrlListener string +type AgentPprofCpuAction struct { + AgentOptions } -// NewCmdPsPprofCpu creates a command object for the "create" command -func NewCmdPsPprofCpu(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsPprofCpuOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewPprofCpuCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentPprofCpuAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -46,28 +41,26 @@ func NewCmdPsPprofCpu(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Runs and emits a 30 second pprof from the target application", Args: cobra.MaximumNArgs(2), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsPprofCpuOptions) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *AgentPprofCpuAction) Run() error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } var out io.WriteCloser = os.Stdout - if len(o.Args) > 1 { - out, err = os.Create(o.Args[1]) + if len(self.Args) > 1 { + out, err = os.Create(self.Args[1]) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/ps_pprof_heap.go b/ziti/cmd/ziti/cmd/agentcli/agent_pprof_heap.go similarity index 64% rename from ziti/cmd/ziti/cmd/ps_pprof_heap.go rename to ziti/cmd/ziti/cmd/agentcli/agent_pprof_heap.go index ca7a383f3..74786676f 100644 --- a/ziti/cmd/ziti/cmd/ps_pprof_heap.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_pprof_heap.go @@ -14,29 +14,25 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" ) -// PsPprofHeapOptions the options for the create spring command -type PsPprofHeapOptions struct { - PsOptions +type AgentPprofHeapAction struct { + AgentOptions } -// NewCmdPsPprofHeap creates a command object for the "create" command -func NewCmdPsPprofHeap(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsPprofHeapOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewPprofHeapCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentPprofHeapAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -44,28 +40,26 @@ func NewCmdPsPprofHeap(out io.Writer, errOut io.Writer) *cobra.Command { Use: "pprof-heap", Short: "Returns a memory heap pprof of the target application", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsPprofHeapOptions) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *AgentPprofHeapAction) Run() error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } var out io.WriteCloser = os.Stdout - if len(o.Args) > 1 { - out, err = os.Create(o.Args[1]) + if len(self.Args) > 1 { + out, err = os.Create(self.Args[1]) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/ps_set_channel_log_level.go b/ziti/cmd/ziti/cmd/agentcli/agent_set_channel_log_level.go similarity index 72% rename from ziti/cmd/ziti/cmd/ps_set_channel_log_level.go rename to ziti/cmd/ziti/cmd/agentcli/agent_set_channel_log_level.go index d3ec563fa..1b7288cfa 100644 --- a/ziti/cmd/ziti/cmd/ps_set_channel_log_level.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_set_channel_log_level.go @@ -14,34 +14,29 @@ limitations under the License. */ -package cmd +package agentcli import ( "bytes" "encoding/binary" "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "io" "os" "strings" ) -type PsSetChannelLogLevelOptions struct { - PsOptions - CtrlListener string +type AgentSetChannelLogLevelAction struct { + AgentOptions } -// NewCmdPsSetChannelLogLevel creates a command object for the "create" command -func NewCmdPsSetChannelLogLevel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsSetChannelLogLevelOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewSetChannelLogLevelCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentSetChannelLogLevelAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -50,32 +45,30 @@ func NewCmdPsSetChannelLogLevel(out io.Writer, errOut io.Writer) *cobra.Command Short: "Sets a channel-specific log level in the target application", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsSetChannelLogLevelOptions) Run() error { +func (self *AgentSetChannelLogLevelAction) Run() error { var addr string var err error var channelArg string var levelArg string - if len(o.Args) == 2 { + if len(self.Args) == 2 { addr, err = agent.ParseGopsAddress(nil) - channelArg = o.Args[0] - levelArg = o.Args[1] + channelArg = self.Args[0] + levelArg = self.Args[1] } else { - addr, err = agent.ParseGopsAddress(o.Args) - channelArg = o.Args[1] - levelArg = o.Args[2] + addr, err = agent.ParseGopsAddress(self.Args) + channelArg = self.Args[1] + levelArg = self.Args[2] } if err != nil { diff --git a/ziti/cmd/ziti/cmd/ps_set_log_level.go b/ziti/cmd/ziti/cmd/agentcli/agent_set_log_level.go similarity index 70% rename from ziti/cmd/ziti/cmd/ps_set_log_level.go rename to ziti/cmd/ziti/cmd/agentcli/agent_set_log_level.go index 347fdd4bc..f129592a9 100644 --- a/ziti/cmd/ziti/cmd/ps_set_log_level.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_set_log_level.go @@ -14,33 +14,27 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "io" "os" "strings" ) -// PsSetgcOptions the options for the create spring command -type PsSetLogLevelOptions struct { - PsOptions - CtrlListener string +type AgentSetLogLevelAction struct { + AgentOptions } -// NewCmdPsLogLevel creates a command object for the "create" command -func NewCmdPsSetLogLevel(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsSetLogLevelOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewSetLogLevelCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentSetLogLevelAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -49,29 +43,27 @@ func NewCmdPsSetLogLevel(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Sets the global logrus logging level in the target application", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsSetLogLevelOptions) Run() error { +func (self *AgentSetLogLevelAction) Run() error { var addr string var err error var levelArg string - if len(o.Args) == 1 { + if len(self.Args) == 1 { addr, err = agent.ParseGopsAddress(nil) - levelArg = o.Args[0] + levelArg = self.Args[0] } else { - addr, err = agent.ParseGopsAddress(o.Args) - levelArg = o.Args[1] + addr, err = agent.ParseGopsAddress(self.Args) + levelArg = self.Args[1] } if err != nil { diff --git a/ziti/cmd/ziti/cmd/ps_setgc.go b/ziti/cmd/ziti/cmd/agentcli/agent_setgc.go similarity index 74% rename from ziti/cmd/ziti/cmd/ps_setgc.go rename to ziti/cmd/ziti/cmd/agentcli/agent_setgc.go index 3101cb9f8..b3e68d537 100644 --- a/ziti/cmd/ziti/cmd/ps_setgc.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_setgc.go @@ -14,32 +14,26 @@ limitations under the License. */ -package cmd +package agentcli import ( "encoding/binary" "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" "strconv" ) -// PsSetgcOptions the options for the create spring command -type PsSetgcOptions struct { - PsOptions - CtrlListener string +type AgentSetGcAction struct { + AgentOptions } -// NewCmdPsSetgc creates a command object for the "create" command -func NewCmdPsSetgc(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsSetgcOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewSetGcCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentSetGcAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -48,20 +42,18 @@ func NewCmdPsSetgc(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Sets the GC percentage in the target application", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsSetgcOptions) Run() error { +func (o *AgentSetGcAction) Run() error { var addr string var err error var pctArg string diff --git a/ziti/cmd/ziti/cmd/ps_stack.go b/ziti/cmd/ziti/cmd/agentcli/agent_stack.go similarity index 66% rename from ziti/cmd/ziti/cmd/ps_stack.go rename to ziti/cmd/ziti/cmd/agentcli/agent_stack.go index d55ca6a36..b278aab1f 100644 --- a/ziti/cmd/ziti/cmd/ps_stack.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_stack.go @@ -14,32 +14,26 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" "time" ) -// PsStackOptions the options for the create spring command -type PsStackOptions struct { - PsOptions - CtrlListener string +type AgentStackAction struct { + AgentOptions StackTimeout time.Duration } -// NewCmdPsStack creates a command object for the "create" command -func NewCmdPsStack(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsStackOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewStackCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentStackAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -48,21 +42,20 @@ func NewCmdPsStack(out io.Writer, errOut io.Writer) *cobra.Command { Use: "stack []", Short: "Emits a go-routine stack dump from the target application", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - cmd.Flags().DurationVar(&options.StackTimeout, "stack-timeout", 5*time.Second, "Timeout for stack operation") + cmd.Flags().DurationVar(&action.StackTimeout, "stack-timeout", 5*time.Second, "Timeout for stack operation") return cmd } // Run implements the command -func (o *PsStackOptions) Run() error { +func (o *AgentStackAction) Run() error { time.AfterFunc(o.StackTimeout, func() { os.Exit(-1) }) diff --git a/ziti/cmd/ziti/cmd/ps_stats.go b/ziti/cmd/ziti/cmd/agentcli/agent_stats.go similarity index 66% rename from ziti/cmd/ziti/cmd/ps_stats.go rename to ziti/cmd/ziti/cmd/agentcli/agent_stats.go index 485dc1a78..8116e16b7 100644 --- a/ziti/cmd/ziti/cmd/ps_stats.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_stats.go @@ -14,30 +14,24 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" ) -// PsStatsOptions the options for the create spring command -type PsStatsOptions struct { - PsOptions - CtrlListener string +type AgentStatsAction struct { + AgentOptions } -// NewCmdPsStats creates a command object for the "create" command -func NewCmdPsStats(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsStatsOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewStatsCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentStatsAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -46,21 +40,19 @@ func NewCmdPsStats(out io.Writer, errOut io.Writer) *cobra.Command { Short: "Emits some runtime information (# go-routines, threads, cpus, etc) from the target application", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsStatsOptions) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *AgentStatsAction) Run() error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/ps_trace.go b/ziti/cmd/ziti/cmd/agentcli/agent_trace.go similarity index 65% rename from ziti/cmd/ziti/cmd/ps_trace.go rename to ziti/cmd/ziti/cmd/agentcli/agent_trace.go index 885f8d5b8..09e24e491 100644 --- a/ziti/cmd/ziti/cmd/ps_trace.go +++ b/ziti/cmd/ziti/cmd/agentcli/agent_trace.go @@ -14,29 +14,24 @@ limitations under the License. */ -package cmd +package agentcli import ( "github.com/openziti/foundation/agent" + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" - "io" "os" ) -// PsTraceOptions the options for the create spring command -type PsTraceOptions struct { - PsOptions +type AgentTraceAction struct { + AgentOptions } -// NewCmdPsTrace creates a command object for the "create" command -func NewCmdPsTrace(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsTraceOptions{ - PsOptions: PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, - }, +func NewTraceCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentTraceAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), }, } @@ -44,21 +39,19 @@ func NewCmdPsTrace(out io.Writer, errOut io.Writer) *cobra.Command { Use: "trace", Short: "Turn tracing on for 5 seconds in the target application", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) - return cmd } // Run implements the command -func (o *PsTraceOptions) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *AgentTraceAction) Run() error { + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } diff --git a/ziti/cmd/ziti/cmd/art.go b/ziti/cmd/ziti/cmd/art.go index 7aa4548bb..ff6da6cf7 100644 --- a/ziti/cmd/ziti/cmd/art.go +++ b/ziti/cmd/ziti/cmd/art.go @@ -20,7 +20,6 @@ import ( "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" @@ -32,12 +31,11 @@ type ArtOptions struct { CommonOptions } -func NewCmdArt(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdArt(out io.Writer, errOut io.Writer) *cobra.Command { options := &ArtOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -51,7 +49,7 @@ func NewCmdArt(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Comman cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/cmd.go b/ziti/cmd/ziti/cmd/cmd.go index 975928744..5baf1fed2 100644 --- a/ziti/cmd/ziti/cmd/cmd.go +++ b/ziti/cmd/ziti/cmd/cmd.go @@ -30,7 +30,6 @@ import ( "github.com/openziti/ziti/ziti/cmd/ziti/cmd/edge" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -47,8 +46,6 @@ type MainOptions struct { } type RootCmd struct { - factory cmdutil.Factory - configFile string RegistryPath string @@ -85,13 +82,10 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - factory := cmdutil.NewFactory() - rootCommand.factory = factory - NewCmdRoot(factory, os.Stdin, os.Stdout, os.Stderr) - + NewCmdRoot(os.Stdin, os.Stdout, os.Stderr) } -func NewCmdRoot(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Command { +func NewCmdRoot(in io.Reader, out, err io.Writer) *cobra.Command { cmd := rootCommand.cobraCommand @@ -129,24 +123,24 @@ func NewCmdRoot(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Comm p := common.NewOptionsProvider(out, err) - initCommands := NewCmdInit(f, out, err) - createCommands := NewCmdCreate(f, out, err) - updateCommands := NewCmdUpdate(f, out, err) - executeCommands := NewCmdExecute(f, out, err) - agentCommands := NewAgentCmd(out, err) - psCommands := NewCmdPs(out, err) - pkiCommands := NewCmdPKI(f, out, err) + initCommands := NewCmdInit(out, err) + createCommands := NewCmdCreate(out, err) + updateCommands := NewCmdUpdate(out, err) + executeCommands := NewCmdExecute(out, err) + agentCommands := NewAgentCmd(p) + psCommands := NewCmdPs(p) + pkiCommands := NewCmdPKI(out, err) fabricCommand := fabric.NewFabricCmd(p) - edgeCommand := edge.NewCmdEdge(f, out, err) + edgeCommand := edge.NewCmdEdge(out, err) tutorialCmd := tutorial.NewTutorialCmd(p) demoCmd := demo.NewDemoCmd(p) - logFilter := NewCmdLogFormat(f, out, err) - unwrapIdentityFileCommand := NewUnwrapIdentityFileCommand(f, out, err) + logFilter := NewCmdLogFormat(out, err) + unwrapIdentityFileCommand := NewUnwrapIdentityFileCommand(out, err) installCommands := []*cobra.Command{ - NewCmdInstall(f, out, err), - NewCmdUnInstall(f, out, err), - NewCmdUpgrade(f, out, err), + NewCmdInstall(out, err), + NewCmdUnInstall(out, err), + NewCmdUpgrade(out, err), } groups := templates.CommandGroups{ @@ -196,14 +190,14 @@ func NewCmdRoot(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cobra.Comm groups.Add(cmd) - cmd.AddCommand(NewCmdVersion(f, out, err)) + cmd.AddCommand(NewCmdVersion(out, err)) cmd.Version = version.GetVersion() cmd.SetVersionTemplate("{{printf .Version}}\n") - cmd.AddCommand(NewCmdArt(f, out, err)) - cmd.AddCommand(NewCmdPlaybook(f, out, err)) - cmd.AddCommand(NewCmdPing(f, out, err)) - cmd.AddCommand(NewCmdAdhoc(f, out, err)) - cmd.AddCommand(NewCmdUse(f, out, err)) + 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.go b/ziti/cmd/ziti/cmd/common.go index a83fdbd3a..0eba1c177 100644 --- a/ziti/cmd/ziti/cmd/common.go +++ b/ziti/cmd/ziti/cmd/common.go @@ -17,18 +17,12 @@ package cmd import ( - "fmt" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" - "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" "io" - "os" - "time" ) // CommonOptions contains common options and helper methods type CommonOptions struct { - Factory cmdutil.Factory Out io.Writer Err io.Writer Cmd *cobra.Command @@ -40,30 +34,7 @@ type CommonOptions struct { Timeout int } -type ServerFlags struct { - ServerName string - ServerURL string -} - -func (f *ServerFlags) IsEmpty() bool { - return f.ServerName == "" && f.ServerURL == "" -} - -func (c *CommonOptions) Stdout() io.Writer { - if c.Out != nil { - return c.Out - } - return os.Stdout -} - -// Debugf outputs the given text to the console if verbose mode is enabled -func (c *CommonOptions) Debugf(format string, a ...interface{}) { - if c.Verbose { - log.Infof(format, a...) - } -} - -func (options *CommonOptions) addCommonFlags(cmd *cobra.Command) { +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") @@ -71,92 +42,3 @@ func (options *CommonOptions) addCommonFlags(cmd *cobra.Command) { cmd.Flags().IntVarP(&options.Timeout, "timeout", "t", 5, "Timeout for REST operations (specified in seconds)") options.Cmd = cmd } - -func (o *CommonOptions) retry(attempts int, sleep time.Duration, call func() error) (err error) { - for i := 0; ; i++ { - err = call() - if err == nil { - return - } - - if i >= (attempts - 1) { - break - } - - time.Sleep(sleep) - - log.Infof("retrying after error:%s\n", err) - } - return fmt.Errorf("after %d attempts, last error: %s", attempts, err) -} - -func (o *CommonOptions) retryQuiet(attempts int, sleep time.Duration, call func() error) (err error) { - lastMessage := "" - dot := false - - for i := 0; ; i++ { - err = call() - if err == nil { - if dot { - log.Blank() - } - return - } - - if i >= (attempts - 1) { - break - } - - time.Sleep(sleep) - - message := fmt.Sprintf("retrying after error: %s", err) - if lastMessage == message { - log.Info(".") - dot = true - } else { - lastMessage = message - if dot { - dot = false - log.Blank() - } - log.Infof("%s\n", lastMessage) - } - } - return fmt.Errorf("after %d attempts, last error: %s", attempts, err) -} - -func (o *CommonOptions) retryQuietlyUntilTimeout(timeout time.Duration, sleep time.Duration, call func() error) (err error) { - timeoutTime := time.Now().Add(timeout) - - lastMessage := "" - dot := false - - for i := 0; ; i++ { - err = call() - if err == nil { - if dot { - log.Blank() - } - return - } - - if time.Now().After(timeoutTime) { - return fmt.Errorf("Timed out after %s, last error: %s", timeout.String(), err) - } - - time.Sleep(sleep) - - message := fmt.Sprintf("retrying after error: %s", err) - if lastMessage == message { - log.Info(".") - dot = true - } else { - lastMessage = message - if dot { - dot = false - log.Blank() - } - log.Infof("%s\n", lastMessage) - } - } -} diff --git a/ziti/cmd/ziti/cmd/common/options.go b/ziti/cmd/ziti/cmd/common/options.go index 6139def7a..4c95314bd 100644 --- a/ziti/cmd/ziti/cmd/common/options.go +++ b/ziti/cmd/ziti/cmd/common/options.go @@ -19,7 +19,6 @@ package common import ( "context" "fmt" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/table" "github.com/spf13/cobra" "io" "time" @@ -30,10 +29,6 @@ type Printer interface { Println(val interface{}) } -type Factory interface { - CreateTable(out io.Writer) table.Table -} - type OptionsProvider func() CommonOptions func NewOptionsProvider(out, err io.Writer) OptionsProvider { @@ -47,7 +42,6 @@ func NewOptionsProvider(out, err io.Writer) OptionsProvider { // CommonOptions contains common options and helper methods type CommonOptions struct { - Factory Factory Out io.Writer Err io.Writer Cmd *cobra.Command diff --git a/ziti/cmd/ziti/cmd/create.go b/ziti/cmd/ziti/cmd/create.go index efeb310b0..d81a4a586 100644 --- a/ziti/cmd/ziti/cmd/create.go +++ b/ziti/cmd/ziti/cmd/create.go @@ -17,7 +17,6 @@ package cmd import ( - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/spf13/cobra" "io" @@ -33,7 +32,7 @@ var ( ) // NewCmdCreate creates a command object for the "create" command -func NewCmdCreate(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdCreate(out io.Writer, errOut io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "create", Short: "Create a new resource", @@ -44,13 +43,13 @@ func NewCmdCreate(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Com } cmd.AddCommand(NewCmdCreateConfig()) - cmd.AddCommand(NewCmdCreateEnvironment(f, out, errOut)) + cmd.AddCommand(NewCmdCreateEnvironment(out, errOut)) - cmd.AddCommand(NewCmdPKICreateCA(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateIntermediate(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateServer(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateClient(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateCSR(f, out, errOut)) + cmd.AddCommand(NewCmdPKICreateCA(out, errOut)) + cmd.AddCommand(NewCmdPKICreateIntermediate(out, errOut)) + cmd.AddCommand(NewCmdPKICreateServer(out, errOut)) + cmd.AddCommand(NewCmdPKICreateClient(out, errOut)) + cmd.AddCommand(NewCmdPKICreateCSR(out, errOut)) return cmd } diff --git a/ziti/cmd/ziti/cmd/create_environment.go b/ziti/cmd/ziti/cmd/create_environment.go index 0a707c3f9..8de9e05af 100644 --- a/ziti/cmd/ziti/cmd/create_environment.go +++ b/ziti/cmd/ziti/cmd/create_environment.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -34,12 +33,11 @@ type CreateEnvironmentOptions struct { } // NewCmdCreateEnvironment creates a command object for the "create" command -func NewCmdCreateEnvironment(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdCreateEnvironment(out io.Writer, errOut io.Writer) *cobra.Command { options := &CreateEnvironmentOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } diff --git a/ziti/cmd/ziti/cmd/demo/echo_server.go b/ziti/cmd/ziti/cmd/demo/echo_server.go index 39fa19b1e..9af4263a0 100644 --- a/ziti/cmd/ziti/cmd/demo/echo_server.go +++ b/ziti/cmd/ziti/cmd/demo/echo_server.go @@ -17,24 +17,42 @@ package demo import ( - "errors" + "bufio" "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel" + "github.com/openziti/foundation/agent" + "github.com/openziti/foundation/identity/identity" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/config" + "github.com/openziti/sdk-golang/ziti/edge" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "io" "net" + "net/http" + "strings" + "time" +) + +const ( + EchoServerAppId = 100 + EchoServerUpdateTerminator = 1000 + EchoServerPrecedenceHeader = 1000 + EchoServerCostHeader = 1001 ) type echoServer struct { port uint16 + healthCheckAddr string verbose bool logFormatter string configFile string service string bindWithIdentity bool + zitiIdentity identity.Identity + zitiListener edge.Listener } func newEchoServerCmd() *cobra.Command { @@ -50,6 +68,7 @@ func newEchoServerCmd() *cobra.Command { // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) cmd.Flags().Uint16VarP(&server.port, "port", "p", 0, "Specify the port to listen on. If not specified the TCP listener won't be started") + cmd.Flags().StringVar(&server.healthCheckAddr, "health-check-addr", "", "Specify the ip:port on which to serve the health check endpoint. If not specified, a health check endpoint will not be started") cmd.Flags().BoolVarP(&server.verbose, "verbose", "v", false, "Enable verbose logging") cmd.Flags().StringVar(&server.logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") cmd.Flags().StringVarP(&server.configFile, "identity", "i", "", "Specify the Ziti identity to use. If not specified the Ziti listener won't be started") @@ -90,6 +109,15 @@ func (self *echoServer) run(*cobra.Command, []string) { log.Fatalf("No port specified and no ziti identity specified. Not starting either listener, so nothing to do. exiting.") } + if self.healthCheckAddr != "" { + err := http.ListenAndServe(self.healthCheckAddr, http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { + writer.WriteHeader(200) + })) + if err != nil { + log.WithError(err).Fatalf("unable to start health check endpoint on addr [%v]", self.healthCheckAddr) + } + } + if self.port > 0 { addr := fmt.Sprintf("0.0.0.0:%v", self.port) log.Infof("tcp: starting listener on address [%v]", addr) @@ -97,7 +125,6 @@ func (self *echoServer) run(*cobra.Command, []string) { if err != nil { log.WithError(err).Fatalf("unable to start TCP listener on addr [%v]", addr) } - go self.accept("tcp", listener) } @@ -106,6 +133,10 @@ func (self *echoServer) run(*cobra.Command, []string) { if err != nil { log.WithError(err).Fatalf("ziti: unable to load ziti identity from [%v]", self.configFile) } + self.zitiIdentity, err = identity.LoadIdentity(zitiConfig.ID) + if err != nil { + log.WithError(err).Fatalf("ziti: unable to create ziti identity from [%v]", self.configFile) + } zitiContext := ziti.NewContextWithConfig(zitiConfig) @@ -139,6 +170,20 @@ func (self *echoServer) run(*cobra.Command, []string) { log.WithError(err).Fatalf("ziti: failed to host service [%v]", self.service) } + self.zitiListener = listener + + shutdownClean := false + agentOptions := agent.Options{ + ShutdownCleanup: &shutdownClean, + CustomOps: map[byte]func(conn net.Conn) error{ + agent.CustomOpAsync: self.HandleCustomAgentAsyncOp, + }, + } + + if err = agent.Listen(agentOptions); err != nil { + log.WithError(err).Warn("failed to start agent") + } + go self.accept("ziti", listener) } @@ -189,3 +234,97 @@ func (self *echoServer) echo(connType string, conn io.ReadWriteCloser) { log.Infof("%v: wrote %v bytes", connType, n) } } + +func (self *echoServer) HandleCustomAgentAsyncOp(conn net.Conn) error { + logrus.Debug("received agent operation request") + + appIdBuf := []byte{0} + _, err := io.ReadFull(conn, appIdBuf) + if err != nil { + return err + } + appId := appIdBuf[0] + + if appId != EchoServerAppId { + logrus.WithField("appId", appId).Debug("invalid app id on agent request") + return errors.New("invalid operation for controller") + } + + options := channel.DefaultOptions() + options.ConnectTimeout = time.Second + tId := &identity.TokenId{Identity: self.zitiIdentity, Token: "echo-server"} + listener := channel.NewExistingConnListener(tId, conn, nil) + _, err = channel.NewChannel("agent", listener, channel.BindHandlerF(self.bindAgentChannel), options) + return err +} + +func (self *echoServer) bindAgentChannel(binding channel.Binding) error { + binding.AddReceiveHandlerF(EchoServerUpdateTerminator, self.HandleUpdateTerminator) + return nil +} + +func (self *echoServer) HandleUpdateTerminator(msg *channel.Message, ch channel.Channel) { + log := pfxlog.Logger() + precedenceLabel, hasPrecedence := msg.GetStringHeader(EchoServerPrecedenceHeader) + var precedence edge.Precedence + + if hasPrecedence { + if strings.EqualFold("default", precedenceLabel) { + precedence = edge.PrecedenceDefault + } else if strings.EqualFold("required", precedenceLabel) { + precedence = edge.PrecedenceRequired + } else if strings.EqualFold("failed", precedenceLabel) { + precedence = edge.PrecedenceFailed + } else { + err := errors.Errorf("invalid precedence [%v]", precedenceLabel) + self.SendOpResult(msg, ch, "update-precedence", err.Error(), false) + return + } + } + + cost, hasCost := msg.GetUint16Header(EchoServerCostHeader) + + var err error + if hasPrecedence && hasCost { + log.Infof("updating precedence=%v, cost=%v", precedenceLabel, cost) + err = self.zitiListener.UpdateCostAndPrecedence(cost, precedence) + } else if hasPrecedence { + log.Infof("updating precedence=%v", precedenceLabel) + + err = self.zitiListener.UpdatePrecedence(precedence) + } else if hasCost { + log.Infof("updating cost=%v", cost) + err = self.zitiListener.UpdateCost(cost) + } else { + err = errors.New("neither precedence nor cost provided, nothing to do") + } + + if err == nil { + self.SendOpResult(msg, ch, "update-precedence", "", true) + } else { + self.SendOpResult(msg, ch, "update-precedence", err.Error(), false) + } +} + +func (self *echoServer) SendOpResult(request *channel.Message, ch channel.Channel, op string, message string, success bool) { + log := pfxlog.ContextLogger(ch.Label()).WithField("operation", op) + if !success { + log.Errorf("%v error performing %v: (%s)", ch.LogicalName(), op, message) + } + + response := channel.NewResult(success, message) + response.ReplyTo(request) + if err := response.WithTimeout(time.Second).SendAndWaitForWire(ch); err != nil { + log.WithError(err).Error("failed to send result") + } +} + +func (self *echoServer) handleResult(err error, bconn *bufio.ReadWriter) error { + if err != nil { + return err + } + if _, err = bconn.WriteString("OK"); err != nil { + return err + } + return bconn.Flush() +} diff --git a/ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go b/ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go new file mode 100644 index 000000000..74a459834 --- /dev/null +++ b/ziti/cmd/ziti/cmd/demo/echo_server_update_terminator.go @@ -0,0 +1,101 @@ +/* + 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 demo + +import ( + "fmt" + "github.com/openziti/channel" + "github.com/openziti/foundation/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/pkg/errors" + "github.com/spf13/cobra" + "time" +) + +type AgentEchoServerUpdateTerminatorAction struct { + agentcli.AgentOptions + precedence string + cost uint16 +} + +func NewAgentEchoServerUpdateTerminatorCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentEchoServerUpdateTerminatorAction{ + AgentOptions: agentcli.AgentOptions{ + CommonOptions: p(), + }, + } + + updateTerminatorCmd := &cobra.Command{ + Args: cobra.RangeArgs(0, 1), + Use: "update-terminator ", + Run: func(cmd *cobra.Command, args []string) { + action.Cmd = cmd + action.Args = args + err := action.Run() + cmdhelper.CheckErr(err) + }, + } + + updateTerminatorCmd.Flags().StringVarP(&action.precedence, "precedence", "p", "", "Target precedence [default, required, failed]") + updateTerminatorCmd.Flags().Uint16VarP(&action.cost, "cost", "c", 0, "Target cost") + + return updateTerminatorCmd +} + +// Run implements the command +func (self *AgentEchoServerUpdateTerminatorAction) Run() error { + var addr string + var err error + + if len(self.Args) == 1 { + addr, err = agent.ParseGopsAddress(self.Args) + if err != nil { + return err + } + } + + return agentcli.MakeAgentChannelRequest(addr, agent.CustomOpAsync, []byte{byte(EchoServerAppId)}, self.makeRequest) +} + +func (self *AgentEchoServerUpdateTerminatorAction) makeRequest(ch channel.Channel) error { + msg := channel.NewMessage(EchoServerUpdateTerminator, nil) + + if self.Cmd.Flag("precedence").Changed { + msg.PutStringHeader(EchoServerPrecedenceHeader, self.precedence) + } + if self.Cmd.Flag("cost").Changed { + msg.PutUint16Header(EchoServerCostHeader, self.cost) + } + + reply, err := msg.WithTimeout(5 * time.Second).SendForReply(ch) + if err != nil { + return err + } + if reply.ContentType == channel.ContentTypeResultType { + result := channel.UnmarshalResult(reply) + if result.Success { + fmt.Println("success") + } else { + fmt.Printf("error: %v\n", result.Message) + } + } else { + return errors.Errorf("unexpected reponse type: %v", reply.ContentType) + } + return nil +} diff --git a/ziti/cmd/ziti/cmd/demo/root.go b/ziti/cmd/ziti/cmd/demo/root.go index 237b8e78e..6edac7f47 100644 --- a/ziti/cmd/ziti/cmd/demo/root.go +++ b/ziti/cmd/ziti/cmd/demo/root.go @@ -17,13 +17,14 @@ 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/spf13/cobra" ) func NewDemoCmd(p common.OptionsProvider) *cobra.Command { - cmd := &cobra.Command{ + demoCmd := &cobra.Command{ Use: "demo", Short: "Demos and examples for learning about Ziti", Run: func(cmd *cobra.Command, args []string) { @@ -50,10 +51,23 @@ func NewDemoCmd(p common.OptionsProvider) *cobra.Command { }, } - cmd.AddCommand(newEchoServerCmd()) - cmd.AddCommand(newZcatCmd()) + agentCmd := agentcli.NewAgentCmd(p) + echoServerAgentCmd := &cobra.Command{ + Use: "echo-server", + Short: "Interact with an echo-server process using the IPC agent", + Run: func(cmd *cobra.Command, args []string) { + helpers.CheckErr(cmd.Help()) + }, + } - cmd.AddCommand(setupCmd) + agentCmd.AddCommand(echoServerAgentCmd) + echoServerAgentCmd.AddCommand(NewAgentEchoServerUpdateTerminatorCmd(p)) + + demoCmd.AddCommand(newEchoServerCmd()) + demoCmd.AddCommand(newZcatCmd()) + demoCmd.AddCommand(agentCmd) + + demoCmd.AddCommand(setupCmd) setupCmd.AddCommand(echoCmd) echoCmd.AddCommand(newClientCmd(p)) echoCmd.AddCommand(newSingleSdkHostedCmd(p)) @@ -63,5 +77,5 @@ func NewDemoCmd(p common.OptionsProvider) *cobra.Command { echoCmd.AddCommand(newUpdateConfigAddressableCmd(p)) echoCmd.AddCommand(newUpdateConfigHACmd(p)) - return cmd + return demoCmd } diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md b/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md index fc9a83e46..efc3d4f06 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md +++ b/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-router-tunneler-hosted.md @@ -40,7 +40,7 @@ ziti edge delete service-edge-router-policies echo "protocol" : "tcp", "portChecks" : [ { - "address" : "localhost:1234", + "address" : "localhost:2234", "interval" : "1s", "timeout" : "100ms", "actions" : [ @@ -56,7 +56,7 @@ ziti edge delete service-edge-router-policies echo "protocol" : "tcp", "portChecks" : [ { - "address" : "localhost:1235", + "address" : "localhost:2235", "interval" : "1s", "timeout" : "100ms", "actions" : [ @@ -95,10 +95,11 @@ ziti edge create service-edge-router-policy echo --service-roles @echo --edge-ro ## Summary -You should now be to run the echo server with +You should now be to run two instances of the echo server with ``` -ziti demo echo-server -p 1234 +ziti demo echo-server -p 1234 --health-check-addr 0.0.0.0:2234 +ziti demo echo-server -p 1235 --health-check-addr 0.0.0.0:2235 ``` and the zcat client using diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md b/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md index 08df9df77..8796bb93c 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md +++ b/ziti/cmd/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md @@ -55,10 +55,11 @@ ziti edge create edge-router-policy echo --identity-roles #echo --edge-router-ro ziti edge create service-edge-router-policy echo --service-roles @echo --edge-router-roles #all ``` -You should now be to run the echo server with +You should now be to run two instances of the echo server with: ``` -ziti demo echo-server -i echo-host.json +ziti demo echo-server -i echo-host-1.json +ziti demo echo-server -i echo-host-2.json ``` and diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md b/ziti/cmd/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md index da9d9fe48..fa846f42b 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md +++ b/ziti/cmd/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md @@ -54,7 +54,7 @@ ziti edge create service-edge-router-policy echo --service-roles @echo --edge-ro You should now be to run the echo server with ``` -ziti demo echo-server -i echo-host.json +ziti demo echo-server -i echo-host-1.json ``` and diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-addressable.md b/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-addressable.md index 8ac142585..275b00f0d 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-addressable.md +++ b/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-addressable.md @@ -28,7 +28,7 @@ ziti edge login "protocol" : "tcp", "portChecks" : [ { - "address" : "localhost:1234", + "address" : "localhost:2234", "interval" : "1s", "timeout" : "100ms", "actions" : [ @@ -47,7 +47,7 @@ ziti edge login "protocol" : "tcp", "portChecks" : [ { - "address" : "localhost:1235", + "address" : "localhost:2235", "interval" : "1s", "timeout" : "100ms", "actions" : [ diff --git a/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-ha.md b/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-ha.md index 3dded3207..5862ae13b 100644 --- a/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-ha.md +++ b/ziti/cmd/ziti/cmd/demo/setup-scripts/update-config-ha.md @@ -28,7 +28,7 @@ ziti edge login "protocol" : "tcp", "portChecks" : [ { - "address" : "localhost:1234", + "address" : "localhost:2234", "interval" : "1s", "timeout" : "100ms", "actions" : [ @@ -47,7 +47,7 @@ ziti edge login "protocol" : "tcp", "portChecks" : [ { - "address" : "localhost:1235", + "address" : "localhost:2235", "interval" : "1s", "timeout" : "100ms", "actions" : [ diff --git a/ziti/cmd/ziti/cmd/edge/create.go b/ziti/cmd/ziti/cmd/edge/create.go index 533f88788..6eff7f0b7 100644 --- a/ziti/cmd/ziti/cmd/edge/create.go +++ b/ziti/cmd/ziti/cmd/edge/create.go @@ -22,13 +22,12 @@ import ( "github.com/openziti/ziti/ziti/cmd/ziti/util" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) // newListCmd creates a command object for the "controller list" command -func newCreateCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateCmd(out io.Writer, errOut io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "create", Short: "creates various entities managed by the Ziti Edge Controller", @@ -38,16 +37,16 @@ func newCreateCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Com }, } - cmd.AddCommand(newCreateAuthenticatorCmd(f, out, errOut)) - cmd.AddCommand(newCreateCaCmd(f, out, errOut)) - cmd.AddCommand(newCreateConfigCmd(f, out, errOut)) - cmd.AddCommand(newCreateConfigTypeCmd(f, out, errOut)) - cmd.AddCommand(newCreateEdgeRouterCmd(f, out, errOut)) - cmd.AddCommand(newCreateEdgeRouterPolicyCmd(f, out, errOut)) - cmd.AddCommand(newCreateTerminatorCmd(f, out, errOut)) - cmd.AddCommand(newCreateIdentityCmd(f, out, errOut)) - cmd.AddCommand(newCreateServiceCmd(f, out, errOut)) - cmd.AddCommand(newCreateServiceEdgeRouterPolicyCmd(f, out, errOut)) + cmd.AddCommand(newCreateAuthenticatorCmd(out, errOut)) + cmd.AddCommand(newCreateCaCmd(out, errOut)) + cmd.AddCommand(newCreateConfigCmd(out, errOut)) + cmd.AddCommand(newCreateConfigTypeCmd(out, errOut)) + cmd.AddCommand(newCreateEdgeRouterCmd(out, errOut)) + cmd.AddCommand(newCreateEdgeRouterPolicyCmd(out, errOut)) + cmd.AddCommand(newCreateTerminatorCmd(out, errOut)) + cmd.AddCommand(newCreateIdentityCmd(out, errOut)) + cmd.AddCommand(newCreateServiceCmd(out, errOut)) + cmd.AddCommand(newCreateServiceEdgeRouterPolicyCmd(out, errOut)) cmd.AddCommand(newCreateServicePolicyCmd(out, errOut)) cmd.AddCommand(newCreatePostureCheckCmd(out, errOut)) diff --git a/ziti/cmd/ziti/cmd/edge/create_authenticator.go b/ziti/cmd/ziti/cmd/edge/create_authenticator.go index b7187d9e9..d96d0ca29 100644 --- a/ziti/cmd/ziti/cmd/edge/create_authenticator.go +++ b/ziti/cmd/ziti/cmd/edge/create_authenticator.go @@ -19,15 +19,14 @@ package edge import ( "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/spf13/cobra" "io" ) // newCreateAuthenticatorCmd creates the 'edge controller create authenticator' command -func newCreateAuthenticatorCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateAuthenticatorCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, OutputJSONResponse: false, } diff --git a/ziti/cmd/ziti/cmd/edge/create_ca.go b/ziti/cmd/ziti/cmd/edge/create_ca.go index 4fa634458..61f45b705 100644 --- a/ziti/cmd/ziti/cmd/edge/create_ca.go +++ b/ziti/cmd/ziti/cmd/edge/create_ca.go @@ -21,7 +21,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" "io" @@ -42,13 +41,12 @@ type createCaOptions struct { } // newCreateCaCmd creates the 'edge controller create ca local' command for the given entity type -func newCreateCaCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createCaOptions{ Options: api.Options{ CommonOptions: common.CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, tags: make(map[string]string), diff --git a/ziti/cmd/ziti/cmd/edge/create_config.go b/ziti/cmd/ziti/cmd/edge/create_config.go index daa6f6ad0..5e1874725 100644 --- a/ziti/cmd/ziti/cmd/edge/create_config.go +++ b/ziti/cmd/ziti/cmd/edge/create_config.go @@ -27,7 +27,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -38,10 +37,10 @@ type createConfigOptions struct { } // newCreateConfigCmd creates the 'edge controller create service-policy' command -func newCreateConfigCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateConfigCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createConfigOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/create_config_type.go b/ziti/cmd/ziti/cmd/edge/create_config_type.go index 4ab22ec38..50f7ed74d 100644 --- a/ziti/cmd/ziti/cmd/edge/create_config_type.go +++ b/ziti/cmd/ziti/cmd/edge/create_config_type.go @@ -27,7 +27,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -38,10 +37,10 @@ type createConfigTypeOptions struct { } // newCreateConfigTypeCmd creates the 'edge controller create service-policy' command -func newCreateConfigTypeCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateConfigTypeCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createConfigTypeOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/create_edge_router.go b/ziti/cmd/ziti/cmd/edge/create_edge_router.go index d3b1160e5..8a0b8343f 100644 --- a/ziti/cmd/ziti/cmd/edge/create_edge_router.go +++ b/ziti/cmd/ziti/cmd/edge/create_edge_router.go @@ -25,7 +25,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -41,10 +40,10 @@ type createEdgeRouterOptions struct { noTraversal bool } -func newCreateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateEdgeRouterCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createEdgeRouterOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go index 445a2a8f7..5e4723fdb 100644 --- a/ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge/create_edge_router_policy.go @@ -22,7 +22,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -35,10 +34,10 @@ type createEdgeRouterPolicyOptions struct { } // newCreateEdgeRouterPolicyCmd creates the 'edge controller create edge-router-policy' command -func newCreateEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createEdgeRouterPolicyOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/create_identity.go b/ziti/cmd/ziti/cmd/edge/create_identity.go index bc09c33a0..f0787538e 100644 --- a/ziti/cmd/ziti/cmd/edge/create_identity.go +++ b/ziti/cmd/ziti/cmd/edge/create_identity.go @@ -28,7 +28,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -48,11 +47,11 @@ type createIdentityOptions struct { } // newCreateIdentityCmd creates the 'edge controller create identity' command -func newCreateIdentityCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateIdentityCmd(out io.Writer, errOut io.Writer) *cobra.Command { newOptions := func() *createIdentityOptions { return &createIdentityOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } } diff --git a/ziti/cmd/ziti/cmd/edge/create_service.go b/ziti/cmd/ziti/cmd/edge/create_service.go index c7ffb0ddd..cc3b2a8c6 100644 --- a/ziti/cmd/ziti/cmd/edge/create_service.go +++ b/ziti/cmd/ziti/cmd/edge/create_service.go @@ -20,7 +20,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" "io" @@ -37,13 +36,12 @@ type createServiceOptions struct { } // newCreateServiceCmd creates the 'edge controller create service local' command for the given entity type -func newCreateServiceCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateServiceCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createServiceOptions{ Options: api.Options{ CommonOptions: common.CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, tags: make(map[string]string), diff --git a/ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go index 5e619357e..16dacfd16 100644 --- a/ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge/create_service_edge_router_policy.go @@ -22,7 +22,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -35,10 +34,10 @@ type createServiceEdgeRouterPolicyOptions struct { } // newCreateServiceEdgeRouterPolicyCmd creates the 'edge controller create service-edge-router-policy' command -func newCreateServiceEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateServiceEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createServiceEdgeRouterPolicyOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/create_terminator.go b/ziti/cmd/ziti/cmd/edge/create_terminator.go index e920d6d80..d01129a26 100644 --- a/ziti/cmd/ziti/cmd/edge/create_terminator.go +++ b/ziti/cmd/ziti/cmd/edge/create_terminator.go @@ -23,7 +23,6 @@ import ( "github.com/openziti/foundation/util/stringz" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" "io" @@ -39,13 +38,12 @@ type createTerminatorOptions struct { } // newCreateTerminatorCmd creates the 'edge controller create Terminator local' command for the given entity type -func newCreateTerminatorCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateTerminatorCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &createTerminatorOptions{ Options: api.Options{ CommonOptions: common.CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/edge/list.go b/ziti/cmd/ziti/cmd/edge/list.go index 491e94517..feeb66949 100644 --- a/ziti/cmd/ziti/cmd/edge/list.go +++ b/ziti/cmd/ziti/cmd/edge/list.go @@ -41,9 +41,9 @@ import ( // newListCmd creates a command object for the "controller list" command func newListCmd(out io.Writer, errOut io.Writer) *cobra.Command { cmd := &cobra.Command{ - Use: "list", - Short: "Lists various entities managed by the Ziti Edge Controller", - Long: "Lists various entities managed by the Ziti Edge Controller", + Use: "list", + Short: "Lists various entities managed by the Ziti Edge Controller", + Aliases: []string{"ls"}, Run: func(cmd *cobra.Command, args []string) { err := cmd.Help() cmdhelper.CheckErr(err) diff --git a/ziti/cmd/ziti/cmd/edge/root.go b/ziti/cmd/ziti/cmd/edge/root.go index 662b4a835..208917fdf 100644 --- a/ziti/cmd/ziti/cmd/edge/root.go +++ b/ziti/cmd/ziti/cmd/edge/root.go @@ -21,7 +21,6 @@ import ( "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) @@ -29,20 +28,20 @@ import ( var ExtraEdgeCommands []func(p common.OptionsProvider) *cobra.Command // NewCmdEdge creates a command object for the "controller" command -func NewCmdEdge(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdEdge(out io.Writer, errOut io.Writer) *cobra.Command { cmd := util.NewEmptyParentCmd("edge", "Interact with Ziti Edge Components") - populateEdgeCommands(f, out, errOut, cmd) + populateEdgeCommands(out, errOut, cmd) return cmd } -func populateEdgeCommands(f cmdutil.Factory, out io.Writer, errOut io.Writer, cmd *cobra.Command) *cobra.Command { - cmd.AddCommand(newCreateCmd(f, out, errOut)) +func populateEdgeCommands(out io.Writer, errOut io.Writer, cmd *cobra.Command) *cobra.Command { + cmd.AddCommand(newCreateCmd(out, errOut)) cmd.AddCommand(newDeleteCmd(out, errOut)) cmd.AddCommand(newLoginCmd(out, errOut)) cmd.AddCommand(newLogoutCmd(out, errOut)) cmd.AddCommand(newUseCmd(out, errOut)) cmd.AddCommand(newListCmd(out, errOut)) - cmd.AddCommand(newUpdateCmd(f, out, errOut)) + cmd.AddCommand(newUpdateCmd(out, errOut)) cmd.AddCommand(newVersionCmd(out, errOut)) cmd.AddCommand(newPolicyAdivsorCmd(out, errOut)) cmd.AddCommand(newVerifyCmd(out, errOut)) diff --git a/ziti/cmd/ziti/cmd/edge/update.go b/ziti/cmd/ziti/cmd/edge/update.go index 743964ad0..0ccf3863e 100644 --- a/ziti/cmd/ziti/cmd/edge/update.go +++ b/ziti/cmd/ziti/cmd/edge/update.go @@ -19,7 +19,6 @@ package edge import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" @@ -28,7 +27,7 @@ import ( ) // newUpdateCmd creates a command object for the "controller update" command -func newUpdateCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateCmd(out io.Writer, errOut io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "update", Short: "updates various entities managed by the Ziti Edge Controller", @@ -39,17 +38,17 @@ func newUpdateCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Com }, } - cmd.AddCommand(newUpdateAuthenticatorCmd(f, out, errOut)) - cmd.AddCommand(newUpdateConfigCmd(f, out, errOut)) - cmd.AddCommand(newUpdateCaCmd(f, out, errOut)) - cmd.AddCommand(newUpdateEdgeRouterCmd(f, out, errOut)) - cmd.AddCommand(newUpdateEdgeRouterPolicyCmd(f, out, errOut)) - cmd.AddCommand(newUpdateIdentityCmd(f, out, errOut)) - cmd.AddCommand(newUpdateIdentityConfigsCmd(f, out, errOut)) - cmd.AddCommand(newUpdateServiceCmd(f, out, errOut)) - cmd.AddCommand(newUpdateServicePolicyCmd(f, out, errOut)) - cmd.AddCommand(newUpdateServiceEdgeRouterPolicyCmd(f, out, errOut)) - cmd.AddCommand(newUpdateTerminatorCmd(f, out, errOut)) + cmd.AddCommand(newUpdateAuthenticatorCmd(out, errOut)) + cmd.AddCommand(newUpdateConfigCmd(out, errOut)) + cmd.AddCommand(newUpdateCaCmd(out, errOut)) + cmd.AddCommand(newUpdateEdgeRouterCmd(out, errOut)) + cmd.AddCommand(newUpdateEdgeRouterPolicyCmd(out, errOut)) + cmd.AddCommand(newUpdateIdentityCmd(out, errOut)) + cmd.AddCommand(newUpdateIdentityConfigsCmd(out, errOut)) + cmd.AddCommand(newUpdateServiceCmd(out, errOut)) + cmd.AddCommand(newUpdateServicePolicyCmd(out, errOut)) + cmd.AddCommand(newUpdateServiceEdgeRouterPolicyCmd(out, errOut)) + cmd.AddCommand(newUpdateTerminatorCmd(out, errOut)) cmd.AddCommand(newUpdatePostureCheckCmd(out, errOut)) return cmd diff --git a/ziti/cmd/ziti/cmd/edge/update_authenticator.go b/ziti/cmd/ziti/cmd/edge/update_authenticator.go index 59d0379ce..8c7e5fe9d 100644 --- a/ziti/cmd/ziti/cmd/edge/update_authenticator.go +++ b/ziti/cmd/ziti/cmd/edge/update_authenticator.go @@ -19,15 +19,14 @@ package edge import ( "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/spf13/cobra" "io" ) // newUpdateAuthenticatorCmd creates the 'edge controller update authenticator' command -func newUpdateAuthenticatorCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateAuthenticatorCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, OutputJSONResponse: false, } diff --git a/ziti/cmd/ziti/cmd/edge/update_ca.go b/ziti/cmd/ziti/cmd/edge/update_ca.go index 94bc27d2c..e2ad20bea 100644 --- a/ziti/cmd/ziti/cmd/edge/update_ca.go +++ b/ziti/cmd/ziti/cmd/edge/update_ca.go @@ -22,7 +22,6 @@ import ( "github.com/openziti/edge/rest_model" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/pkg/errors" @@ -47,10 +46,10 @@ type updateCaOptions struct { } // newUpdateAuthenticatorCmd creates the 'edge controller update authenticator' command -func newUpdateCaCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := updateCaOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, OutputJSONResponse: false, }, verify: false, diff --git a/ziti/cmd/ziti/cmd/edge/update_config.go b/ziti/cmd/ziti/cmd/edge/update_config.go index 44697adae..fd8dbc08e 100644 --- a/ziti/cmd/ziti/cmd/edge/update_config.go +++ b/ziti/cmd/ziti/cmd/edge/update_config.go @@ -27,7 +27,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -40,10 +39,10 @@ type updateConfigOptions struct { } // newUpdateConfigCmd updates the 'edge controller update service-policy' command -func newUpdateConfigCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateConfigCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateConfigOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_edge_router.go b/ziti/cmd/ziti/cmd/edge/update_edge_router.go index fe0ce7ae1..21399949a 100644 --- a/ziti/cmd/ziti/cmd/edge/update_edge_router.go +++ b/ziti/cmd/ziti/cmd/edge/update_edge_router.go @@ -26,7 +26,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -43,10 +42,10 @@ type updateEdgeRouterOptions struct { noTraversal bool } -func newUpdateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateEdgeRouterCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateEdgeRouterOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go index 6812e92cd..ddf551df9 100644 --- a/ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge/update_edge_router_policy.go @@ -25,7 +25,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -37,10 +36,10 @@ type updateEdgeRouterPolicyOptions struct { identityRoles []string } -func newUpdateEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateEdgeRouterPolicyOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_identity.go b/ziti/cmd/ziti/cmd/edge/update_identity.go index f45e4c04d..5e3924c36 100644 --- a/ziti/cmd/ziti/cmd/edge/update_identity.go +++ b/ziti/cmd/ziti/cmd/edge/update_identity.go @@ -28,7 +28,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -45,10 +44,10 @@ type updateIdentityOptions struct { appData map[string]string } -func newUpdateIdentityCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateIdentityCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateIdentityOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_identity_configs.go b/ziti/cmd/ziti/cmd/edge/update_identity_configs.go index 345ddce9a..c8c82f70a 100644 --- a/ziti/cmd/ziti/cmd/edge/update_identity_configs.go +++ b/ziti/cmd/ziti/cmd/edge/update_identity_configs.go @@ -23,7 +23,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -33,10 +32,10 @@ type updateIdentityConfigsOptions struct { remove bool } -func newUpdateIdentityConfigsCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateIdentityConfigsCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateIdentityConfigsOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_service.go b/ziti/cmd/ziti/cmd/edge/update_service.go index 12c4eb4d0..3ff02b769 100644 --- a/ziti/cmd/ziti/cmd/edge/update_service.go +++ b/ziti/cmd/ziti/cmd/edge/update_service.go @@ -25,7 +25,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -39,10 +38,10 @@ type updateServiceOptions struct { configs []string } -func newUpdateServiceCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateServiceCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateServiceOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go index a2376dd94..8c38b0758 100644 --- a/ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge/update_service_edge_router_policy.go @@ -25,7 +25,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -37,10 +36,10 @@ type updateServiceEdgeRouterPolicyOptions struct { serviceRoles []string } -func newUpdateServiceEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateServiceEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateServiceEdgeRouterPolicyOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_service_policy.go b/ziti/cmd/ziti/cmd/edge/update_service_policy.go index 2190dd72c..1551587ba 100644 --- a/ziti/cmd/ziti/cmd/edge/update_service_policy.go +++ b/ziti/cmd/ziti/cmd/edge/update_service_policy.go @@ -25,7 +25,6 @@ import ( "github.com/Jeffail/gabs" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) @@ -38,10 +37,10 @@ type updateServicePolicyOptions struct { postureCheckRoles []string } -func newUpdateServicePolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateServicePolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateServicePolicyOptions{ Options: api.Options{ - CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + CommonOptions: common.CommonOptions{Out: out, Err: errOut}, }, } diff --git a/ziti/cmd/ziti/cmd/edge/update_terminator.go b/ziti/cmd/ziti/cmd/edge/update_terminator.go index 380b3b604..acebf3b97 100644 --- a/ziti/cmd/ziti/cmd/edge/update_terminator.go +++ b/ziti/cmd/ziti/cmd/edge/update_terminator.go @@ -23,7 +23,6 @@ import ( "github.com/openziti/foundation/util/stringz" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" errors2 "github.com/pkg/errors" "github.com/spf13/cobra" @@ -40,13 +39,12 @@ type updateTerminatorOptions struct { precedence string } -func newUpdateTerminatorCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newUpdateTerminatorCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &updateTerminatorOptions{ Options: api.Options{ CommonOptions: common.CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/execute.go b/ziti/cmd/ziti/cmd/execute.go index 99424956e..821ce55bc 100644 --- a/ziti/cmd/ziti/cmd/execute.go +++ b/ziti/cmd/ziti/cmd/execute.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" ) @@ -47,12 +46,11 @@ var ( ) // NewCmdExecute Executes a command object for the "Execute" command -func NewCmdExecute(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdExecute(out io.Writer, errOut io.Writer) *cobra.Command { options := &ExecuteOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdExecute(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Co }, } - cmd.AddCommand(NewCmdExecuteController(f, out, errOut)) + cmd.AddCommand(NewCmdExecuteController(out, errOut)) options.addExecuteFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/execute_controller.go b/ziti/cmd/ziti/cmd/execute_controller.go index 868c414e5..40455ff62 100644 --- a/ziti/cmd/ziti/cmd/execute_controller.go +++ b/ziti/cmd/ziti/cmd/execute_controller.go @@ -22,7 +22,6 @@ import ( "github.com/spf13/cobra" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -50,13 +49,12 @@ type ExecuteControllerOptions struct { } // NewCmdExecuteController creates a command object for the "create" command -func NewCmdExecuteController(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdExecuteController(out io.Writer, errOut io.Writer) *cobra.Command { options := &ExecuteControllerOptions{ ExecuteOptions: ExecuteOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -77,7 +75,7 @@ func NewCmdExecuteController(f cmdutil.Factory, out io.Writer, errOut io.Writer) cmd.PersistentFlags().BoolVarP(&cliAgentEnabled, "cliagent", "a", false, "Enable CLI Agent (use in dev only)") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/fabric/list.go b/ziti/cmd/ziti/cmd/fabric/list.go index 2e69d724a..9ecb3faf1 100644 --- a/ziti/cmd/ziti/cmd/fabric/list.go +++ b/ziti/cmd/ziti/cmd/fabric/list.go @@ -33,8 +33,9 @@ import ( // newListCmd creates a command object for the "controller list" command func newListCmd(p common.OptionsProvider) *cobra.Command { listCmd := &cobra.Command{ - Use: "list", - Short: "Lists various entities managed by the Ziti Controller", + Use: "list", + Short: "Lists various entities managed by the Ziti Controller", + Aliases: []string{"ls"}, Run: func(cmd *cobra.Command, args []string) { err := cmd.Help() cmdhelper.CheckErr(err) diff --git a/ziti/cmd/ziti/cmd/factory/factory.go b/ziti/cmd/ziti/cmd/factory/factory.go deleted file mode 100644 index 1b790df8d..000000000 --- a/ziti/cmd/ziti/cmd/factory/factory.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright NetFoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/table" - "io" - "os" -) - -type Factory interface { - CreateTable(out io.Writer) table.Table -} - -type factory struct { - Batch bool - - impersonateUser string -} - -// NewFactory creates a factory with the default Kubernetes resources defined -// if optionalClientConfig is nil, then flags will be bound to a new clientcmd.ClientConfig. -// if optionalClientConfig is not nil, then this factory will make use of it. -func NewFactory() Factory { - return &factory{} -} - -func (f *factory) SetBatch(batch bool) { - f.Batch = batch -} - -// ImpersonateUser returns a new factory impersonating the given user -func (f *factory) ImpersonateUser(user string) Factory { - copy := *f - copy.impersonateUser = user - return © -} - -func (f *factory) CreateTable(out io.Writer) table.Table { - return table.CreateTable(os.Stdout) -} diff --git a/ziti/cmd/ziti/cmd/init.go b/ziti/cmd/ziti/cmd/init.go index 4a3143433..bb17f1fe4 100644 --- a/ziti/cmd/ziti/cmd/init.go +++ b/ziti/cmd/ziti/cmd/init.go @@ -17,7 +17,6 @@ package cmd import ( - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ var ( ) // NewCmdInit creates a command object for the generic "init" action -func NewCmdInit(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInit(out io.Writer, errOut io.Writer) *cobra.Command { options := &InitOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -68,7 +66,7 @@ func NewCmdInit(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Comma }, } - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) options.addInitFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/install.go b/ziti/cmd/ziti/cmd/install.go index 33769e9e9..39c0b810c 100644 --- a/ziti/cmd/ziti/cmd/install.go +++ b/ziti/cmd/ziti/cmd/install.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" @@ -42,12 +41,11 @@ var ( ) // NewCmdInstall creates the command -func NewCmdInstall(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstall(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallOptions{ CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -66,20 +64,20 @@ func NewCmdInstall(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Co SuggestFor: []string{"up"}, } - cmd.AddCommand(NewCmdInstallZitiALL(f, out, errOut)) + cmd.AddCommand(NewCmdInstallZitiALL(out, errOut)) - cmd.AddCommand(NewCmdInstallZitiController(f, out, errOut)) - cmd.AddCommand(NewCmdInstallZitiFabric(f, out, errOut)) - cmd.AddCommand(NewCmdInstallZitiRouter(f, out, errOut)) - cmd.AddCommand(NewCmdInstallZitiTunnel(f, out, errOut)) - cmd.AddCommand(NewCmdInstallZitiEdgeTunnel(f, out, errOut)) - cmd.AddCommand(NewCmdInstallZitiProxC(f, out, errOut)) + cmd.AddCommand(NewCmdInstallZitiController(out, errOut)) + cmd.AddCommand(NewCmdInstallZitiFabric(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(f, out, errOut)) // Disable/hide this for now + // cmd.AddCommand(NewCmdInstallAnsible(out, errOut)) // Disable/hide this for now - cmd.AddCommand(NewCmdInstallTerraformProviderEdgeController(f, out, errOut)) + cmd.AddCommand(NewCmdInstallTerraformProviderEdgeController(out, errOut)) - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ansible.go b/ziti/cmd/ziti/cmd/install_ansible.go index 5ad2a8825..ec976c9e0 100644 --- a/ziti/cmd/ziti/cmd/install_ansible.go +++ b/ziti/cmd/ziti/cmd/install_ansible.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/ziti/ansible" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" @@ -50,13 +49,12 @@ type InstallAnsibleOptions struct { var installOptions = &ansible.InstallOptions{} // NewCmdInstallAnsible defines the command -func NewCmdInstallAnsible(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallAnsible(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallAnsibleOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go b/ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go index 62310eacd..8282ca71f 100644 --- a/ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go +++ b/ziti/cmd/ziti/cmd/install_terraform_provider_edge_controller.go @@ -19,12 +19,11 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + "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/blang/semver" "github.com/spf13/cobra" ) @@ -48,13 +47,12 @@ type InstallTerraformProviderEdgeControllerOptions struct { } // NewCmdInstallTerraformProviderEdgeController defines the command -func NewCmdInstallTerraformProviderEdgeController(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallTerraformProviderEdgeController(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallTerraformProviderEdgeControllerOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/install_ziti_ALL.go b/ziti/cmd/ziti/cmd/install_ziti_ALL.go index ac8f12e52..c5bf2ac34 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_ALL.go +++ b/ziti/cmd/ziti/cmd/install_ziti_ALL.go @@ -21,7 +21,6 @@ import ( "github.com/blang/semver" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -48,13 +47,12 @@ type InstallZitiALLOptions struct { } // NewCmdInstallZitiALL defines the command -func NewCmdInstallZitiALL(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiALL(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiALLOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiALL(f cmdutil.Factory, out io.Writer, errOut io.Writer) *c }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ziti_controller.go b/ziti/cmd/ziti/cmd/install_ziti_controller.go index 72097a1b2..4bd28fd36 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_controller.go +++ b/ziti/cmd/ziti/cmd/install_ziti_controller.go @@ -19,13 +19,12 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + "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/openziti/ziti/common/version" - "github.com/blang/semver" "github.com/spf13/cobra" ) @@ -48,13 +47,12 @@ type InstallZitiControllerOptions struct { } // NewCmdInstallZitiController defines the command -func NewCmdInstallZitiController(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiController(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiControllerOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiController(f cmdutil.Factory, out io.Writer, errOut io.Wri }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go b/ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go index e5eac248d..682771e28 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go +++ b/ziti/cmd/ziti/cmd/install_ziti_edge_tunnel.go @@ -21,7 +21,6 @@ import ( "github.com/blang/semver" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -48,13 +47,12 @@ type InstallZitiEdgeTunnelOptions struct { } // NewCmdInstallZitiEdgeTunnel defines the command -func NewCmdInstallZitiEdgeTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiEdgeTunnelOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiEdgeTunnel(f cmdutil.Factory, out io.Writer, errOut io.Wri }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ziti_fabric.go b/ziti/cmd/ziti/cmd/install_ziti_fabric.go index 480351c32..9831fb01c 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_fabric.go +++ b/ziti/cmd/ziti/cmd/install_ziti_fabric.go @@ -19,13 +19,12 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + "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/openziti/ziti/common/version" - "github.com/blang/semver" "github.com/spf13/cobra" ) @@ -48,13 +47,12 @@ type InstallZitiFabricOptions struct { } // NewCmdInstallZitiFabric defines the command -func NewCmdInstallZitiFabric(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiFabric(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiFabricOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiFabric(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ziti_prox_c.go b/ziti/cmd/ziti/cmd/install_ziti_prox_c.go index 3df9bb3ef..ec3e593f8 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_prox_c.go +++ b/ziti/cmd/ziti/cmd/install_ziti_prox_c.go @@ -21,7 +21,6 @@ import ( "github.com/blang/semver" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -48,13 +47,12 @@ type InstallZitiProxCOptions struct { } // NewCmdInstallZitiProxC defines the command -func NewCmdInstallZitiProxC(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiProxCOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiProxC(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ziti_router.go b/ziti/cmd/ziti/cmd/install_ziti_router.go index 39f15a26a..a54a6d3ee 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_router.go +++ b/ziti/cmd/ziti/cmd/install_ziti_router.go @@ -19,13 +19,12 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + "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/openziti/ziti/common/version" - "github.com/blang/semver" "github.com/spf13/cobra" ) @@ -48,13 +47,12 @@ type InstallZitiRouterOptions struct { } // NewCmdInstallZitiRouter defines the command -func NewCmdInstallZitiRouter(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiRouterOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiRouter(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/install_ziti_tunnel.go b/ziti/cmd/ziti/cmd/install_ziti_tunnel.go index 7098dbf2e..0509a3635 100644 --- a/ziti/cmd/ziti/cmd/install_ziti_tunnel.go +++ b/ziti/cmd/ziti/cmd/install_ziti_tunnel.go @@ -19,13 +19,12 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + "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/openziti/ziti/common/version" - "github.com/blang/semver" "github.com/spf13/cobra" ) @@ -48,13 +47,12 @@ type InstallZitiTunnelOptions struct { } // NewCmdInstallZitiTunnel defines the command -func NewCmdInstallZitiTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdInstallZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { options := &InstallZitiTunnelOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -73,7 +71,7 @@ func NewCmdInstallZitiTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to install") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/create.go b/ziti/cmd/ziti/cmd/lets_encrypt/create.go index 7ac4b83a6..ba1c9c9c0 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/create.go +++ b/ziti/cmd/ziti/cmd/lets_encrypt/create.go @@ -21,7 +21,6 @@ import ( "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" @@ -51,7 +50,7 @@ func (u *AcmeUser) GetPrivateKey() crypto.PrivateKey { } // newCreateCmd creates the 'edge controller create ca local' command for the given entity type -func newCreateCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newCreateCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &leOptions{} cmd := &cobra.Command{ diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/list.go b/ziti/cmd/ziti/cmd/lets_encrypt/list.go index 75d9ac2c4..9db17f5ad 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/list.go +++ b/ziti/cmd/ziti/cmd/lets_encrypt/list.go @@ -26,13 +26,12 @@ import ( "strings" "github.com/go-acme/lego/v4/certcrypto" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) // newListCmd creates a command object for the "controller list" command -func newListCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newListCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &leOptions{} cmd := &cobra.Command{ diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/renew.go b/ziti/cmd/ziti/cmd/lets_encrypt/renew.go index e069dbaac..83b470d43 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/renew.go +++ b/ziti/cmd/ziti/cmd/lets_encrypt/renew.go @@ -22,7 +22,6 @@ import ( "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "github.com/spf13/cobra" @@ -38,7 +37,7 @@ const ( ) // newListCmd creates a command object for the "controller list" command -func newRenewCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newRenewCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &leOptions{} cmd := &cobra.Command{ diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/revoke.go b/ziti/cmd/ziti/cmd/lets_encrypt/revoke.go index 8be0d9fe4..588377a78 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/revoke.go +++ b/ziti/cmd/ziti/cmd/lets_encrypt/revoke.go @@ -20,13 +20,12 @@ import ( "github.com/openziti/ziti/ziti/cmd/ziti/internal/log" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" ) // newListCmd creates a command object for the "controller list" command -func newRevokeCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func newRevokeCmd(out io.Writer, errOut io.Writer) *cobra.Command { options := &leOptions{} cmd := &cobra.Command{ diff --git a/ziti/cmd/ziti/cmd/lets_encrypt/root.go b/ziti/cmd/ziti/cmd/lets_encrypt/root.go index 71658b03b..fd51e911a 100644 --- a/ziti/cmd/ziti/cmd/lets_encrypt/root.go +++ b/ziti/cmd/ziti/cmd/lets_encrypt/root.go @@ -19,15 +19,14 @@ package lets_encrypt import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/cobra" ) // NewCmdLE creates a command object for the "le" sub-command of the "pki" cmd -func NewCmdLE(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdLE(out io.Writer, errOut io.Writer) *cobra.Command { cmd := util.NewEmptyParentCmd("le", "Interact with Let's Encrypt infra") - populateLECommands(f, out, errOut, cmd) + populateLECommands(out, errOut, cmd) return cmd } @@ -58,11 +57,10 @@ type leOptions struct { // type leFlags struct { // } -func populateLECommands(f cmdutil.Factory, out io.Writer, errOut io.Writer, cmd *cobra.Command) *cobra.Command { - - cmd.AddCommand(newCreateCmd(f, out, errOut)) - cmd.AddCommand(newRevokeCmd(f, out, errOut)) - cmd.AddCommand(newRenewCmd(f, out, errOut)) - cmd.AddCommand(newListCmd(f, out, errOut)) +func populateLECommands(out io.Writer, errOut io.Writer, cmd *cobra.Command) *cobra.Command { + cmd.AddCommand(newCreateCmd(out, errOut)) + cmd.AddCommand(newRevokeCmd(out, errOut)) + cmd.AddCommand(newRenewCmd(out, errOut)) + cmd.AddCommand(newListCmd(out, errOut)) return cmd } diff --git a/ziti/cmd/ziti/cmd/log_filter.go b/ziti/cmd/ziti/cmd/log_filter.go index 517b8124b..59457b8f0 100644 --- a/ziti/cmd/ziti/cmd/log_filter.go +++ b/ziti/cmd/ziti/cmd/log_filter.go @@ -18,14 +18,13 @@ package cmd import ( "github.com/michaelquigley/pfxlog" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" ) -// PsOptions contains the command line options +// AgentOptions contains the command line options type LogFormatOptions struct { CommonOptions @@ -34,12 +33,11 @@ type LogFormatOptions struct { } // NewCmdLogFormat a command object for the "log-format" command -func NewCmdLogFormat(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdLogFormat(out io.Writer, errOut io.Writer) *cobra.Command { options := &LogFormatOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } diff --git a/ziti/cmd/ziti/cmd/ping.go b/ziti/cmd/ziti/cmd/ping.go index 756da9ca9..4bb17d9cb 100644 --- a/ziti/cmd/ziti/cmd/ping.go +++ b/ziti/cmd/ziti/cmd/ping.go @@ -24,7 +24,6 @@ import ( "path/filepath" "github.com/openziti/ziti/ziti/ansible" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" // "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" @@ -38,12 +37,11 @@ type PingOptions struct { var pingOptions = &ansible.Options{} // NewCmdPing creates the command -func NewCmdPing(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPing(out io.Writer, errOut io.Writer) *cobra.Command { options := &PingOptions{ CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } diff --git a/ziti/cmd/ziti/cmd/pki.go b/ziti/cmd/ziti/cmd/pki.go index 83c928515..27c8f023c 100644 --- a/ziti/cmd/ziti/cmd/pki.go +++ b/ziti/cmd/ziti/cmd/pki.go @@ -20,7 +20,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -70,12 +69,11 @@ Provide the components needed to manage a Ziti PKI. ) // NewCmdPKI PKIs a command object for the "PKI" command -func NewCmdPKI(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKI(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -91,9 +89,9 @@ func NewCmdPKI(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Comman }, } - cmd.AddCommand(NewCmdPKICreate(f, out, errOut)) + cmd.AddCommand(NewCmdPKICreate(out, errOut)) - cmd.AddCommand(lets_encrypt.NewCmdLE(f, out, errOut)) + cmd.AddCommand(lets_encrypt.NewCmdLE(out, errOut)) return cmd } diff --git a/ziti/cmd/ziti/cmd/pki_create.go b/ziti/cmd/ziti/cmd/pki_create.go index 110a166dd..43a93df28 100644 --- a/ziti/cmd/ziti/cmd/pki_create.go +++ b/ziti/cmd/ziti/cmd/pki_create.go @@ -29,7 +29,6 @@ import ( "strings" "time" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/util" "github.com/spf13/viper" @@ -41,13 +40,12 @@ type PKICreateOptions struct { } // NewCmdPKICreate creates a command object for the "create" command -func NewCmdPKICreate(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreate(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } @@ -62,12 +60,12 @@ func NewCmdPKICreate(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra. }, } - cmd.AddCommand(NewCmdPKICreateCA(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateIntermediate(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateKey(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateServer(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateClient(f, out, errOut)) - cmd.AddCommand(NewCmdPKICreateCSR(f, out, errOut)) + cmd.AddCommand(NewCmdPKICreateCA(out, errOut)) + cmd.AddCommand(NewCmdPKICreateIntermediate(out, errOut)) + cmd.AddCommand(NewCmdPKICreateKey(out, errOut)) + cmd.AddCommand(NewCmdPKICreateServer(out, errOut)) + cmd.AddCommand(NewCmdPKICreateClient(out, errOut)) + cmd.AddCommand(NewCmdPKICreateCSR(out, errOut)) options.addPKICreateFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/pki_create_ca.go b/ziti/cmd/ziti/cmd/pki_create_ca.go index 5a5b29b98..a91991627 100644 --- a/ziti/cmd/ziti/cmd/pki_create_ca.go +++ b/ziti/cmd/ziti/cmd/pki_create_ca.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -35,14 +34,13 @@ type PKICreateCAOptions struct { } // NewCmdPKICreateCA creates a command object for the "create" command -func NewCmdPKICreateCA(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreateCA(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateCAOptions{ PKICreateOptions: PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, }, diff --git a/ziti/cmd/ziti/cmd/pki_create_client.go b/ziti/cmd/ziti/cmd/pki_create_client.go index 521f53217..8b47cf8b4 100644 --- a/ziti/cmd/ziti/cmd/pki_create_client.go +++ b/ziti/cmd/ziti/cmd/pki_create_client.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -35,14 +34,13 @@ type PKICreateClientOptions struct { } // NewCmdPKICreateClient creates a command object for the "create" command -func NewCmdPKICreateClient(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreateClient(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateClientOptions{ PKICreateOptions: PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, }, diff --git a/ziti/cmd/ziti/cmd/pki_create_csr.go b/ziti/cmd/ziti/cmd/pki_create_csr.go index fe2b2677f..e8c68412a 100644 --- a/ziti/cmd/ziti/cmd/pki_create_csr.go +++ b/ziti/cmd/ziti/cmd/pki_create_csr.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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/pki" @@ -34,14 +33,13 @@ type PKICreateCSROptions struct { } // NewCmdPKICreateCSR creates a command object for the "create" command -func NewCmdPKICreateCSR(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreateCSR(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateCSROptions{ PKICreateOptions: PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, }, diff --git a/ziti/cmd/ziti/cmd/pki_create_intermediate.go b/ziti/cmd/ziti/cmd/pki_create_intermediate.go index 6fec50c7d..4b64c1fcb 100644 --- a/ziti/cmd/ziti/cmd/pki_create_intermediate.go +++ b/ziti/cmd/ziti/cmd/pki_create_intermediate.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -35,14 +34,13 @@ type PKICreateIntermediateOptions struct { } // NewCmdPKICreateIntermediate creates a command object for the "create" command -func NewCmdPKICreateIntermediate(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreateIntermediate(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateIntermediateOptions{ PKICreateOptions: PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, }, diff --git a/ziti/cmd/ziti/cmd/pki_create_key.go b/ziti/cmd/ziti/cmd/pki_create_key.go index a895847c2..90e5a1522 100644 --- a/ziti/cmd/ziti/cmd/pki_create_key.go +++ b/ziti/cmd/ziti/cmd/pki_create_key.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -35,14 +34,13 @@ type PKICreateKeyOptions struct { } // NewCmdPKICreateKey creates a command object for the "create" command -func NewCmdPKICreateKey(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreateKey(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateKeyOptions{ PKICreateOptions: PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, }, diff --git a/ziti/cmd/ziti/cmd/pki_create_server.go b/ziti/cmd/ziti/cmd/pki_create_server.go index 1258acb7d..879f18ca1 100644 --- a/ziti/cmd/ziti/cmd/pki_create_server.go +++ b/ziti/cmd/ziti/cmd/pki_create_server.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -35,14 +34,13 @@ type PKICreateServerOptions struct { } // NewCmdPKICreateServer creates a command object for the "create" command -func NewCmdPKICreateServer(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPKICreateServer(out io.Writer, errOut io.Writer) *cobra.Command { options := &PKICreateServerOptions{ PKICreateOptions: PKICreateOptions{ PKIOptions: PKIOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, }, diff --git a/ziti/cmd/ziti/cmd/playbook.go b/ziti/cmd/ziti/cmd/playbook.go index ea70e5c62..3e7b4d3d2 100644 --- a/ziti/cmd/ziti/cmd/playbook.go +++ b/ziti/cmd/ziti/cmd/playbook.go @@ -21,7 +21,6 @@ import ( "io" "github.com/openziti/ziti/ziti/ansible" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/provisioner" @@ -40,12 +39,11 @@ type PlaybookOptions struct { var playbookOptions = &ansible.Options{} var po = &provisioner.Options{} -func NewCmdPlaybook(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdPlaybook(out io.Writer, errOut io.Writer) *cobra.Command { options := &PlaybookOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -111,7 +109,7 @@ the user "root" and run in verbose mode, do this: cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) cmd.Flags().StringVarP(&playbookOptions.SSHConfigFile, "ssh-config-file", "s", "", "Path to ssh config file to use.") diff --git a/ziti/cmd/ziti/cmd/ps.go b/ziti/cmd/ziti/cmd/ps.go index f4a75a29a..4367d8ebe 100644 --- a/ziti/cmd/ziti/cmd/ps.go +++ b/ziti/cmd/ziti/cmd/ps.go @@ -19,75 +19,61 @@ 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" - "io" "os" "regexp" "strconv" "strings" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" - "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/openziti/ziti/ziti/goprocess" ) -// PsOptions contains the command line options -type PsOptions struct { - CommonOptions - - Flags PsFlags +type PsAction struct { + agentcli.AgentOptions } -type PsFlags struct { - Pid string -} - -var ( - psLong = templates.LongDesc(` - Show information about currently running Ziti preocesses. - `) -) - // NewCmdPs Pss a command object for the "Ps" command -func NewCmdPs(out io.Writer, errOut io.Writer) *cobra.Command { - options := &PsOptions{ - CommonOptions: CommonOptions{ - Out: out, - Err: errOut, +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: psLong, + Long: "Show information about currently running Ziti preocesses", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } - cmd.AddCommand(NewCmdPsGet(out, errOut)) - cmd.AddCommand(NewCmdPsGoversion(out, errOut)) - cmd.AddCommand(NewCmdPsGc(out, errOut)) - cmd.AddCommand(NewCmdPsSetgc(out, errOut)) - cmd.AddCommand(NewCmdPsStack(out, errOut)) - cmd.AddCommand(NewCmdPsMemstats(out, errOut)) - cmd.AddCommand(NewCmdPsStats(out, errOut)) - cmd.AddCommand(NewCmdPsPprofHeap(out, errOut)) - cmd.AddCommand(NewCmdPsPprofCpu(out, errOut)) - cmd.AddCommand(NewCmdPsTrace(out, errOut)) - cmd.AddCommand(NewCmdPsSetLogLevel(out, errOut)) - cmd.AddCommand(NewCmdPsSetChannelLogLevel(out, errOut)) - cmd.AddCommand(NewCmdPsClearChannelLogLevel(out, errOut)) + 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 (o *PsOptions) Run() error { +func (self *PsAction) Run() error { fmt.Println("ps is running") ps := goprocess.FindAll() diff --git a/ziti/cmd/ziti/cmd/uninstall.go b/ziti/cmd/ziti/cmd/uninstall.go index a56f10f2e..7aa4913df 100644 --- a/ziti/cmd/ziti/cmd/uninstall.go +++ b/ziti/cmd/ziti/cmd/uninstall.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" @@ -42,12 +41,11 @@ var ( ) // NewCmdUnInstall creates the command -func NewCmdUnInstall(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstall(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallOptions{ CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -66,12 +64,12 @@ func NewCmdUnInstall(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra. SuggestFor: []string{"up"}, } - cmd.AddCommand(NewCmdUnInstallZitiController(f, out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiFabric(f, out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiRouter(f, out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiTunnel(f, out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiEdgeTunnel(f, out, errOut)) - cmd.AddCommand(NewCmdUnInstallZitiProxC(f, out, errOut)) + cmd.AddCommand(NewCmdUnInstallZitiController(out, errOut)) + cmd.AddCommand(NewCmdUnInstallZitiFabric(out, errOut)) + cmd.AddCommand(NewCmdUnInstallZitiRouter(out, errOut)) + cmd.AddCommand(NewCmdUnInstallZitiTunnel(out, errOut)) + cmd.AddCommand(NewCmdUnInstallZitiEdgeTunnel(out, errOut)) + cmd.AddCommand(NewCmdUnInstallZitiProxC(out, errOut)) return cmd } diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_controller.go b/ziti/cmd/ziti/cmd/uninstall_ziti_controller.go index 129d1fed8..517bedea6 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_controller.go +++ b/ziti/cmd/ziti/cmd/uninstall_ziti_controller.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -45,13 +44,12 @@ type UnInstallZitiControllerOptions struct { } // NewCmdUnInstallZitiController defines the command -func NewCmdUnInstallZitiController(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstallZitiController(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallZitiControllerOptions{ UnInstallOptions: UnInstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go b/ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go index 4366b5c4a..e77f721db 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go +++ b/ziti/cmd/ziti/cmd/uninstall_ziti_edge_tunnel.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -45,13 +44,12 @@ type UnInstallZitiEdgeTunnelOptions struct { } // NewCmdUnInstallZitiEdgeTunnel defines the command -func NewCmdUnInstallZitiEdgeTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstallZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallZitiEdgeTunnelOptions{ UnInstallOptions: UnInstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_fabric.go b/ziti/cmd/ziti/cmd/uninstall_ziti_fabric.go index 7600b34b7..1d9edc7cb 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_fabric.go +++ b/ziti/cmd/ziti/cmd/uninstall_ziti_fabric.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -45,13 +44,12 @@ type UnInstallZitiFabricOptions struct { } // NewCmdUnInstallZitiFabric defines the command -func NewCmdUnInstallZitiFabric(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstallZitiFabric(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallZitiFabricOptions{ UnInstallOptions: UnInstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go b/ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go index bb2442547..fdc3220aa 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go +++ b/ziti/cmd/ziti/cmd/uninstall_ziti_proxy_c.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -45,13 +44,12 @@ type UnInstallZitiProxCOptions struct { } // NewCmdUnInstallZitiProxC defines the command -func NewCmdUnInstallZitiProxC(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstallZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallZitiProxCOptions{ UnInstallOptions: UnInstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_router.go b/ziti/cmd/ziti/cmd/uninstall_ziti_router.go index 298e153a2..2cac5b2b3 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_router.go +++ b/ziti/cmd/ziti/cmd/uninstall_ziti_router.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -45,13 +44,12 @@ type UnInstallZitiRouterOptions struct { } // NewCmdUnInstallZitiRouter defines the command -func NewCmdUnInstallZitiRouter(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstallZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallZitiRouterOptions{ UnInstallOptions: UnInstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go b/ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go index 49269b362..5fb9cc759 100644 --- a/ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go +++ b/ziti/cmd/ziti/cmd/uninstall_ziti_tunnel.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -45,13 +44,12 @@ type UnInstallZitiTunnelOptions struct { } // NewCmdUnInstallZitiTunnel defines the command -func NewCmdUnInstallZitiTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUnInstallZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { options := &UnInstallZitiTunnelOptions{ UnInstallOptions: UnInstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/unwrap_identity.go b/ziti/cmd/ziti/cmd/unwrap_identity.go index dad38bd62..7a39c049d 100644 --- a/ziti/cmd/ziti/cmd/unwrap_identity.go +++ b/ziti/cmd/ziti/cmd/unwrap_identity.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "github.com/openziti/foundation/identity/identity" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" "github.com/spf13/cobra" "io" "io/ioutil" @@ -17,7 +16,7 @@ type IdentityConfigFile struct { ConfigTypes []string `json:"configTypes"` } -func NewUnwrapIdentityFileCommand(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewUnwrapIdentityFileCommand(out io.Writer, errOut io.Writer) *cobra.Command { outCertFile := "" outKeyFile := "" outCaFile := "" diff --git a/ziti/cmd/ziti/cmd/update.go b/ziti/cmd/ziti/cmd/update.go index 19e8addea..1b6c5863c 100644 --- a/ziti/cmd/ziti/cmd/update.go +++ b/ziti/cmd/ziti/cmd/update.go @@ -21,7 +21,6 @@ import ( "github.com/spf13/cobra" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" ) @@ -48,12 +47,11 @@ var ( ) // NewCmdUpdate creates a command object for the "update" command -func NewCmdUpdate(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpdate(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpdateOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } diff --git a/ziti/cmd/ziti/cmd/upgrade.go b/ziti/cmd/ziti/cmd/upgrade.go index 0a3ef2a49..437b7b33b 100644 --- a/ziti/cmd/ziti/cmd/upgrade.go +++ b/ziti/cmd/ziti/cmd/upgrade.go @@ -19,7 +19,6 @@ package cmd import ( "io" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates" "github.com/spf13/cobra" @@ -42,12 +41,11 @@ var ( ) // NewCmdUpgrade creates the command -func NewCmdUpgrade(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgrade(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeOptions{ CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -66,13 +64,13 @@ func NewCmdUpgrade(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Co SuggestFor: []string{"up"}, } - cmd.AddCommand(NewCmdUpgradeZiti(f, out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiController(f, out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiFabric(f, out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiRouter(f, out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiTunnel(f, out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiProxC(f, out, errOut)) - cmd.AddCommand(NewCmdUpgradeZitiEdgeTunnel(f, out, errOut)) + cmd.AddCommand(NewCmdUpgradeZiti(out, errOut)) + cmd.AddCommand(NewCmdUpgradeZitiController(out, errOut)) + cmd.AddCommand(NewCmdUpgradeZitiFabric(out, errOut)) + cmd.AddCommand(NewCmdUpgradeZitiRouter(out, errOut)) + cmd.AddCommand(NewCmdUpgradeZitiTunnel(out, errOut)) + cmd.AddCommand(NewCmdUpgradeZitiProxC(out, errOut)) + cmd.AddCommand(NewCmdUpgradeZitiEdgeTunnel(out, errOut)) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti.go b/ziti/cmd/ziti/cmd/upgrade_ziti.go index 89db1c2ef..332526e3d 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiOptions struct { } // NewCmdUpgradeZiti defines the command -func NewCmdUpgradeZiti(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZiti(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZiti(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobr }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_controller.go b/ziti/cmd/ziti/cmd/upgrade_ziti_controller.go index 9fce2e922..ed26c617a 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_controller.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti_controller.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiControllerOptions struct { } // NewCmdUpgradeZitiController defines the command -func NewCmdUpgradeZitiController(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZitiController(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiControllerOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZitiController(f cmdutil.Factory, out io.Writer, errOut io.Wri }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go b/ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go index 5ef79413d..61cb7f214 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti_edge_tunnel.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiEdgeTunnelOptions struct { } // NewCmdUpgradeZitiEdgeTunnel defines the command -func NewCmdUpgradeZitiEdgeTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZitiEdgeTunnel(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiEdgeTunnelOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZitiEdgeTunnel(f cmdutil.Factory, out io.Writer, errOut io.Wri }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_fabric.go b/ziti/cmd/ziti/cmd/upgrade_ziti_fabric.go index 47fdb597d..ad542c769 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_fabric.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti_fabric.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiFabricOptions struct { } // NewCmdUpgradeZitiFabric defines the command -func NewCmdUpgradeZitiFabric(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZitiFabric(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiFabricOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZitiFabric(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go b/ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go index 4e91efc13..4efe92e29 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti_prox_c.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiProxCOptions struct { } // NewCmdUpgradeZitiProxC defines the command -func NewCmdUpgradeZitiProxC(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZitiProxC(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiProxCOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZitiProxC(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_router.go b/ziti/cmd/ziti/cmd/upgrade_ziti_router.go index 7d3569785..8a221dcfe 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_router.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti_router.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiRouterOptions struct { } // NewCmdUpgradeZitiRouter defines the command -func NewCmdUpgradeZitiRouter(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZitiRouter(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiRouterOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZitiRouter(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go b/ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go index 364378fc7..0ea86f73e 100644 --- a/ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go +++ b/ziti/cmd/ziti/cmd/upgrade_ziti_tunnel.go @@ -20,7 +20,6 @@ import ( "io" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -46,12 +45,11 @@ type UpgradeZitiTunnelOptions struct { } // NewCmdUpgradeZitiTunnel defines the command -func NewCmdUpgradeZitiTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUpgradeZitiTunnel(out io.Writer, errOut io.Writer) *cobra.Command { options := &UpgradeZitiTunnelOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -69,7 +67,7 @@ func NewCmdUpgradeZitiTunnel(f cmdutil.Factory, out io.Writer, errOut io.Writer) }, } cmd.Flags().StringVarP(&options.Version, "version", "v", "", "The specific version to upgrade to") - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) return cmd } diff --git a/ziti/cmd/ziti/cmd/use.go b/ziti/cmd/ziti/cmd/use.go index fd3719825..578b2d6e5 100644 --- a/ziti/cmd/ziti/cmd/use.go +++ b/ziti/cmd/ziti/cmd/use.go @@ -22,7 +22,6 @@ import ( "github.com/blang/semver" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -39,13 +38,12 @@ type UseOptions struct { } // NewCmdUse creates the command -func NewCmdUse(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdUse(out io.Writer, errOut io.Writer) *cobra.Command { options := &UseOptions{ InstallOptions: InstallOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, }, } diff --git a/ziti/cmd/ziti/cmd/version.go b/ziti/cmd/ziti/cmd/version.go index c8ce5a858..19f5a1946 100644 --- a/ziti/cmd/ziti/cmd/version.go +++ b/ziti/cmd/ziti/cmd/version.go @@ -27,7 +27,6 @@ import ( // "strings" "github.com/openziti/ziti/common/version" - cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" 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" @@ -44,12 +43,11 @@ type VersionOptions struct { NoVersionCheck bool } -func NewCmdVersion(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { +func NewCmdVersion(out io.Writer, errOut io.Writer) *cobra.Command { options := &VersionOptions{ CommonOptions: CommonOptions{ - Factory: f, - Out: out, - Err: errOut, + Out: out, + Err: errOut, }, } @@ -64,7 +62,7 @@ func NewCmdVersion(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Co cmdhelper.CheckErr(err) }, } - options.addCommonFlags(cmd) + options.AddCommonFlags(cmd) cmd.Flags().BoolVarP(&options.NoVersionCheck, "no-update", "n", false, "disable update check")