Skip to content

Commit 1d2e7c0

Browse files
committed
Implement webspace exec and webspace login
1 parent 9c86e03 commit 1d2e7c0

File tree

9 files changed

+373
-10
lines changed

9 files changed

+373
-10
lines changed

cmd/netsoc/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package main
22

33
import (
4+
"os"
5+
46
"github.com/netsoc/cli/pkg/cmd"
7+
"github.com/netsoc/cli/pkg/util"
58
)
69

710
func main() {
8-
cmd.NewCmdRoot().Execute()
11+
if err := cmd.NewCmdRoot().Execute(); err != nil {
12+
os.Exit(1)
13+
}
14+
15+
os.Exit(util.ExitCode)
916
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/mitchellh/mapstructure v1.3.3
1818
github.com/netsoc/iam/client v1.0.9
19-
github.com/netsoc/webspaced/client v1.1.0
19+
github.com/netsoc/webspaced/client v1.1.2
2020
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2121
github.com/spf13/cobra v1.0.0
2222
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
173173
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
174174
github.com/netsoc/iam/client v1.0.9 h1:hrOXe0cVYzsvIlkFNUsq98mE7lyZnS7wBnriiUAGAzc=
175175
github.com/netsoc/iam/client v1.0.9/go.mod h1:CA6PtAeTRVAx6AXb+DAjav7d754hNWcwEVFij9Nzsxg=
176-
github.com/netsoc/webspaced/client v1.1.0 h1:WmUS4C3ZirHeOvDbLoNIZsAziiR4NnAzCwDZXXWuxXU=
177-
github.com/netsoc/webspaced/client v1.1.0/go.mod h1:GFCOmONSPqvqD2LoglRBFrqr0GdUbN/7huvbsyXMRkU=
176+
github.com/netsoc/webspaced/client v1.1.2 h1:j+Sux/iqecUV+Ee/325o28dazWL0a114J3KY3loXkXY=
177+
github.com/netsoc/webspaced/client v1.1.2/go.mod h1:GFCOmONSPqvqD2LoglRBFrqr0GdUbN/7huvbsyXMRkU=
178178
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
179179
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
180180
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=

pkg/cmd/webspace/console.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@ import (
88
"os"
99

1010
"github.com/containerd/console"
11+
"github.com/gorilla/websocket"
1112
"github.com/spf13/cobra"
1213

1314
"github.com/netsoc/cli/pkg/config"
1415
"github.com/netsoc/cli/pkg/util"
15-
webspaced "github.com/netsoc/webspaced/client"
1616
)
1717

1818
type consoleOptions struct {
19-
Config func() (*config.Config, error)
20-
WebspacedClient func() (*webspaced.APIClient, error)
19+
Config func() (*config.Config, error)
2120

2221
User string
2322
}
2423

2524
// NewCmdConsole creates a new webspace console command
2625
func NewCmdConsole(f *util.CmdFactory) *cobra.Command {
2726
opts := consoleOptions{
28-
Config: f.Config,
29-
WebspacedClient: f.WebspacedClient,
27+
Config: f.Config,
3028
}
3129
cmd := &cobra.Command{
3230
Use: "console",
@@ -118,6 +116,12 @@ func consoleRun(opts consoleOptions) error {
118116
fmt.Print("\r\n")
119117
return nil
120118
case err := <-errChan:
119+
var ce *websocket.CloseError
120+
if errors.As(err, &ce) && ce.Code == websocket.CloseNormalClosure {
121+
fmt.Print("\r\n")
122+
return nil
123+
}
124+
121125
return err
122126
}
123127
}

0 commit comments

Comments
 (0)