Skip to content

Commit eb66334

Browse files
committed
client/cordium - add --rm to run
1 parent b18746e commit eb66334

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

client/cordium/commands/create/workspace/cmd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ var Cmd = &cobra.Command{
6464
Short: "Create a Workspace",
6565
Example: `
6666
cordium create workspace
67-
cordium create ws -o json
68-
cordium create workspaces
67+
cordium create ws
68+
cordium create ws --space my-space
69+
cordium create ws --template my-template.my-space
6970
`,
7071
Aliases: []string{"workspaces", "ws"},
7172
RunE: func(cmd *cobra.Command, args []string) error {

client/cordium/commands/run/cmd.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"os"
23+
"time"
2324

2425
"github.com/octelium/cordium/client/cordium/commands/create/workspace"
2526
"github.com/octelium/cordium/client/cordium/commands/terminal"
@@ -37,6 +38,7 @@ import (
3738

3839
type args struct {
3940
workspace.CreateWorkspaceArgs
41+
DoRemove bool
4042
}
4143

4244
var cmdArgs args
@@ -51,12 +53,14 @@ func init() {
5153
Cmd.PersistentFlags().StringVarP(&cmdArgs.Dockerfile, "dockerfile", "", "",
5254
`Provide a Dockerfile file path to build the Container image from it`)
5355
Cmd.PersistentFlags().BoolVarP(&cmdArgs.Ephemeral, "ephemeral", "", false, "Set the Workspace storage to be ephemeral")
56+
Cmd.PersistentFlags().BoolVarP(&cmdArgs.DoRemove, "rm", "", false, "Automatically remove the Workspace after the run")
5457
}
5558

5659
var Cmd = &cobra.Command{
5760
Use: "run",
5861
Short: "Run a Workspace",
5962
Example: `
63+
cordium run
6064
cordium run abc
6165
`,
6266
RunE: func(cmd *cobra.Command, args []string) error {
@@ -105,7 +109,22 @@ func doCmd(cmd *cobra.Command, args []string) error {
105109
}
106110
}
107111

108-
return doRun(ctx, conn, ws)
112+
if err := doRun(ctx, conn, ws); err != nil {
113+
zap.L().Debug("doRun exited with err", zap.Error(err))
114+
}
115+
116+
if cmdArgs.DoRemove {
117+
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second)
118+
defer cancel()
119+
120+
if _, err := c.DeleteWorkspace(ctx, &metav1.DeleteOptions{
121+
Uid: ws.Metadata.Uid,
122+
}); err != nil {
123+
return err
124+
}
125+
}
126+
127+
return nil
109128
}
110129

111130
func doRun(ctx context.Context, conn *grpc.ClientConn, ws *pb.Workspace) error {

0 commit comments

Comments
 (0)