Path: blob/main/components/local-app/cmd/workspace-delete.go
2497 views
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package cmd56import (7"context"8"log/slog"9"time"1011"github.com/bufbuild/connect-go"12v1 "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1"13"github.com/spf13/cobra"14)1516// stopWorkspaceCommand stops to a given workspace17var workspaceDeleteCmd = &cobra.Command{18Use: "delete <workspace-id>",19Short: "Deletes a given workspace",20Args: cobra.ExactArgs(1),21RunE: func(cmd *cobra.Command, args []string) error {22workspaceID := args[0]2324ctx, cancel := context.WithTimeout(cmd.Context(), 30*time.Second)25defer cancel()2627gitpod, err := getGitpodClient(ctx)28if err != nil {29return err30}3132slog.Debug("Attempting to delete workspace...")33_, err = gitpod.Workspaces.DeleteWorkspace(ctx, connect.NewRequest(&v1.DeleteWorkspaceRequest{WorkspaceId: workspaceID}))3435return err36},37}3839func init() {40workspaceCmd.AddCommand(workspaceDeleteCmd)41}424344