Path: blob/main/components/supervisor/cmd/terminal-close.go
2498 views
// Copyright (c) 2020 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"time"910"github.com/spf13/cobra"1112"github.com/gitpod-io/gitpod/common-go/log"13"github.com/gitpod-io/gitpod/supervisor/api"14)1516var terminalCloseCmd = &cobra.Command{17Use: "close <alias>",18Short: "closes a terminal",19Args: cobra.ExactArgs(1),20Run: func(cmd *cobra.Command, args []string) {21client := api.NewTerminalServiceClient(dialSupervisor())2223ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)24defer cancel()2526_, err := client.Shutdown(ctx, &api.ShutdownTerminalRequest{27Alias: args[0],28})29if err != nil {30log.WithError(err).Fatal("cannot close terminals")31}32},33}3435func init() {36terminalCmd.AddCommand(terminalCloseCmd)37}383940