Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/local-app/cmd/workspace-delete.go
2497 views
1
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"context"
9
"log/slog"
10
"time"
11
12
"github.com/bufbuild/connect-go"
13
v1 "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1"
14
"github.com/spf13/cobra"
15
)
16
17
// stopWorkspaceCommand stops to a given workspace
18
var workspaceDeleteCmd = &cobra.Command{
19
Use: "delete <workspace-id>",
20
Short: "Deletes a given workspace",
21
Args: cobra.ExactArgs(1),
22
RunE: func(cmd *cobra.Command, args []string) error {
23
workspaceID := args[0]
24
25
ctx, cancel := context.WithTimeout(cmd.Context(), 30*time.Second)
26
defer cancel()
27
28
gitpod, err := getGitpodClient(ctx)
29
if err != nil {
30
return err
31
}
32
33
slog.Debug("Attempting to delete workspace...")
34
_, err = gitpod.Workspaces.DeleteWorkspace(ctx, connect.NewRequest(&v1.DeleteWorkspaceRequest{WorkspaceId: workspaceID}))
35
36
return err
37
},
38
}
39
40
func init() {
41
workspaceCmd.AddCommand(workspaceDeleteCmd)
42
}
43
44