Add demo agent and echo-server health checks. Do some cli tidying

This commit is contained in:
Paul Lorenz
2022-04-12 17:38:15 -04:00
parent fe33a2d1b0
commit 674363f03b
111 changed files with 922 additions and 1055 deletions
+1
View File
@@ -27,3 +27,4 @@ linux-build
*.log
/build/
go.work
go.work.sum
+8 -10
View File
@@ -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
+17 -18
View File
@@ -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=
+3 -5
View File
@@ -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,
},
}
+11 -29
View File
@@ -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
}
+14 -20
View File
@@ -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],
},
},
}
+13 -17
View File
@@ -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 + " <optional-target> ",
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
}
+59
View File
@@ -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)
})
}
@@ -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 {
@@ -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
}
@@ -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
}
@@ -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
}
@@ -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
@@ -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
}
@@ -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
}
@@ -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 {
@@ -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 {
@@ -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
@@ -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 [<optional-target>]",
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)
})
@@ -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
}
@@ -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
}
+4 -6
View File
@@ -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
}
+21 -27
View File
@@ -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
}
+1 -119
View File
@@ -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)
}
}
}
-6
View File
@@ -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
+7 -8
View File
@@ -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
}
+3 -5
View File
@@ -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,
},
}
+141 -2
View File
@@ -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()
}
@@ -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 <optional-target>",
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
}
+19 -5
View File
@@ -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
}
@@ -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
@@ -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
@@ -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
@@ -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" : [
@@ -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" : [
+11 -12
View File
@@ -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))
@@ -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,
}
+3 -5
View File
@@ -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),
+2 -3
View File
@@ -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},
},
}
+2 -3
View File
@@ -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},
},
}
+2 -3
View File
@@ -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},
},
}
@@ -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},
},
}
+2 -3
View File
@@ -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},
},
}
}
+3 -5
View File
@@ -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),
@@ -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},
},
}
+3 -5
View File
@@ -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,
},
},
}
+3 -3
View File
@@ -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)
+5 -6
View File
@@ -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))
+12 -13
View File
@@ -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
@@ -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,
}
+2 -3
View File
@@ -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,
+2 -3
View File
@@ -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},
},
}
+2 -3
View File
@@ -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},
},
}
@@ -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},
},
}
+2 -3
View File
@@ -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},
},
}
@@ -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},
},
}
+2 -3
View File
@@ -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},
},
}
@@ -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},
},
}
@@ -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},
},
}
+3 -5
View File
@@ -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,
},
},
}
+4 -6
View File
@@ -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
+4 -6
View File
@@ -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
}
+3 -2
View File
@@ -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)
-55
View File
@@ -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 &copy
}
func (f *factory) CreateTable(out io.Writer) table.Table {
return table.CreateTable(os.Stdout)
}
+4 -6
View File
@@ -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
+13 -15
View File
@@ -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
}
+3 -5
View File
@@ -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,
},
},
}
@@ -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,
},
},
}
+4 -6
View File
@@ -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
}
+6 -8
View File
@@ -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
}
@@ -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
}
+6 -8
View File
@@ -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
}
+4 -6
View File
@@ -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
}
+6 -8
View File
@@ -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
}
+6 -8
View File
@@ -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
}
+1 -2
View File
@@ -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{
+1 -2
View File
@@ -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{
+1 -2
View File
@@ -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{
+1 -2
View File
@@ -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{
+7 -9
View File
@@ -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
}
+4 -6
View File
@@ -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,
},
}
+3 -5
View File
@@ -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,
},
}
+5 -7
View File
@@ -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
}
+9 -11
View File
@@ -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
+3 -5
View File
@@ -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,
},
},
},
+3 -5
View File
@@ -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,
},
},
},
+3 -5
View File
@@ -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,
},
},
},
+3 -5
View File
@@ -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,
},
},
},
+3 -5
View File
@@ -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,
},
},
},
+3 -5
View File
@@ -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,
},
},
},
+4 -6
View File
@@ -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.")
+26 -40
View File
@@ -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()
+9 -11
View File
@@ -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
}
@@ -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,
},
},
}
@@ -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,
},
},
}
+3 -5
View File
@@ -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,
},
},
}
+3 -5
View File
@@ -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,
},
},
}
+3 -5
View File
@@ -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,
},
},
}
+3 -5
View File
@@ -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,
},
},
}
+1 -2
View File
@@ -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 := ""

Some files were not shown because too many files have changed in this diff Show More