chore(deps): replace coral with latest cobra

This commit is contained in:
Johan Siebens
2023-03-08 07:43:03 +01:00
parent b7b3796ae6
commit 2fc79ee0a1
18 changed files with 185 additions and 184 deletions
+3 -3
View File
@@ -28,11 +28,12 @@ require (
github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/pointerstructure v1.2.1 github.com/mitchellh/pointerstructure v1.2.1
github.com/mr-tron/base58 v1.2.0 github.com/mr-tron/base58 v1.2.0
github.com/muesli/coral v1.0.0
github.com/nleeper/goment v1.4.4 github.com/nleeper/goment v1.4.4
github.com/ory/dockertest/v3 v3.9.1
github.com/prometheus/client_golang v1.13.0 github.com/prometheus/client_golang v1.13.0
github.com/rodaine/table v1.0.1 github.com/rodaine/table v1.0.1
github.com/sony/sonyflake v1.1.0 github.com/sony/sonyflake v1.1.0
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.0 github.com/stretchr/testify v1.8.0
github.com/xhit/go-str2duration/v2 v2.0.0 github.com/xhit/go-str2duration/v2 v2.0.0
golang.org/x/crypto v0.1.0 golang.org/x/crypto v0.1.0
@@ -103,7 +104,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa // indirect github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect github.com/googleapis/gax-go/v2 v2.4.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgio v1.0.0 // indirect
@@ -132,7 +133,6 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
github.com/opencontainers/runc v1.1.2 // indirect github.com/opencontainers/runc v1.1.2 // indirect
github.com/ory/dockertest/v3 v3.9.1 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect
+6 -5
View File
@@ -241,7 +241,7 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
@@ -565,8 +565,9 @@ github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
@@ -814,8 +815,6 @@ github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5/go.mod h1:
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
github.com/muesli/coral v1.0.0 h1:odyqkoEg4aJAINOzvnjN4tUsdp+Zleccs7tRIAkkYzU=
github.com/muesli/coral v1.0.0/go.mod h1:bf91M/dkp7iHQw73HOoR9PekdTJMTD6ihJgWoDitde8=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo=
@@ -972,6 +971,8 @@ github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
@@ -1766,8 +1767,8 @@ gorm.io/gorm v1.24.0 h1:j/CoiSm6xpRpmzbFJsQHYj+I8bGYWLXVHeYEyyKlF74=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/plugin/prometheus v0.0.0-20221204031128-799a96c40bf9 h1:LvPtKOKrtPfXxiP1iX7mgb5K1Z82KIhE5/WOycFk+1I= gorm.io/plugin/prometheus v0.0.0-20221204031128-799a96c40bf9 h1:LvPtKOKrtPfXxiP1iX7mgb5K1Z82KIhE5/WOycFk+1I=
gorm.io/plugin/prometheus v0.0.0-20221204031128-799a96c40bf9/go.mod h1:v4jeQnuOCPB9ENA2mTkYKdBkMcmRuYK0Hd+7DiUCCFA= gorm.io/plugin/prometheus v0.0.0-20221204031128-799a96c40bf9/go.mod h1:v4jeQnuOCPB9ENA2mTkYKdBkMcmRuYK0Hd+7DiUCCFA=
gotest.tools/v3 v3.0.2 h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+10 -10
View File
@@ -8,13 +8,13 @@ import (
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
"github.com/jsiebens/go-edit/editor" "github.com/jsiebens/go-edit/editor"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral" "github.com/spf13/cobra"
"io/ioutil" "io/ioutil"
"os" "os"
) )
func getACLConfigCommand() *coral.Command { func getACLConfigCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get-acl-policy", Use: "get-acl-policy",
Short: "Get the ACL policy", Short: "Get the ACL policy",
SilenceUsage: true, SilenceUsage: true,
@@ -29,7 +29,7 @@ func getACLConfigCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(cmd *coral.Command, args []string) error { command.RunE = func(cmd *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -58,8 +58,8 @@ func getACLConfigCommand() *coral.Command {
return command return command
} }
func editACLConfigCommand() *coral.Command { func editACLConfigCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "edit-acl-policy", Use: "edit-acl-policy",
Short: "Edit the ACL policy", Short: "Edit the ACL policy",
SilenceUsage: true, SilenceUsage: true,
@@ -74,7 +74,7 @@ func editACLConfigCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(cmd *coral.Command, args []string) error { command.RunE = func(cmd *cobra.Command, args []string) error {
edit := editor.NewDefaultEditor([]string{"IONSCALE_EDITOR", "EDITOR"}) edit := editor.NewDefaultEditor([]string{"IONSCALE_EDITOR", "EDITOR"})
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
@@ -122,8 +122,8 @@ func editACLConfigCommand() *coral.Command {
return command return command
} }
func setACLConfigCommand() *coral.Command { func setACLConfigCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "set-acl-policy", Use: "set-acl-policy",
Short: "Set ACL policy", Short: "Set ACL policy",
SilenceUsage: true, SilenceUsage: true,
@@ -140,7 +140,7 @@ func setACLConfigCommand() *coral.Command {
command.Flags().StringVar(&file, "file", "", "Path to json file with the acl configuration") command.Flags().StringVar(&file, "file", "", "Path to json file with the acl configuration")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(cmd *coral.Command, args []string) error { command.RunE = func(cmd *cobra.Command, args []string) error {
rawJson, err := ioutil.ReadFile(file) rawJson, err := ioutil.ReadFile(file)
if err != nil { if err != nil {
return err return err
+6 -6
View File
@@ -6,11 +6,11 @@ import (
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
"github.com/jsiebens/ionscale/pkg/client/ionscale" "github.com/jsiebens/ionscale/pkg/client/ionscale"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
func authCommand() *coral.Command { func authCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "auth", Use: "auth",
} }
@@ -19,8 +19,8 @@ func authCommand() *coral.Command {
return command return command
} }
func authLoginCommand() *coral.Command { func authLoginCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "login", Use: "login",
SilenceUsage: true, SilenceUsage: true,
} }
@@ -29,7 +29,7 @@ func authLoginCommand() *coral.Command {
target.prepareCommand(command) target.prepareCommand(command)
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
+12 -12
View File
@@ -5,16 +5,16 @@ import (
"fmt" "fmt"
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral"
"github.com/rodaine/table" "github.com/rodaine/table"
"github.com/spf13/cobra"
str2dur "github.com/xhit/go-str2duration/v2" str2dur "github.com/xhit/go-str2duration/v2"
"google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/durationpb"
"strings" "strings"
"time" "time"
) )
func authkeysCommand() *coral.Command { func authkeysCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "auth-keys", Use: "auth-keys",
Aliases: []string{"auth-key"}, Aliases: []string{"auth-key"},
Short: "Manage ionscale auth keys", Short: "Manage ionscale auth keys",
@@ -27,8 +27,8 @@ func authkeysCommand() *coral.Command {
return command return command
} }
func createAuthkeysCommand() *coral.Command { func createAuthkeysCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "create", Use: "create",
Short: "Creates a new auth key in the specified tailnet", Short: "Creates a new auth key in the specified tailnet",
SilenceUsage: true, SilenceUsage: true,
@@ -51,7 +51,7 @@ func createAuthkeysCommand() *coral.Command {
command.Flags().BoolVar(&preAuthorized, "pre-authorized", false, "Generate an auth key which is pre-authorized.") command.Flags().BoolVar(&preAuthorized, "pre-authorized", false, "Generate an auth key which is pre-authorized.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -98,8 +98,8 @@ func createAuthkeysCommand() *coral.Command {
return command return command
} }
func deleteAuthKeyCommand() *coral.Command { func deleteAuthKeyCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "delete", Use: "delete",
Short: "Delete a specified auth key", Short: "Delete a specified auth key",
SilenceUsage: true, SilenceUsage: true,
@@ -110,7 +110,7 @@ func deleteAuthKeyCommand() *coral.Command {
target.prepareCommand(command) target.prepareCommand(command)
command.Flags().Uint64Var(&authKeyId, "id", 0, "Auth Key ID") command.Flags().Uint64Var(&authKeyId, "id", 0, "Auth Key ID")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
grpcClient, err := target.createGRPCClient() grpcClient, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -129,8 +129,8 @@ func deleteAuthKeyCommand() *coral.Command {
return command return command
} }
func listAuthkeysCommand() *coral.Command { func listAuthkeysCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "list", Use: "list",
Short: "List all auth keys for a given tailnet", Short: "List all auth keys for a given tailnet",
SilenceUsage: true, SilenceUsage: true,
@@ -145,7 +145,7 @@ func listAuthkeysCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
+5 -5
View File
@@ -5,13 +5,13 @@ import (
"fmt" "fmt"
"github.com/jsiebens/ionscale/internal/config" "github.com/jsiebens/ionscale/internal/config"
"github.com/jsiebens/ionscale/internal/key" "github.com/jsiebens/ionscale/internal/key"
"github.com/muesli/coral" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"path/filepath" "path/filepath"
) )
func configureCommand() *coral.Command { func configureCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "configure", Use: "configure",
Short: "Generate a simple config file to get started.", Short: "Generate a simple config file to get started.",
SilenceUsage: true, SilenceUsage: true,
@@ -33,7 +33,7 @@ func configureCommand() *coral.Command {
command.MarkFlagRequired("domain") command.MarkFlagRequired("domain")
command.PreRunE = func(cmd *coral.Command, args []string) error { command.PreRunE = func(cmd *cobra.Command, args []string) error {
if domain == "" { if domain == "" {
return errors.New("required flag 'domain' is missing") return errors.New("required flag 'domain' is missing")
} }
@@ -49,7 +49,7 @@ func configureCommand() *coral.Command {
return nil return nil
} }
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
c := &config.Config{} c := &config.Config{}
c.HttpListenAddr = "0.0.0.0:80" c.HttpListenAddr = "0.0.0.0:80"
+12 -12
View File
@@ -6,14 +6,14 @@ import (
"fmt" "fmt"
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"os" "os"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
) )
func systemCommand() *coral.Command { func systemCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "system", Use: "system",
Short: "Manage global system configurations", Short: "Manage global system configurations",
} }
@@ -25,8 +25,8 @@ func systemCommand() *coral.Command {
return command return command
} }
func getDefaultDERPMap() *coral.Command { func getDefaultDERPMap() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get-derp-map", Use: "get-derp-map",
Short: "Get the DERP Map configuration", Short: "Get the DERP Map configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -38,7 +38,7 @@ func getDefaultDERPMap() *coral.Command {
target.prepareCommand(command) target.prepareCommand(command)
command.Flags().BoolVar(&asJson, "json", false, "When enabled, render output as json otherwise yaml") command.Flags().BoolVar(&asJson, "json", false, "When enabled, render output as json otherwise yaml")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -80,8 +80,8 @@ func getDefaultDERPMap() *coral.Command {
return command return command
} }
func setDefaultDERPMap() *coral.Command { func setDefaultDERPMap() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "set-derp-map", Use: "set-derp-map",
Short: "Set the DERP Map configuration", Short: "Set the DERP Map configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -92,7 +92,7 @@ func setDefaultDERPMap() *coral.Command {
target.prepareCommand(command) target.prepareCommand(command)
command.Flags().StringVar(&file, "file", "", "Path to json file with the DERP Map configuration") command.Flags().StringVar(&file, "file", "", "Path to json file with the DERP Map configuration")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
grpcClient, err := target.createGRPCClient() grpcClient, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -121,8 +121,8 @@ func setDefaultDERPMap() *coral.Command {
return command return command
} }
func resetDefaultDERPMap() *coral.Command { func resetDefaultDERPMap() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "reset-derp-map", Use: "reset-derp-map",
Short: "Reset the DERP Map to the default configuration", Short: "Reset the DERP Map to the default configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -131,7 +131,7 @@ func resetDefaultDERPMap() *coral.Command {
var target = Target{} var target = Target{}
target.prepareCommand(command) target.prepareCommand(command)
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
grpcClient, err := target.createGRPCClient() grpcClient, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
+7 -7
View File
@@ -5,14 +5,14 @@ import (
"fmt" "fmt"
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral" "github.com/spf13/cobra"
"os" "os"
"strings" "strings"
"text/tabwriter" "text/tabwriter"
) )
func getDNSConfigCommand() *coral.Command { func getDNSConfigCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get-dns", Use: "get-dns",
Short: "Get DNS configuration", Short: "Get DNS configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -27,7 +27,7 @@ func getDNSConfigCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -82,8 +82,8 @@ func getDNSConfigCommand() *coral.Command {
return command return command
} }
func setDNSConfigCommand() *coral.Command { func setDNSConfigCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "set-dns", Use: "set-dns",
Short: "Set DNS config", Short: "Set DNS config",
SilenceUsage: true, SilenceUsage: true,
@@ -105,7 +105,7 @@ func setDNSConfigCommand() *coral.Command {
command.Flags().BoolVarP(&overrideLocalDNS, "override-local-dns", "", false, "When enabled, connected clients ignore local DNS settings and always use the nameservers specified for this Tailnet") command.Flags().BoolVarP(&overrideLocalDNS, "override-local-dns", "", false, "When enabled, connected clients ignore local DNS settings and always use the nameservers specified for this Tailnet")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
+2 -2
View File
@@ -7,10 +7,10 @@ import (
"github.com/jsiebens/ionscale/pkg/client/ionscale" "github.com/jsiebens/ionscale/pkg/client/ionscale"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
apiconnect "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1/ionscalev1connect" apiconnect "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1/ionscalev1connect"
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
func checkRequiredTailnetAndTailnetIdFlags(cmd *coral.Command, args []string) error { func checkRequiredTailnetAndTailnetIdFlags(cmd *cobra.Command, args []string) error {
savedTailnetID, err := ionscale.TailnetFromFile() savedTailnetID, err := ionscale.TailnetFromFile()
if err != nil { if err != nil {
return err return err
+10 -10
View File
@@ -8,13 +8,13 @@ import (
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
"github.com/jsiebens/go-edit/editor" "github.com/jsiebens/go-edit/editor"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral" "github.com/spf13/cobra"
"io/ioutil" "io/ioutil"
"os" "os"
) )
func getIAMPolicyCommand() *coral.Command { func getIAMPolicyCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get-iam-policy", Use: "get-iam-policy",
Short: "Get the IAM policy", Short: "Get the IAM policy",
SilenceUsage: true, SilenceUsage: true,
@@ -29,7 +29,7 @@ func getIAMPolicyCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(cmd *coral.Command, args []string) error { command.RunE = func(cmd *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -58,8 +58,8 @@ func getIAMPolicyCommand() *coral.Command {
return command return command
} }
func editIAMPolicyCommand() *coral.Command { func editIAMPolicyCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "edit-iam-policy", Use: "edit-iam-policy",
Short: "Edit the IAM policy", Short: "Edit the IAM policy",
SilenceUsage: true, SilenceUsage: true,
@@ -74,7 +74,7 @@ func editIAMPolicyCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(cmd *coral.Command, args []string) error { command.RunE = func(cmd *cobra.Command, args []string) error {
edit := editor.NewDefaultEditor([]string{"IONSCALE_EDITOR", "EDITOR"}) edit := editor.NewDefaultEditor([]string{"IONSCALE_EDITOR", "EDITOR"})
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
@@ -122,8 +122,8 @@ func editIAMPolicyCommand() *coral.Command {
return command return command
} }
func setIAMPolicyCommand() *coral.Command { func setIAMPolicyCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "set-iam-policy", Use: "set-iam-policy",
Short: "Set IAM policy", Short: "Set IAM policy",
SilenceUsage: true, SilenceUsage: true,
@@ -140,7 +140,7 @@ func setIAMPolicyCommand() *coral.Command {
command.Flags().StringVar(&file, "file", "", "Path to json file with the acl configuration") command.Flags().StringVar(&file, "file", "", "Path to json file with the acl configuration")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(cmd *coral.Command, args []string) error { command.RunE = func(cmd *cobra.Command, args []string) error {
rawJson, err := ioutil.ReadFile(file) rawJson, err := ioutil.ReadFile(file)
if err != nil { if err != nil {
return err return err
+4 -4
View File
@@ -3,11 +3,11 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/jsiebens/ionscale/internal/key" "github.com/jsiebens/ionscale/internal/key"
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
func keyCommand() *coral.Command { func keyCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "genkey", Use: "genkey",
SilenceUsage: true, SilenceUsage: true,
} }
@@ -16,7 +16,7 @@ func keyCommand() *coral.Command {
command.Flags().BoolVarP(&disableNewLine, "no-newline", "n", false, "do not output a trailing newline") command.Flags().BoolVarP(&disableNewLine, "no-newline", "n", false, "do not output a trailing newline")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
serverKey := key.NewServerKey() serverKey := key.NewServerKey()
if disableNewLine { if disableNewLine {
fmt.Print(serverKey.String()) fmt.Print(serverKey.String())
+39 -39
View File
@@ -5,17 +5,17 @@ import (
"fmt" "fmt"
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral"
"github.com/nleeper/goment" "github.com/nleeper/goment"
"github.com/rodaine/table" "github.com/rodaine/table"
"github.com/spf13/cobra"
"inet.af/netaddr" "inet.af/netaddr"
"os" "os"
"strings" "strings"
"text/tabwriter" "text/tabwriter"
) )
func machineCommands() *coral.Command { func machineCommands() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "machines", Use: "machines",
Aliases: []string{"machine"}, Aliases: []string{"machine"},
Short: "Manage ionscale machines", Short: "Manage ionscale machines",
@@ -38,8 +38,8 @@ func machineCommands() *coral.Command {
return command return command
} }
func getMachineCommand() *coral.Command { func getMachineCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get", Use: "get",
Short: "Retrieve detailed information for a machine", Short: "Retrieve detailed information for a machine",
SilenceUsage: true, SilenceUsage: true,
@@ -52,7 +52,7 @@ func getMachineCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -150,8 +150,8 @@ func getMachineCommand() *coral.Command {
return command return command
} }
func deleteMachineCommand() *coral.Command { func deleteMachineCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "delete", Use: "delete",
Short: "Deletes a machine", Short: "Deletes a machine",
SilenceUsage: true, SilenceUsage: true,
@@ -164,7 +164,7 @@ func deleteMachineCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -183,8 +183,8 @@ func deleteMachineCommand() *coral.Command {
return command return command
} }
func expireMachineCommand() *coral.Command { func expireMachineCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "expire", Use: "expire",
Short: "Expires a machine", Short: "Expires a machine",
SilenceUsage: true, SilenceUsage: true,
@@ -197,7 +197,7 @@ func expireMachineCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -216,8 +216,8 @@ func expireMachineCommand() *coral.Command {
return command return command
} }
func authorizeMachineCommand() *coral.Command { func authorizeMachineCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "authorize", Use: "authorize",
Short: "Authorizes a machine", Short: "Authorizes a machine",
SilenceUsage: true, SilenceUsage: true,
@@ -230,7 +230,7 @@ func authorizeMachineCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -249,8 +249,8 @@ func authorizeMachineCommand() *coral.Command {
return command return command
} }
func listMachinesCommand() *coral.Command { func listMachinesCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "list", Use: "list",
Short: "List machines", Short: "List machines",
SilenceUsage: true, SilenceUsage: true,
@@ -265,7 +265,7 @@ func listMachinesCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -304,8 +304,8 @@ func listMachinesCommand() *coral.Command {
return command return command
} }
func getMachineRoutesCommand() *coral.Command { func getMachineRoutesCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get-routes", Use: "get-routes",
Short: "Show routes advertised and enabled by a given machine", Short: "Show routes advertised and enabled by a given machine",
SilenceUsage: true, SilenceUsage: true,
@@ -318,7 +318,7 @@ func getMachineRoutesCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
grpcClient, err := target.createGRPCClient() grpcClient, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -338,8 +338,8 @@ func getMachineRoutesCommand() *coral.Command {
return command return command
} }
func enableMachineRoutesCommand() *coral.Command { func enableMachineRoutesCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-routes", Use: "enable-routes",
Short: "Enable routes for a given machine", Short: "Enable routes for a given machine",
SilenceUsage: true, SilenceUsage: true,
@@ -356,7 +356,7 @@ func enableMachineRoutesCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -382,8 +382,8 @@ func enableMachineRoutesCommand() *coral.Command {
return command return command
} }
func disableMachineRoutesCommand() *coral.Command { func disableMachineRoutesCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-routes", Use: "disable-routes",
Short: "Disable routes for a given machine", Short: "Disable routes for a given machine",
SilenceUsage: true, SilenceUsage: true,
@@ -398,7 +398,7 @@ func disableMachineRoutesCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -424,8 +424,8 @@ func disableMachineRoutesCommand() *coral.Command {
return command return command
} }
func enableExitNodeCommand() *coral.Command { func enableExitNodeCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-exit-node", Use: "enable-exit-node",
Short: "Enable given machine as an exit node", Short: "Enable given machine as an exit node",
SilenceUsage: true, SilenceUsage: true,
@@ -438,7 +438,7 @@ func enableExitNodeCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -458,8 +458,8 @@ func enableExitNodeCommand() *coral.Command {
return command return command
} }
func disableExitNodeCommand() *coral.Command { func disableExitNodeCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-exit-node", Use: "disable-exit-node",
Short: "Disable given machine as an exit node", Short: "Disable given machine as an exit node",
SilenceUsage: true, SilenceUsage: true,
@@ -472,7 +472,7 @@ func disableExitNodeCommand() *coral.Command {
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -492,8 +492,8 @@ func disableExitNodeCommand() *coral.Command {
return command return command
} }
func enableMachineKeyExpiryCommand() *coral.Command { func enableMachineKeyExpiryCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-key-expiry", Use: "enable-key-expiry",
Short: "Enable machine key expiry", Short: "Enable machine key expiry",
SilenceUsage: true, SilenceUsage: true,
@@ -502,8 +502,8 @@ func enableMachineKeyExpiryCommand() *coral.Command {
return configureSetMachineKeyExpiryCommand(command, false) return configureSetMachineKeyExpiryCommand(command, false)
} }
func disableMachineKeyExpiryCommand() *coral.Command { func disableMachineKeyExpiryCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-key-expiry", Use: "disable-key-expiry",
Short: "Disable machine key expiry", Short: "Disable machine key expiry",
SilenceUsage: true, SilenceUsage: true,
@@ -512,7 +512,7 @@ func disableMachineKeyExpiryCommand() *coral.Command {
return configureSetMachineKeyExpiryCommand(command, true) return configureSetMachineKeyExpiryCommand(command, true)
} }
func configureSetMachineKeyExpiryCommand(command *coral.Command, v bool) *coral.Command { func configureSetMachineKeyExpiryCommand(command *cobra.Command, v bool) *cobra.Command {
var machineID uint64 var machineID uint64
var target = Target{} var target = Target{}
target.prepareCommand(command) target.prepareCommand(command)
@@ -520,7 +520,7 @@ func configureSetMachineKeyExpiryCommand(command *coral.Command, v bool) *coral.
_ = command.MarkFlagRequired("machine-id") _ = command.MarkFlagRequired("machine-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
+4 -4
View File
@@ -1,10 +1,10 @@
package cmd package cmd
import ( import (
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
func Command() *coral.Command { func Command() *cobra.Command {
rootCmd := rootCommand() rootCmd := rootCommand()
rootCmd.AddCommand(configureCommand()) rootCmd.AddCommand(configureCommand())
rootCmd.AddCommand(keyCommand()) rootCmd.AddCommand(keyCommand())
@@ -24,8 +24,8 @@ func Execute() error {
return Command().Execute() return Command().Execute()
} }
func rootCommand() *coral.Command { func rootCommand() *cobra.Command {
return &coral.Command{ return &cobra.Command{
Use: "ionscale", Use: "ionscale",
} }
} }
+4 -4
View File
@@ -3,11 +3,11 @@ package cmd
import ( import (
"github.com/jsiebens/ionscale/internal/config" "github.com/jsiebens/ionscale/internal/config"
"github.com/jsiebens/ionscale/internal/server" "github.com/jsiebens/ionscale/internal/server"
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
func serverCommand() *coral.Command { func serverCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "server", Use: "server",
Short: "Start an ionscale server", Short: "Start an ionscale server",
SilenceUsage: true, SilenceUsage: true,
@@ -17,7 +17,7 @@ func serverCommand() *coral.Command {
command.Flags().StringVarP(&configFile, "config", "c", "", "Path to the configuration file.") command.Flags().StringVarP(&configFile, "config", "c", "", "Path to the configuration file.")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
c, err := config.LoadConfig(configFile) c, err := config.LoadConfig(configFile)
if err != nil { if err != nil {
+46 -46
View File
@@ -8,16 +8,16 @@ import (
idomain "github.com/jsiebens/ionscale/internal/domain" idomain "github.com/jsiebens/ionscale/internal/domain"
"github.com/jsiebens/ionscale/pkg/defaults" "github.com/jsiebens/ionscale/pkg/defaults"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral"
"github.com/rodaine/table" "github.com/rodaine/table"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"os" "os"
"strings" "strings"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
) )
func tailnetCommand() *coral.Command { func tailnetCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "tailnets", Use: "tailnets",
Aliases: []string{"tailnet"}, Aliases: []string{"tailnet"},
Short: "Manage ionscale tailnets", Short: "Manage ionscale tailnets",
@@ -49,8 +49,8 @@ func tailnetCommand() *coral.Command {
return command return command
} }
func listTailnetsCommand() *coral.Command { func listTailnetsCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "list", Use: "list",
Short: "List available Tailnets", Short: "List available Tailnets",
SilenceUsage: true, SilenceUsage: true,
@@ -59,7 +59,7 @@ func listTailnetsCommand() *coral.Command {
var target = Target{} var target = Target{}
target.prepareCommand(command) target.prepareCommand(command)
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
@@ -84,8 +84,8 @@ func listTailnetsCommand() *coral.Command {
return command return command
} }
func createTailnetsCommand() *coral.Command { func createTailnetsCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "create", Use: "create",
Short: "Create a new Tailnet", Short: "Create a new Tailnet",
SilenceUsage: true, SilenceUsage: true,
@@ -101,7 +101,7 @@ func createTailnetsCommand() *coral.Command {
command.Flags().StringVar(&domain, "domain", "", "") command.Flags().StringVar(&domain, "domain", "", "")
command.Flags().StringVar(&email, "email", "", "") command.Flags().StringVar(&email, "email", "", "")
command.PreRunE = func(cmd *coral.Command, args []string) error { command.PreRunE = func(cmd *cobra.Command, args []string) error {
if name == "" { if name == "" {
return fmt.Errorf("flag --name is required") return fmt.Errorf("flag --name is required")
} }
@@ -111,7 +111,7 @@ func createTailnetsCommand() *coral.Command {
return nil return nil
} }
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
dnsConfig := defaults.DefaultDNSConfig() dnsConfig := defaults.DefaultDNSConfig()
aclPolicy := defaults.DefaultACLPolicy() aclPolicy := defaults.DefaultACLPolicy()
@@ -160,8 +160,8 @@ func createTailnetsCommand() *coral.Command {
return command return command
} }
func deleteTailnetCommand() *coral.Command { func deleteTailnetCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "delete", Use: "delete",
Short: "Delete a tailnet", Short: "Delete a tailnet",
SilenceUsage: true, SilenceUsage: true,
@@ -178,7 +178,7 @@ func deleteTailnetCommand() *coral.Command {
command.Flags().BoolVar(&force, "force", false, "When enabled, force delete the specified Tailnet even when machines are still available.") command.Flags().BoolVar(&force, "force", false, "When enabled, force delete the specified Tailnet even when machines are still available.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
@@ -204,8 +204,8 @@ func deleteTailnetCommand() *coral.Command {
return command return command
} }
func getDERPMap() *coral.Command { func getDERPMap() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "get-derp-map", Use: "get-derp-map",
Short: "Get the DERP Map configuration", Short: "Get the DERP Map configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -223,7 +223,7 @@ func getDERPMap() *coral.Command {
command.Flags().BoolVar(&asJson, "json", false, "When enabled, render output as json otherwise yaml") command.Flags().BoolVar(&asJson, "json", false, "When enabled, render output as json otherwise yaml")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -270,8 +270,8 @@ func getDERPMap() *coral.Command {
return command return command
} }
func setDERPMap() *coral.Command { func setDERPMap() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "set-derp-map", Use: "set-derp-map",
Short: "Set the DERP Map configuration", Short: "Set the DERP Map configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -288,7 +288,7 @@ func setDERPMap() *coral.Command {
command.Flags().StringVar(&file, "file", "", "Path to json file with the DERP Map configuration") command.Flags().StringVar(&file, "file", "", "Path to json file with the DERP Map configuration")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -322,8 +322,8 @@ func setDERPMap() *coral.Command {
return command return command
} }
func resetDERPMap() *coral.Command { func resetDERPMap() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "reset-derp-map", Use: "reset-derp-map",
Short: "Reset the DERP Map to the default configuration", Short: "Reset the DERP Map to the default configuration",
SilenceUsage: true, SilenceUsage: true,
@@ -338,7 +338,7 @@ func resetDERPMap() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -361,8 +361,8 @@ func resetDERPMap() *coral.Command {
return command return command
} }
func enableFileSharingCommand() *coral.Command { func enableFileSharingCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-file-sharing", Use: "enable-file-sharing",
Aliases: []string{"enable-taildrop"}, Aliases: []string{"enable-taildrop"},
Short: "Enable Taildrop, the file sharing feature", Short: "Enable Taildrop, the file sharing feature",
@@ -378,7 +378,7 @@ func enableFileSharingCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -403,8 +403,8 @@ func enableFileSharingCommand() *coral.Command {
return command return command
} }
func disableFileSharingCommand() *coral.Command { func disableFileSharingCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-file-sharing", Use: "disable-file-sharing",
Aliases: []string{"disable-taildrop"}, Aliases: []string{"disable-taildrop"},
Short: "Disable Taildrop, the file sharing feature", Short: "Disable Taildrop, the file sharing feature",
@@ -420,7 +420,7 @@ func disableFileSharingCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -445,8 +445,8 @@ func disableFileSharingCommand() *coral.Command {
return command return command
} }
func enableServiceCollectionCommand() *coral.Command { func enableServiceCollectionCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-service-collection", Use: "enable-service-collection",
Short: "Enable monitoring live services running on your networks machines.", Short: "Enable monitoring live services running on your networks machines.",
SilenceUsage: true, SilenceUsage: true,
@@ -461,7 +461,7 @@ func enableServiceCollectionCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -486,8 +486,8 @@ func enableServiceCollectionCommand() *coral.Command {
return command return command
} }
func disableServiceCollectionCommand() *coral.Command { func disableServiceCollectionCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-service-collection", Use: "disable-service-collection",
Short: "Disable monitoring live services running on your networks machines.", Short: "Disable monitoring live services running on your networks machines.",
SilenceUsage: true, SilenceUsage: true,
@@ -502,7 +502,7 @@ func disableServiceCollectionCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -527,8 +527,8 @@ func disableServiceCollectionCommand() *coral.Command {
return command return command
} }
func enableSSHCommand() *coral.Command { func enableSSHCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-ssh", Use: "enable-ssh",
Short: "Enable ssh access using tailnet and ACLs.", Short: "Enable ssh access using tailnet and ACLs.",
SilenceUsage: true, SilenceUsage: true,
@@ -543,7 +543,7 @@ func enableSSHCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -568,8 +568,8 @@ func enableSSHCommand() *coral.Command {
return command return command
} }
func disableSSHCommand() *coral.Command { func disableSSHCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-ssh", Use: "disable-ssh",
Short: "Disable ssh access using tailnet and ACLs.", Short: "Disable ssh access using tailnet and ACLs.",
SilenceUsage: true, SilenceUsage: true,
@@ -584,7 +584,7 @@ func disableSSHCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -609,8 +609,8 @@ func disableSSHCommand() *coral.Command {
return command return command
} }
func enableMachineAuthorizationCommand() *coral.Command { func enableMachineAuthorizationCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "enable-machine-authorization", Use: "enable-machine-authorization",
Short: "Enable machine authorization.", Short: "Enable machine authorization.",
SilenceUsage: true, SilenceUsage: true,
@@ -625,7 +625,7 @@ func enableMachineAuthorizationCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -650,8 +650,8 @@ func enableMachineAuthorizationCommand() *coral.Command {
return command return command
} }
func disableMachineAuthorizationCommand() *coral.Command { func disableMachineAuthorizationCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "disable-machine-authorization", Use: "disable-machine-authorization",
Short: "Disable machine authorization.", Short: "Disable machine authorization.",
SilenceUsage: true, SilenceUsage: true,
@@ -666,7 +666,7 @@ func disableMachineAuthorizationCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"github.com/jsiebens/ionscale/internal/config" "github.com/jsiebens/ionscale/internal/config"
"github.com/jsiebens/ionscale/pkg/client/ionscale" "github.com/jsiebens/ionscale/pkg/client/ionscale"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1/ionscalev1connect" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1/ionscalev1connect"
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
const ( const (
@@ -19,7 +19,7 @@ type Target struct {
systemAdminKey string systemAdminKey string
} }
func (t *Target) prepareCommand(cmd *coral.Command) { func (t *Target) prepareCommand(cmd *cobra.Command) {
cmd.Flags().StringVar(&t.addr, "addr", "", "Addr of the ionscale server, as a complete URL") cmd.Flags().StringVar(&t.addr, "addr", "", "Addr of the ionscale server, as a complete URL")
cmd.Flags().BoolVar(&t.insecureSkipVerify, "tls-skip-verify", false, "Disable verification of TLS certificates") cmd.Flags().BoolVar(&t.insecureSkipVerify, "tls-skip-verify", false, "Disable verification of TLS certificates")
cmd.Flags().StringVar(&t.systemAdminKey, "system-admin-key", "", "If specified, the given value will be used as the key to generate a Bearer token for the call. This can also be specified via the IONSCALE_ADMIN_KEY environment variable.") cmd.Flags().StringVar(&t.systemAdminKey, "system-admin-key", "", "If specified, the given value will be used as the key to generate a Bearer token for the call. This can also be specified via the IONSCALE_ADMIN_KEY environment variable.")
+9 -9
View File
@@ -5,12 +5,12 @@ import (
"fmt" "fmt"
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral"
"github.com/rodaine/table" "github.com/rodaine/table"
"github.com/spf13/cobra"
) )
func userCommands() *coral.Command { func userCommands() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "users", Use: "users",
Aliases: []string{"user"}, Aliases: []string{"user"},
Short: "Manage ionscale users", Short: "Manage ionscale users",
@@ -23,8 +23,8 @@ func userCommands() *coral.Command {
return command return command
} }
func listUsersCommand() *coral.Command { func listUsersCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "list", Use: "list",
Short: "List users", Short: "List users",
SilenceUsage: true, SilenceUsage: true,
@@ -39,7 +39,7 @@ func listUsersCommand() *coral.Command {
command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.") command.Flags().Uint64Var(&tailnetID, "tailnet-id", 0, "Tailnet ID. Mutually exclusive with --tailnet.")
command.PreRunE = checkRequiredTailnetAndTailnetIdFlags command.PreRunE = checkRequiredTailnetAndTailnetIdFlags
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
@@ -69,8 +69,8 @@ func listUsersCommand() *coral.Command {
return command return command
} }
func deleteUserCommand() *coral.Command { func deleteUserCommand() *cobra.Command {
command := &coral.Command{ command := &cobra.Command{
Use: "delete", Use: "delete",
Short: "Deletes a user", Short: "Deletes a user",
SilenceUsage: true, SilenceUsage: true,
@@ -83,7 +83,7 @@ func deleteUserCommand() *coral.Command {
_ = command.MarkFlagRequired("user-id") _ = command.MarkFlagRequired("user-id")
command.RunE = func(command *coral.Command, args []string) error { command.RunE = func(command *cobra.Command, args []string) error {
client, err := target.createGRPCClient() client, err := target.createGRPCClient()
if err != nil { if err != nil {
return err return err
+4 -4
View File
@@ -6,11 +6,11 @@ import (
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
"github.com/jsiebens/ionscale/internal/version" "github.com/jsiebens/ionscale/internal/version"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1" api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
"github.com/muesli/coral" "github.com/spf13/cobra"
) )
func versionCommand() *coral.Command { func versionCommand() *cobra.Command {
var command = &coral.Command{ var command = &cobra.Command{
Use: "version", Use: "version",
Short: "Display version information", Short: "Display version information",
SilenceUsage: true, SilenceUsage: true,
@@ -19,7 +19,7 @@ func versionCommand() *coral.Command {
var target = Target{} var target = Target{}
target.prepareCommand(command) target.prepareCommand(command)
command.Run = func(cmd *coral.Command, args []string) { command.Run = func(cmd *cobra.Command, args []string) {
clientVersion, clientRevision := version.GetReleaseInfo() clientVersion, clientRevision := version.GetReleaseInfo()
fmt.Printf(` fmt.Printf(`
Client: Client: