Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/supervisor/cmd/terminal-close.go
2498 views
1
// Copyright (c) 2020 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
"time"
10
11
"github.com/spf13/cobra"
12
13
"github.com/gitpod-io/gitpod/common-go/log"
14
"github.com/gitpod-io/gitpod/supervisor/api"
15
)
16
17
var terminalCloseCmd = &cobra.Command{
18
Use: "close <alias>",
19
Short: "closes a terminal",
20
Args: cobra.ExactArgs(1),
21
Run: func(cmd *cobra.Command, args []string) {
22
client := api.NewTerminalServiceClient(dialSupervisor())
23
24
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
25
defer cancel()
26
27
_, err := client.Shutdown(ctx, &api.ShutdownTerminalRequest{
28
Alias: args[0],
29
})
30
if err != nil {
31
log.WithError(err).Fatal("cannot close terminals")
32
}
33
},
34
}
35
36
func init() {
37
terminalCmd.AddCommand(terminalCloseCmd)
38
}
39
40