Move tutorial library into runzmd library

This commit is contained in:
Paul Lorenz
2022-10-20 00:15:06 -04:00
parent 58a17d241b
commit fb99a43551
29 changed files with 132 additions and 1495 deletions
+4 -4
View File
@@ -6,8 +6,6 @@ require (
github.com/Jeffail/gabs v1.4.0
github.com/Jeffail/gabs/v2 v2.6.1
github.com/MakeNowJust/heredoc v1.0.0
github.com/MichaelMure/go-term-markdown v0.1.4
github.com/alecthomas/chroma v0.9.2
github.com/blang/semver v3.5.1+incompatible
github.com/fatih/color v1.13.0
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa
@@ -27,6 +25,7 @@ require (
github.com/openziti/fabric v0.21.9
github.com/openziti/foundation/v2 v2.0.6
github.com/openziti/identity v1.0.18
github.com/openziti/runzmd v1.0.0
github.com/openziti/sdk-golang v0.16.135
github.com/openziti/storage v0.1.25
github.com/openziti/transport/v2 v2.0.36
@@ -42,7 +41,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.0
github.com/stretchr/testify v1.8.0
github.com/valyala/fasttemplate v1.2.1
go.etcd.io/bbolt v1.3.6
golang.org/x/net v0.0.0-20220923203811-8be639271d50
google.golang.org/grpc v1.42.0
@@ -56,7 +54,9 @@ require (
require (
github.com/AppsFlyer/go-sundheit v0.5.0 // indirect
github.com/MichaelMure/go-term-markdown v0.1.4 // indirect
github.com/MichaelMure/go-term-text v0.3.1 // indirect
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211106181442-e4c1a74c66bd // indirect
github.com/armon/go-metrics v0.3.10 // indirect
@@ -66,7 +66,6 @@ require (
github.com/c-bata/go-prompt v0.2.6 // 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
github.com/dgryski/dgoogauth v0.0.0-20190221195224-5a805980a5f3 // indirect
github.com/dineshappavoo/basex v0.0.0-20170425072625-481a6f6dc663 // indirect
@@ -151,6 +150,7 @@ require (
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
+6 -14
View File
@@ -84,16 +84,12 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
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=
github.com/akamai/AkamaiOPEN-edgegrid-golang v0.9.18/go.mod h1:L+HB2uBoDgi3+r1pJEJcbGwyyHhd2QXaGsKLbDwtm8Q=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/chroma v0.7.1/go.mod h1:gHw09mkX1Qp80JlYbmN9L3+4R5o6DJJ3GRShh+AICNc=
github.com/alecthomas/chroma v0.9.2 h1:yU1sE2+TZbLIQPMk30SolL2Hn53SR/Pv750f7qZ/XMs=
github.com/alecthomas/chroma v0.9.2/go.mod h1:eMuEnpA18XbG/WhOWtCzJHS7WqEtDAI+HxdwoW0nVSk=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -175,7 +171,6 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -570,7 +565,6 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -679,8 +673,6 @@ github.com/openziti/channel/v2 v2.0.9 h1:vkB44EsSMIIxCcua0JK7VpUrBi9N7bNb42tuUAt
github.com/openziti/channel/v2 v2.0.9/go.mod h1:bHjCw8iZngh8QfUwloqi5JeDszS93kQfW8e7fEt5OJY=
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.24.11 h1:wkNzH0ZzyooFiZ5iclRmFiHJVfMj6yPsgDyYbD43kVE=
github.com/openziti/edge v0.24.11/go.mod h1:sIAjb03x6jqYyzaanliBTfF5q8DqGJHCmQ1k9nB9eN4=
github.com/openziti/edge v0.24.12 h1:ugZ1Uoz6+/7Fs0u5mN01H6gQDeu8cT0FJdEZJs/V5sU=
github.com/openziti/edge v0.24.12/go.mod h1:sIAjb03x6jqYyzaanliBTfF5q8DqGJHCmQ1k9nB9eN4=
github.com/openziti/fabric v0.21.9 h1:zMU3blfo9CUctHcwTetH/x/9+3+3c/NNy+4RuQG8zaw=
@@ -693,6 +685,8 @@ github.com/openziti/jwks v1.0.2 h1:32BGXIAnefS+v7uXKPb1x8/cQ7srek6Ai06dsrMTY4E=
github.com/openziti/jwks v1.0.2/go.mod h1:KwO0x9FBG0aoJS5f6nH5xeHoplyR1H143SMI9kF0mC8=
github.com/openziti/metrics v1.1.4 h1:UGLU1kBJ3ztDO1SAs42qecN/BV4/JTPGH93LWvZwa4c=
github.com/openziti/metrics v1.1.4/go.mod h1:Wy7suQpju6oqWc1cmKA6+0Bh3izbudDGdfSqCuJ63UU=
github.com/openziti/runzmd v1.0.0 h1:EH7ZvjFdikhuJlHWuG2VlLK2ng2dV23pIJAw7yRsKkM=
github.com/openziti/runzmd v1.0.0/go.mod h1:3w6vxdO3MCqD8emZWaSK+z4JN6D7XFCPiyymv0N4U3k=
github.com/openziti/sdk-golang v0.16.135 h1:9/pxkHGZJYUsdM03/rQksOz2S3i9C/sSUIHwmEbrxXk=
github.com/openziti/sdk-golang v0.16.135/go.mod h1:o4brIi4dvez9mM+IPtKuUN97RiGAwcY3D9zFm6SIMOI=
github.com/openziti/storage v0.1.25 h1:8HMNCR9pRKhZT8VMWad89zLntmZHLJVbWC2dDFxQ/BQ=
@@ -791,7 +785,6 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sacloud/libsacloud v1.36.2/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil/v3 v3.22.9 h1:yibtJhIVEMcdw+tCTbOPiF1VcsuDeTE4utJ8Dm4c5eA=
github.com/shirou/gopsutil/v3 v3.22.9/go.mod h1:bBYl1kjgEJpWpxeHmLI+dVHWtyAwfcmSBLDsp2TNT8A=
@@ -898,8 +891,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/vultr/govultr/v2 v2.0.0/go.mod h1:2PsEeg+gs3p/Fo5Pw8F9mv+DUBEOlrNZ8GmCTGmhOhs=
@@ -1162,7 +1155,6 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+3 -3
View File
@@ -19,7 +19,7 @@ require (
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/MichaelMure/go-term-markdown v0.1.4 // indirect
github.com/MichaelMure/go-term-text v0.3.1 // indirect
github.com/alecthomas/chroma v0.9.2 // indirect
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211106181442-e4c1a74c66bd // indirect
github.com/armon/go-metrics v0.3.10 // indirect
@@ -30,7 +30,6 @@ require (
github.com/boltdb/bolt v1.3.1 // indirect
github.com/c-bata/go-prompt v0.2.6 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/dgoogauth v0.0.0-20190221195224-5a805980a5f3 // indirect
github.com/dineshappavoo/basex v0.0.0-20170425072625-481a6f6dc663 // indirect
@@ -114,6 +113,7 @@ require (
github.com/openziti/identity v1.0.18 // indirect
github.com/openziti/jwks v1.0.2 // indirect
github.com/openziti/metrics v1.1.4 // indirect
github.com/openziti/runzmd v1.0.0 // indirect
github.com/openziti/storage v0.1.25 // indirect
github.com/openziti/transport/v2 v2.0.36 // indirect
github.com/openziti/x509-claims v1.0.3 // indirect
@@ -146,7 +146,7 @@ require (
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
+6 -12
View File
@@ -76,16 +76,12 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
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=
github.com/akamai/AkamaiOPEN-edgegrid-golang v0.9.18/go.mod h1:L+HB2uBoDgi3+r1pJEJcbGwyyHhd2QXaGsKLbDwtm8Q=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/chroma v0.7.1/go.mod h1:gHw09mkX1Qp80JlYbmN9L3+4R5o6DJJ3GRShh+AICNc=
github.com/alecthomas/chroma v0.9.2 h1:yU1sE2+TZbLIQPMk30SolL2Hn53SR/Pv750f7qZ/XMs=
github.com/alecthomas/chroma v0.9.2/go.mod h1:eMuEnpA18XbG/WhOWtCzJHS7WqEtDAI+HxdwoW0nVSk=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -149,7 +145,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -501,7 +496,6 @@ github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kN
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -617,6 +611,8 @@ github.com/openziti/jwks v1.0.2 h1:32BGXIAnefS+v7uXKPb1x8/cQ7srek6Ai06dsrMTY4E=
github.com/openziti/jwks v1.0.2/go.mod h1:KwO0x9FBG0aoJS5f6nH5xeHoplyR1H143SMI9kF0mC8=
github.com/openziti/metrics v1.1.4 h1:UGLU1kBJ3ztDO1SAs42qecN/BV4/JTPGH93LWvZwa4c=
github.com/openziti/metrics v1.1.4/go.mod h1:Wy7suQpju6oqWc1cmKA6+0Bh3izbudDGdfSqCuJ63UU=
github.com/openziti/runzmd v1.0.0 h1:EH7ZvjFdikhuJlHWuG2VlLK2ng2dV23pIJAw7yRsKkM=
github.com/openziti/runzmd v1.0.0/go.mod h1:3w6vxdO3MCqD8emZWaSK+z4JN6D7XFCPiyymv0N4U3k=
github.com/openziti/sdk-golang v0.16.135 h1:9/pxkHGZJYUsdM03/rQksOz2S3i9C/sSUIHwmEbrxXk=
github.com/openziti/sdk-golang v0.16.135/go.mod h1:o4brIi4dvez9mM+IPtKuUN97RiGAwcY3D9zFm6SIMOI=
github.com/openziti/storage v0.1.25 h1:8HMNCR9pRKhZT8VMWad89zLntmZHLJVbWC2dDFxQ/BQ=
@@ -708,7 +704,6 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sacloud/libsacloud v1.36.2/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil/v3 v3.22.9 h1:yibtJhIVEMcdw+tCTbOPiF1VcsuDeTE4utJ8Dm4c5eA=
github.com/shirou/gopsutil/v3 v3.22.9/go.mod h1:bBYl1kjgEJpWpxeHmLI+dVHWtyAwfcmSBLDsp2TNT8A=
@@ -779,8 +774,8 @@ github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vultr/govultr/v2 v2.0.0/go.mod h1:2PsEeg+gs3p/Fo5Pw8F9mv+DUBEOlrNZ8GmCTGmhOhs=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
@@ -1013,7 +1008,6 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+9 -9
View File
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var clientScriptSource []byte
type client struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,16 +70,16 @@ func newClientCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *client) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("select-edge-router", &actions.SelectEdgeRouterAction{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("select-edge-router", &actionz.SelectEdgeRouterAction{})
return t.Run(clientScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var multiRouterTunnelerHostedScriptSource []byte
type multiRouterTunnelerHosted struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,17 +70,17 @@ func newMultiRouterTunnelerHostedCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *multiRouterTunnelerHosted) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actions.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actions.ZitiForEach{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actionz.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actionz.ZitiForEach{})
return t.Run(multiRouterTunnelerHostedScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var multiSdkHostedScriptSource []byte
type multiSdkHosted struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,15 +70,15 @@ func newMultiSdkHostedCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *multiSdkHosted) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
return t.Run(multiSdkHostedScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var multiTunnelerHostedScriptSource []byte
type multiTunnelerHosted struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,17 +70,17 @@ func newMultiTunnelerHostedCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *multiTunnelerHosted) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actions.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actions.ZitiForEach{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actionz.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actionz.ZitiForEach{})
return t.Run(multiTunnelerHostedScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var routerTunnelerBothSidesScriptSource []byte
type routerTunnelerBothSides struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,17 +70,17 @@ func newRouterTunnelerBothSidesCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *routerTunnelerBothSides) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actions.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actions.ZitiForEach{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actionz.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actionz.ZitiForEach{})
return t.Run(routerTunnelerBothSidesScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var singleRouterTunnelerHostedScriptSource []byte
type singleRouterTunnelerHosted struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,18 +70,18 @@ func newSingleRouterTunnelerHostedCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *singleRouterTunnelerHosted) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actions.ZitiCreateConfigAction{})
t.RegisterActionHandler("select-edge-router", &actions.SelectEdgeRouterAction{})
t.RegisterActionHandler("ziti-for-each", &actions.ZitiForEach{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actionz.ZitiCreateConfigAction{})
t.RegisterActionHandler("select-edge-router", &actionz.SelectEdgeRouterAction{})
t.RegisterActionHandler("ziti-for-each", &actionz.ZitiForEach{})
return t.Run(singleRouterTunnelerHostedScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var singleSdkHostedScriptSource []byte
type singleSdkHosted struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,16 +70,16 @@ func newSingleSdkHostedCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *singleSdkHosted) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("select-edge-router", &actions.SelectEdgeRouterAction{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("select-edge-router", &actionz.SelectEdgeRouterAction{})
return t.Run(singleSdkHostedScriptSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var updateConfigAddressableSource []byte
type updateConfigAddressable struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,18 +70,18 @@ func newUpdateConfigAddressableCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *updateConfigAddressable) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actions.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-update-config", &actions.ZitiUpdateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actions.ZitiForEach{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actionz.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-update-config", &actionz.ZitiUpdateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actionz.ZitiForEach{})
return t.Run(updateConfigAddressableSource)
}
@@ -18,12 +18,12 @@ package demo
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
tutorial2 "github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial"
"github.com/spf13/cobra"
"time"
)
@@ -33,7 +33,7 @@ var updateConfigHASource []byte
type updateConfigHA struct {
api.Options
tutorial2.TutorialOptions
tutorial.TutorialOptions
interactive bool
}
@@ -70,18 +70,18 @@ func newUpdateConfigHACmd(p common.OptionsProvider) *cobra.Command {
}
func (self *updateConfigHA) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = !self.interactive
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiEnsureLoggedIn{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiEnsureLoggedIn{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actions.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-update-config", &actions.ZitiUpdateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actions.ZitiForEach{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("ziti-create-config", &actionz.ZitiCreateConfigAction{})
t.RegisterActionHandler("ziti-update-config", &actionz.ZitiUpdateConfigAction{})
t.RegisterActionHandler("ziti-for-each", &actionz.ZitiForEach{})
return t.Run(updateConfigHASource)
}
+9 -9
View File
@@ -30,34 +30,34 @@ import (
"time"
)
type zcat struct {
type zcatAction struct {
verbose bool
logFormatter string
configFile string
}
func newZcatCmd() *cobra.Command {
server := &zcat{}
action := &zcatAction{}
cmd := &cobra.Command{
Use: "zcat <destination>",
Example: "ziti demo zcat tcp:localhost:1234 or ziti demo zcat -i zcat.json ziti:echo",
Short: "A simple network cat facility which can run over tcp or ziti",
Args: cobra.ExactArgs(1),
Run: server.run,
Run: action.run,
}
// allow interspersing positional args and flags
cmd.Flags().SetInterspersed(true)
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")
cmd.Flags().BoolVarP(&action.verbose, "verbose", "v", false, "Enable verbose logging")
cmd.Flags().StringVar(&action.logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]")
cmd.Flags().StringVarP(&action.configFile, "identity", "i", "", "Specify the Ziti identity to use. If not specified the Ziti listener won't be started")
cmd.Flags().SetInterspersed(true)
return cmd
}
func (self *zcat) initLogging() {
func (self *zcatAction) initLogging() {
logLevel := logrus.InfoLevel
if self.verbose {
logLevel = logrus.DebugLevel
@@ -78,7 +78,7 @@ func (self *zcat) initLogging() {
}
}
func (self *zcat) run(_ *cobra.Command, args []string) {
func (self *zcatAction) run(_ *cobra.Command, args []string) {
self.initLogging()
log := pfxlog.Logger()
@@ -128,7 +128,7 @@ func (self *zcat) run(_ *cobra.Command, args []string) {
self.copy(os.Stdout, conn)
}
func (self *zcat) copy(writer io.Writer, reader io.Reader) {
func (self *zcatAction) copy(writer io.Writer, reader io.Reader) {
buf := make([]byte, info.MaxUdpPacketSize)
bytesCopied, err := io.CopyBuffer(writer, reader, buf)
pfxlog.Logger().Debugf("Copied %v bytes", bytesCopied)
@@ -1,52 +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 actions
import (
"fmt"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/edge"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"net/url"
"strings"
"time"
)
type KeepSessionAliveAction struct{}
func (self *KeepSessionAliveAction) Execute(ctx *tutorial.ActionContext) error {
interval := time.Minute
if val, ok := ctx.Headers["interval"]; ok {
if d, err := time.ParseDuration(val); err != nil {
return err
} else {
interval = d
}
}
if !strings.EqualFold("true", ctx.Headers["quiet"]) {
fmt.Printf("Running session refresh every %v\n", interval)
}
go func() {
ticker := time.NewTicker(interval)
for {
select {
case <-ticker.C:
_, _, _ = edge.ListEntitiesOfType("edge-routers", url.Values{}, false, nil, 10, false)
}
}
}()
return nil
}
@@ -1,138 +0,0 @@
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package actions
import (
"fmt"
"github.com/openziti/foundation/v2/term"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/edge"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/pkg/errors"
"strconv"
"strings"
)
type edgeRouter struct {
id string
name string
}
type SelectEdgeRouterAction struct{}
func (self *SelectEdgeRouterAction) Execute(ctx *tutorial.ActionContext) error {
for {
err := self.SelectEdgeRouter(ctx)
if err == nil {
return nil
}
retry, err2 := tutorial.AskYesNoWithDefault(fmt.Sprintf("Error getting edge router (err=%v). Try again? [Y/N] (default Y): ", err), true)
if err2 != nil {
fmt.Printf("encountered error prompting for input: %v\n", err2)
return err
}
if !retry {
return err
}
}
}
func (self *SelectEdgeRouterAction) SelectEdgeRouter(ctx *tutorial.ActionContext) error {
fmt.Println("")
valid := false
var edgeRouterName string
for !valid {
children, _, err := edge.ListEntitiesWithFilter("edge-routers", "limit none")
if err != nil {
return errors.Wrap(err, "unable to list edge routers")
}
var ers []*edgeRouter
if len(children) == 0 {
return errors.New("no edge routers found")
}
for _, child := range children {
isOnline := child.S("isOnline").Data().(bool)
if isOnline {
id := child.S("id").Data().(string)
name := child.S("name").Data().(string)
ers = append(ers, &edgeRouter{id: id, name: name})
}
}
if len(ers) == 0 {
fmt.Println("Error: no online edge routers found. Found these offline edge routers: ")
for _, child := range children {
id := child.S("id").Data().(string)
name := child.S("name").Data().(string)
fmt.Printf("id: %10v name: %10v\n", id, name)
}
return errors.New("no on-line edge routers")
}
fmt.Printf("Available edge routers: \n\n")
for idx, er := range ers {
fmt.Printf(" %v: %v\n", idx+1, er.name)
}
fmt.Print(" R: Refresh list from controller\n")
var val string
if !ctx.Runner.AssumeDefault {
val, err = term.Prompt("\nSelect edge router, by number or name (default 1): ")
if err != nil {
return err
}
}
if val == "" {
edgeRouterName = ers[0].name
valid = true
} else {
if idx, err := strconv.Atoi(val); err == nil {
if idx > 0 && idx <= len(ers) {
edgeRouterName = ers[idx-1].name
valid = true
}
}
}
if !valid {
for _, er := range ers {
if val == er.name {
edgeRouterName = val
valid = true
}
}
}
if !valid {
if strings.EqualFold("r", val) {
fmt.Println("Refreshing edge router list")
} else {
fmt.Printf("Invalid input %v\n", val)
}
}
}
ctx.Runner.AddVariable("edgeRouterName", edgeRouterName)
return nil
}
@@ -1,94 +0,0 @@
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package actions
import (
"fmt"
"github.com/fatih/color"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/pkg/errors"
"os"
"strings"
)
// TODO: make this code more DRY
type ZitiCreateConfigAction struct{}
func (self *ZitiCreateConfigAction) Execute(ctx *tutorial.ActionContext) error {
if strings.EqualFold("true", ctx.Headers["templatize"]) {
body, err := ctx.Runner.Template(ctx.Body)
if err != nil {
return err
}
ctx.Body = body
}
name := ctx.Headers["name"]
configType := ctx.Headers["type"]
buf := &strings.Builder{}
buf.WriteString("About to execute:\n\n")
line := fmt.Sprintf("ziti edge create config %v %v '%v'", name, configType, ctx.Body)
params := tutorial.ParseArgumentsWithStrings(line)
if params[0] != "ziti" {
return errors.Errorf("invalid parameter for ziti action, must start with 'ziti': %v", ctx.Body)
}
params[0] = line
ctx.Runner.LeftPadBuilder(buf)
buf.WriteString(" ")
buf.WriteString(color.New(color.Bold).Sprintf(line))
buf.WriteRune('\n')
buf.WriteRune('\n')
ctx.Runner.LeftPadBuilder(buf)
buf.WriteString("Continue [Y/N] (default Y): ")
if !ctx.Runner.AssumeDefault {
tutorial.Continue(buf.String(), true)
}
fmt.Println("")
c := color.New(color.FgBlue, color.Bold)
colorStdOut := !strings.EqualFold("false", ctx.Headers["colorStdOut"])
allowRetry := strings.EqualFold("true", ctx.Headers["allowRetry"])
failOk := strings.EqualFold("true", ctx.Headers["failOk"])
_, _ = c.Printf("$ %v\n", line)
done := false
for !done {
if err := tutorial.Exec(os.Args[0], colorStdOut, "edge", "create", "config", name, configType, ctx.Body); err != nil {
if failOk {
return nil
}
if allowRetry {
retry, err2 := tutorial.AskYesNoWithDefault(fmt.Sprintf("operation failed with err: %v. Retry [Y/N] (default Y):", err), true)
if err2 != nil {
fmt.Printf("error while asking about retry: %v\n", err2)
return err
}
if !retry {
return err
}
} else {
return err
}
} else {
done = true
}
}
return nil
}
@@ -1,38 +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 actions
import (
"fmt"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/edge"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"net/url"
)
type ZitiEnsureLoggedIn struct {
LoginParams LoginParams
}
func (self *ZitiEnsureLoggedIn) Execute(ctx *tutorial.ActionContext) error {
_, _, err := edge.ListEntitiesOfType("edge-routers", url.Values{}, false, nil, 10, false)
if err == nil {
fmt.Println("Already authenticated to Ziti Controller")
return nil
}
loginAction := &ZitiLoginAction{LoginParams: self.LoginParams}
return loginAction.Execute(ctx)
}
@@ -1,100 +0,0 @@
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package actions
import (
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/openziti/ziti/ziti/cmd/ziti/util"
"github.com/pkg/errors"
"net/url"
"os"
"strconv"
)
type ZitiForEach struct{}
func (self *ZitiForEach) Execute(ctx *tutorial.ActionContext) error {
ctx.Headers["templatize"] = "true"
apiType, found := ctx.Headers["api"]
if !found {
apiType = string(util.EdgeAPI)
}
entityType := ctx.Headers["type"]
params := url.Values{}
filter, found := ctx.Headers["filter"]
if found {
params.Add("filter", filter)
}
minCount := 1
if count, found := ctx.Headers["minCount"]; found {
val, err := strconv.Atoi(count)
if err != nil {
return errors.Wrapf(err, "couldn't parse minCount, invalid value '%v'", count)
}
if val < 0 {
return errors.Wrapf(err, "invalid minCount, invalid value '%v', must >= 0", count)
}
minCount = val
}
maxCount := 1
if count, found := ctx.Headers["maxCount"]; found {
val, err := strconv.Atoi(count)
if err != nil {
return errors.Wrapf(err, "couldn't parse maxCount, invalid value '%v'", count)
}
if val < minCount {
return errors.Wrapf(err, "invalid maxCount '%v', must >= minCount of %v", count, minCount)
}
maxCount = val
}
entities, _, err := api.ListEntitiesOfType(util.API(apiType), entityType, params, false, os.Stdout, 1, false)
if err != nil {
return err
}
if len(entities) < minCount {
return errors.Errorf("expected at least %v %v, only found %v", minCount, entityType, len(entities))
}
if len(entities) > maxCount {
return errors.Errorf("expected at most %v %v, only found %v", maxCount, entityType, len(entities))
}
runner := ZitiRunnerAction{}
originalBody := ctx.Body
for _, entity := range entities {
wrapper := api.Wrap(entity)
id := wrapper.String("id")
name := wrapper.String("name")
ctx.Runner.AddVariable("entityId", id)
ctx.Runner.AddVariable("entityName", name)
if err := runner.Execute(ctx); err != nil {
return err
}
ctx.Runner.ClearVariable("entityId")
ctx.Runner.ClearVariable("entityName")
ctx.Body = originalBody
}
return nil
}
@@ -1,44 +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 actions
import "github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
type LoginParams interface {
GetControllerUrl() string
GetUsername() string
GetPassword() string
}
type ZitiLoginAction struct {
LoginParams LoginParams
}
func (self *ZitiLoginAction) Execute(ctx *tutorial.ActionContext) error {
cmd := "ziti edge login --ignore-config"
if self.LoginParams.GetControllerUrl() != "" {
cmd += " " + self.LoginParams.GetControllerUrl()
}
if self.LoginParams.GetUsername() != "" {
cmd += " --username " + self.LoginParams.GetUsername()
}
if self.LoginParams.GetPassword() != "" {
cmd += " --password " + self.LoginParams.GetPassword()
}
ctx.Body = cmd
return (&ZitiRunnerAction{}).Execute(ctx)
}
@@ -1,99 +0,0 @@
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package actions
import (
"fmt"
"github.com/fatih/color"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/pkg/errors"
"os"
"strings"
)
type ZitiRunnerAction struct{}
func (self *ZitiRunnerAction) Execute(ctx *tutorial.ActionContext) error {
if strings.EqualFold("true", ctx.Headers["templatize"]) {
body, err := ctx.Runner.Template(ctx.Body)
if err != nil {
return err
}
ctx.Body = body
}
lines := strings.Split(ctx.Body, "\n")
var cmds [][]string
buf := &strings.Builder{}
buf.WriteString("About to execute:\n\n")
for _, line := range lines {
line = strings.TrimSpace(line)
if len(line) > 0 {
params := tutorial.ParseArgumentsWithStrings(line)
if params[0] != "ziti" {
return errors.Errorf("invalid parameter for ziti action, must start with 'ziti': %v", ctx.Body)
}
params[0] = line
cmds = append(cmds, params)
ctx.Runner.LeftPadBuilder(buf)
buf.WriteString(" ")
buf.WriteString(color.New(color.Bold).Sprintf(line))
buf.WriteRune('\n')
}
}
buf.WriteRune('\n')
ctx.Runner.LeftPadBuilder(buf)
buf.WriteString("Continue [Y/N] (default Y): ")
if !ctx.Runner.AssumeDefault {
tutorial.Continue(buf.String(), true)
}
fmt.Println("")
c := color.New(color.FgBlue, color.Bold)
colorStdOut := !strings.EqualFold("false", ctx.Headers["colorStdOut"])
allowRetry := strings.EqualFold("true", ctx.Headers["allowRetry"])
failOk := strings.EqualFold("true", ctx.Headers["failOk"])
for _, cmd := range cmds {
_, _ = c.Printf("$ %v\n", cmd[0])
done := false
for !done {
if err := tutorial.Exec(os.Args[0], colorStdOut, cmd[1:]...); err != nil {
if failOk {
return nil
}
if allowRetry {
retry, err2 := tutorial.AskYesNoWithDefault(fmt.Sprintf("operation failed with err: %v. Retry [Y/N] (default Y):", err), true)
if err2 != nil {
fmt.Printf("error while asking about retry: %v\n", err2)
return err
}
if !retry {
return err
}
} else {
return err
}
} else {
done = true
}
}
}
return nil
}
@@ -1,92 +0,0 @@
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package actions
import (
"fmt"
"github.com/fatih/color"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/pkg/errors"
"os"
"strings"
)
type ZitiUpdateConfigAction struct{}
func (self *ZitiUpdateConfigAction) Execute(ctx *tutorial.ActionContext) error {
if strings.EqualFold("true", ctx.Headers["templatize"]) {
body, err := ctx.Runner.Template(ctx.Body)
if err != nil {
return err
}
ctx.Body = body
}
name := ctx.Headers["name"]
buf := &strings.Builder{}
buf.WriteString("About to execute:\n\n")
line := fmt.Sprintf("ziti edge update config %v --data '%v'", name, ctx.Body)
params := tutorial.ParseArgumentsWithStrings(line)
if params[0] != "ziti" {
return errors.Errorf("invalid parameter for ziti action, must start with 'ziti': %v", ctx.Body)
}
params[0] = line
ctx.Runner.LeftPadBuilder(buf)
buf.WriteString(" ")
buf.WriteString(color.New(color.Bold).Sprintf(line))
buf.WriteRune('\n')
buf.WriteRune('\n')
ctx.Runner.LeftPadBuilder(buf)
buf.WriteString("Continue [Y/N] (default Y): ")
if !ctx.Runner.AssumeDefault {
tutorial.Continue(buf.String(), true)
}
fmt.Println("")
c := color.New(color.FgBlue, color.Bold)
colorStdOut := !strings.EqualFold("false", ctx.Headers["colorStdOut"])
allowRetry := strings.EqualFold("true", ctx.Headers["allowRetry"])
failOk := strings.EqualFold("true", ctx.Headers["failOk"])
_, _ = c.Printf("$ %v\n", line)
done := false
for !done {
if err := tutorial.Exec(os.Args[0], colorStdOut, "edge", "update", "config", name, "--data", ctx.Body); err != nil {
if failOk {
return nil
}
if allowRetry {
retry, err2 := tutorial.AskYesNoWithDefault(fmt.Sprintf("operation failed with err: %v. Retry [Y/N] (default Y):", err), true)
if err2 != nil {
fmt.Printf("error while asking about retry: %v\n", err2)
return err
}
if !retry {
return err
}
} else {
return err
}
} else {
done = true
}
}
return nil
}
@@ -18,11 +18,11 @@ package tutorial
import (
_ "embed"
"github.com/openziti/runzmd"
"github.com/openziti/runzmd/actionz"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/tutorial/actions"
"github.com/openziti/ziti/ziti/cmd/ziti/tutorial"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"time"
@@ -81,16 +81,16 @@ func newFirstServiceTutorialCmd(p common.OptionsProvider) *cobra.Command {
}
func (self *firstServiceTutorialOptions) run() error {
t := tutorial.NewRunner()
t := runzmd.NewRunner()
t.NewLinePause = self.NewlinePause
t.AssumeDefault = self.AssumeDefault
t.RegisterActionHandler("ziti", &actions.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actions.ZitiLoginAction{
t.RegisterActionHandler("ziti", &actionz.ZitiRunnerAction{})
t.RegisterActionHandler("ziti-login", &actionz.ZitiLoginAction{
LoginParams: &self.TutorialOptions,
})
t.RegisterActionHandler("keep-session-alive", &actions.KeepSessionAliveAction{})
t.RegisterActionHandler("select-edge-router", &actions.SelectEdgeRouterAction{})
t.RegisterActionHandler("keep-session-alive", &actionz.KeepSessionAliveAction{})
t.RegisterActionHandler("select-edge-router", &actionz.SelectEdgeRouterAction{})
plainEchoServerActions := &PlainEchoServerActions{}
t.RegisterActionHandlerF("run-plain-echo-server", plainEchoServerActions.Start)
@@ -100,7 +100,7 @@ func (self *firstServiceTutorialOptions) run() error {
t.RegisterActionHandlerF("run-ziti-echo-server", zitiEchoServerActions.Start)
t.RegisterActionHandlerF("stop-ziti-echo-server", zitiEchoServerActions.Stop)
showActionHandler := tutorial.NewShowActionHandler()
showActionHandler := runzmd.NewShowActionHandler()
showActionHandler.Add("plain_echo_server.go", plainEchoServerSource)
showActionHandler.Add("plain_echo_client.go", plainEchoClientSource)
showActionHandler.Add("ziti_echo_client.go", zitiEchoClientSource)
@@ -114,9 +114,9 @@ type PlainEchoServerActions struct {
server plainEchoServer
}
func (self *PlainEchoServerActions) Start(ctx *tutorial.ActionContext) error {
func (self *PlainEchoServerActions) Start(ctx *runzmd.ActionContext) error {
if !ctx.Runner.AssumeDefault {
start, err := tutorial.AskYesNoWithDefault("Start plain-echo-server? [Y/N] (default Y): ", true)
start, err := runzmd.AskYesNoWithDefault("Start plain-echo-server? [Y/N] (default Y): ", true)
if err != nil {
return err
}
@@ -132,9 +132,9 @@ func (self *PlainEchoServerActions) Start(ctx *tutorial.ActionContext) error {
return nil
}
func (self *PlainEchoServerActions) Stop(ctx *tutorial.ActionContext) error {
func (self *PlainEchoServerActions) Stop(ctx *runzmd.ActionContext) error {
if !ctx.Runner.AssumeDefault {
start, err := tutorial.AskYesNoWithDefault("Stop plain-echo-server? [Y/N] (default Y): ", true)
start, err := runzmd.AskYesNoWithDefault("Stop plain-echo-server? [Y/N] (default Y): ", true)
if err != nil {
return err
}
@@ -153,12 +153,12 @@ type ZitiEchoServerActions struct {
server zitiEchoServer
}
func (self *ZitiEchoServerActions) Start(ctx *tutorial.ActionContext) error {
func (self *ZitiEchoServerActions) Start(ctx *runzmd.ActionContext) error {
logrus.SetLevel(logrus.WarnLevel)
self.server.identityJson = "echo-server.json"
if !ctx.Runner.AssumeDefault {
start, err := tutorial.AskYesNoWithDefault("Start ziti-echo-server? [Y/N] (default Y): ", true)
start, err := runzmd.AskYesNoWithDefault("Start ziti-echo-server? [Y/N] (default Y): ", true)
if err != nil {
return err
}
@@ -173,7 +173,7 @@ func (self *ZitiEchoServerActions) Start(ctx *tutorial.ActionContext) error {
return nil
}
func (self *ZitiEchoServerActions) Stop(*tutorial.ActionContext) error {
func (self *ZitiEchoServerActions) Stop(*runzmd.ActionContext) error {
if self.server.listener != nil {
return self.server.stop()
}
-134
View File
@@ -1,134 +0,0 @@
package tutorial
import (
"fmt"
"github.com/fatih/color"
"github.com/openziti/foundation/v2/term"
"io"
"os"
"os/exec"
"strings"
)
func Exec(program string, colorStdout bool, args ...string) error {
p := exec.Command(program, args...)
stdErrWrapper := &WriterWrapper{
c: color.New(color.FgRed),
w: os.Stdout,
}
p.Stdin = os.Stdin
if colorStdout {
stdOutWrapper := &WriterWrapper{
c: color.New(color.FgBlue),
w: os.Stdout,
}
p.Stdout = stdOutWrapper
} else {
p.Stdout = os.Stdout
}
p.Stderr = stdErrWrapper
if err := p.Run(); err != nil {
return err
}
return nil
}
func Continue(prompt string, defaultValue bool) {
resp, err := AskYesNoWithDefault(prompt, defaultValue)
if err != nil {
fmt.Printf("\nerror: %v. exiting\n", err)
os.Exit(1)
}
if !resp {
fmt.Print("\nok, exiting\n")
os.Exit(0)
}
}
func AskYesNo(prompt string) (bool, error) {
filter := &yesNoFilter{}
if _, err := Ask(prompt, filter.Accept); err != nil {
return false, err
}
return filter.result, nil
}
func AskYesNoWithDefault(prompt string, defaultVal bool) (bool, error) {
filter := &yesNoDefaultFilter{
defaultVal: defaultVal,
}
if _, err := Ask(prompt, filter.Accept); err != nil {
return false, err
}
return filter.result, nil
}
func Ask(prompt string, f func(string) bool) (string, error) {
for {
val, err := term.Prompt(prompt)
if err != nil {
return "", err
}
val = strings.TrimSpace(val)
if f(val) {
return val, nil
}
fmt.Printf("Invalid input: %v\n", val)
}
}
type yesNoFilter struct {
result bool
}
func (self *yesNoFilter) Accept(s string) bool {
if strings.EqualFold("y", s) || strings.EqualFold("yes", s) {
self.result = true
return true
}
if strings.EqualFold("n", s) || strings.EqualFold("no", s) {
self.result = false
return true
}
return false
}
type yesNoDefaultFilter struct {
result bool
defaultVal bool
}
func (self *yesNoDefaultFilter) Accept(s string) bool {
if s == "" {
self.result = self.defaultVal
return true
}
if strings.EqualFold("y", s) || strings.EqualFold("yes", s) {
self.result = true
return true
}
if strings.EqualFold("n", s) || strings.EqualFold("no", s) {
self.result = false
return true
}
return false
}
type WriterWrapper struct {
c *color.Color
w io.Writer
}
func (self *WriterWrapper) Write(p []byte) (n int, err error) {
return self.c.Fprint(self.w, string(p))
}
-35
View File
@@ -1,35 +0,0 @@
package tutorial
import (
"strings"
"unicode"
)
func ParseArgumentsWithStrings(val string) []string {
var result []string
current := &strings.Builder{}
inString := false
for _, r := range val {
if r == '\'' {
if inString {
inString = false
} else {
inString = true
}
} else if !inString && unicode.IsSpace(r) {
if current.Len() > 0 {
result = append(result, current.String())
current.Reset()
}
} else {
current.WriteRune(r)
}
}
if current.Len() > 0 {
result = append(result, current.String())
}
return result
}
-37
View File
@@ -1,37 +0,0 @@
package tutorial
import (
"reflect"
"testing"
)
func TestParseArgumentsWithStrings(t *testing.T) {
tests := []struct {
name string
args string
want []string
}{
{
name: "one",
args: "one two three 'four five'",
want: []string{"one", "two", "three", "four five"},
},
{
name: "two",
args: " one two three 'four five' ",
want: []string{"one", "two", "three", "four five"},
},
{
name: "two",
args: " one two three 'four \"five\"' ",
want: []string{"one", "two", "three", "four \"five\""},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ParseArgumentsWithStrings(tt.args); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ParseArgumentsWithStrings() = %v, want %v", got, tt.want)
}
})
}
}
-379
View File
@@ -1,379 +0,0 @@
package tutorial
import (
"bytes"
"fmt"
markdown "github.com/MichaelMure/go-term-markdown"
"github.com/fatih/color"
"github.com/openziti/foundation/v2/term"
"github.com/pkg/errors"
"github.com/valyala/fasttemplate"
"io"
"os"
"sort"
"strings"
"time"
)
const (
codeActionBlockStart = "```action:"
codeActionBlockEnd = "```"
commentActionBlockStart = "<!---action:"
commentActionBlockEnd = "-->"
actionMarker = "f572d396fae9206628714fb2ce00f72e94f2258f"
)
var debug bool
func init() {
if val, found := os.LookupEnv("DEBUG"); found && strings.EqualFold(val, "true") {
debug = true
}
}
func NewRunner() *Runner {
result := &Runner{
actionHandlers: map[string]ActionHandler{},
variables: map[string]interface{}{},
LineWidth: 75,
LeftPad: 5,
NewLinePause: time.Millisecond * 20,
}
result.RegisterActionHandlerF("echo", func(ctx *ActionContext) error {
fmt.Printf("echo: %v", ctx.Body)
return nil
})
result.RegisterActionHandlerF("userInput", result.HandlePromptForInput)
result.RegisterActionHandlerF("pause", result.HandlePause)
return result
}
type ActionContext struct {
Action string
Headers map[string]string
Body string
Runner *Runner
}
type ActionHandler interface {
Execute(ctx *ActionContext) error
}
type ActionHandlerF func(ctx *ActionContext) error
func (self ActionHandlerF) Execute(ctx *ActionContext) error {
return self(ctx)
}
type Runner struct {
LineWidth int
LeftPad int
NewLinePause time.Duration
AssumeDefault bool
actionHandlers map[string]ActionHandler
actions []func() error
variables map[string]interface{}
}
func (self *Runner) AddVariable(name string, val interface{}) {
self.variables[name] = val
}
func (self *Runner) ClearVariable(name string) {
delete(self.variables, name)
}
func (self *Runner) Run(source []byte) error {
markdownSource, err := self.transformSource(source)
if err != nil {
return err
}
renderedMarkdown := markdown.Render(string(markdownSource), self.LineWidth, self.LeftPad)
return self.runMarkdown(renderedMarkdown)
}
func (self *Runner) runMarkdown(source []byte) error {
fmt.Println("")
pauseWriter := NewSlowWriter(self.NewLinePause)
for {
next := bytes.Index(source, []byte(actionMarker))
if next < 0 {
if err := self.EmitTemplatized(string(source), pauseWriter); err != nil {
return err
}
fmt.Println("")
return nil
}
if next == 0 {
source = source[len(actionMarker):]
action := self.nextAction()
if err := action(); err != nil {
return err
}
} else {
md := source[0:next]
if err := self.EmitTemplatized(string(md), pauseWriter); err != nil {
return err
}
source = source[next:]
}
}
}
func (self *Runner) nextAction() func() error {
result := self.actions[0]
self.actions = self.actions[1:]
return result
}
func (self *Runner) transformSource(source []byte) ([]byte, error) {
var result []byte
for {
if len(source) == 0 {
return result, nil
}
var behavior parseBehavior
if CodeAction.IsStarting(source) {
behavior = CodeAction
} else if CommentAction.IsStarting(source) {
behavior = CommentAction
}
if behavior != nil {
source = source[len(behavior.GetStartToken()):]
endIndex := bytes.Index(source, []byte(behavior.GetEndToken()))
if endIndex < 0 {
return nil, errors.Errorf("no end %v found for action block", behavior.GetEndToken())
}
actionSource := source[:endIndex]
source = source[endIndex+len(behavior.GetEndToken()):]
var actionHeader, body string
nlIndex := bytes.IndexByte(actionSource, '\n')
if nlIndex < 1 {
actionHeader = string(actionSource)
} else {
actionHeader = strings.TrimSpace(string(actionSource[:nlIndex]))
body = strings.TrimSpace(string(actionSource[nlIndex+1 : endIndex]))
}
actionDef := strings.TrimSpace(actionHeader)
action, headers, err := self.parseAction(actionDef)
if err != nil {
return nil, err
}
handler, ok := self.actionHandlers[action]
if !ok {
return nil, errors.Errorf("no handler found for action: %v. Available: %+v", action, self.actionIds())
}
ctx := &ActionContext{
Action: action,
Headers: headers,
Body: body,
Runner: self,
}
self.actions = append(self.actions, func() error {
return handler.Execute(ctx)
})
result = append(result, []byte(actionMarker)...)
} else {
result = append(result, source[0])
source = source[1:]
}
}
}
func (self *Runner) parseAction(s string) (string, map[string]string, error) {
var action string
headers := map[string]string{}
idx := strings.IndexByte(s, ' ')
if idx < 1 {
return s, headers, nil
}
action = s[:idx]
rest := s[idx+1:]
for len(rest) > 0 {
idx = strings.IndexByte(rest, '=')
if idx < 0 {
headers[rest] = ""
if debug {
fmt.Printf("%v: added %v=%v\n", action, rest, headers[rest])
}
rest = ""
} else if idx == 0 {
return "", nil, errors.Errorf("unable to parse action %v, unexpected =", action)
} else {
key := rest[:idx]
rest = rest[idx+1:]
if rest[0] == '\'' {
rest = rest[1:]
closingQuoteIdx := strings.IndexByte(rest, '\'')
if closingQuoteIdx < 0 {
return "", nil, errors.Errorf("unable to parse action %v, unclosed single-quote", action)
}
headers[key] = rest[:closingQuoteIdx]
if debug {
fmt.Printf("%v: added %v=%v\n", action, key, headers[key])
}
rest = rest[closingQuoteIdx+1:]
if len(rest) > 0 {
if rest[0] != ' ' {
return "", nil, errors.Errorf("unable to parse action %v, expected space after closing singe-quote", action)
} else {
rest = rest[1:]
}
}
} else {
idx = strings.IndexByte(rest, ' ')
if idx < 0 {
headers[key] = rest
if debug {
fmt.Printf("%v: added %v=%v\n", action, key, headers[key])
}
rest = ""
} else if idx == 0 {
headers[key] = ""
if debug {
fmt.Printf("%v: added %v=%v\n", action, key, headers[key])
}
rest = rest[1:]
} else {
headers[key] = rest[:idx]
if debug {
fmt.Printf("%v: added %v=%v\n", action, key, headers[key])
}
rest = rest[idx+1:]
}
}
}
}
return action, headers, nil
}
func (self *Runner) actionIds() []string {
var result []string
for k := range self.actionHandlers {
result = append(result, k)
}
sort.Strings(result)
return result
}
func (self *Runner) RegisterActionHandler(action string, handler ActionHandler) {
self.actionHandlers[action] = handler
}
func (self *Runner) RegisterActionHandlerF(action string, handler func(ctx *ActionContext) error) {
self.actionHandlers[action] = ActionHandlerF(handler)
}
func (self *Runner) LeftPadBuilder(b *strings.Builder) {
for i := 0; i < self.LeftPad; i++ {
b.WriteRune(' ')
}
}
func (self *Runner) EmitTemplatized(s string, out io.Writer) error {
_, err := fasttemplate.ExecuteFunc(s, "${", "}", out, func(w io.Writer, tag string) (int, error) {
tag = strings.ReplaceAll(tag, "\n", "") // in case we hit a line-break
tag = strings.ReplaceAll(tag, " ", "") // in case we hit a line-break
val, ok := self.variables[tag]
if !ok {
return 0, errors.Errorf("unknown template value: '%v'", tag)
}
buf := []byte(fmt.Sprintf("%v", val))
return w.Write(buf)
})
return err
}
func (self *Runner) Template(s string) (string, error) {
buf := &strings.Builder{}
_, err := fasttemplate.ExecuteFunc(s, "${", "}", buf, func(w io.Writer, tag string) (int, error) {
val, ok := self.variables[tag]
if !ok {
return 0, errors.Errorf("unknown template value: '%v'", tag)
}
buf := []byte(fmt.Sprintf("%v", val))
return w.Write(buf)
})
return buf.String(), err
}
func (self *Runner) HandlePromptForInput(ctx *ActionContext) error {
varName, ok := ctx.Headers["variable"]
if !ok {
return errors.New("prompt must specify which variable to set")
}
var val string
var err error
for val == "" {
val, err = term.Prompt(ctx.Body + " ")
if err != nil {
return err
}
}
ctx.Runner.AddVariable(varName, val)
return nil
}
func (self *Runner) HandlePause(*ActionContext) error {
if !self.AssumeDefault {
c := color.New(color.FgHiWhite, color.Bold)
_, err := term.Prompt(c.Sprintf("Press enter to continue: "))
return err
}
return nil
}
type parseBehavior interface {
IsStarting(source []byte) bool
GetStartToken() string
GetEndToken() string
}
type CodeActionBlock struct{}
func (self CodeActionBlock) IsStarting(source []byte) bool {
return startsWith(source, []byte(codeActionBlockStart))
}
func (self CodeActionBlock) GetStartToken() string {
return codeActionBlockStart
}
func (self CodeActionBlock) GetEndToken() string {
return codeActionBlockEnd
}
type CommentActionBlock struct{}
func (self CommentActionBlock) IsStarting(source []byte) bool {
return startsWith(source, []byte(commentActionBlockStart))
}
func (self CommentActionBlock) GetStartToken() string {
return commentActionBlockStart
}
func (self CommentActionBlock) GetEndToken() string {
return commentActionBlockEnd
}
func startsWith(b []byte, val []byte) bool {
if len(b) < len(val) {
return false
}
return bytes.Equal(b[:len(val)], val)
}
var CodeAction = CodeActionBlock{}
var CommentAction = CommentActionBlock{}
-64
View File
@@ -1,64 +0,0 @@
package tutorial
import (
"fmt"
"github.com/alecthomas/chroma/quick"
"github.com/pkg/errors"
)
func NewShowActionHandler() *ShowActionHandler {
return &ShowActionHandler{
data: map[string]string{},
}
}
type ShowActionHandler struct {
data map[string]string
}
func (self *ShowActionHandler) Execute(ctx *ActionContext) error {
name, ok := ctx.Headers["src"]
if !ok {
return errors.New("no name specified in show")
}
content, ok := self.data[name]
if !ok {
return errors.Errorf("no contents found to show for name: '%v'", name)
}
if !ctx.Runner.AssumeDefault {
view, err := AskYesNoWithDefault(fmt.Sprintf("View source for %v? [Y/N] (default N): ", name), false)
if err != nil {
return err
}
if !view {
return nil
}
}
codeWriter := NewSlowWriter(ctx.Runner.NewLinePause)
fmt.Println("")
fmt.Printf("%v:\n", name)
for i := 0; i < 80; i++ {
fmt.Print("-")
}
fmt.Println("")
if lang, found := ctx.Headers["highlight"]; found {
if err := quick.Highlight(codeWriter, content, lang, "terminal", "friendly"); err != nil {
return err
}
} else {
_, _ = fmt.Fprintln(codeWriter, content)
}
for i := 0; i < 80; i++ {
fmt.Print("-")
}
fmt.Println("")
return ctx.Runner.HandlePause(ctx)
}
func (self *ShowActionHandler) Add(name, contents string) {
self.data[name] = contents
}
-43
View File
@@ -1,43 +0,0 @@
package tutorial
import (
"io"
"os"
"time"
)
func NewSlowWriter(newlinePause time.Duration) io.Writer {
return &slowWriter{
delay: newlinePause,
}
}
type slowWriter struct {
delay time.Duration
}
func (self *slowWriter) Write(p []byte) (n int, err error) {
var buf []byte
written := 0
for _, b := range p {
buf = append(buf, b)
if b == '\n' {
time.Sleep(self.delay)
n, err := os.Stdout.Write(buf)
buf = buf[0:0]
written += n
if err != nil {
return written, err
}
}
}
if len(buf) > 0 {
n, err := os.Stdout.Write(buf)
written += n
if err != nil {
return written, err
}
}
return written, nil
}