Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/gpctl/cmd/workspaces-last-heartbeat.go
2500 views
1
// Copyright (c) 2022 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
"fmt"
10
11
"github.com/spf13/cobra"
12
13
"github.com/gitpod-io/gitpod/common-go/log"
14
"github.com/gitpod-io/gitpod/ws-manager/api"
15
)
16
17
// workspacesLastHeartbeatCmd get workspace last heartbeat time
18
var workspacesLastHeartbeatCmd = &cobra.Command{
19
Use: "last-heartbeat <instanceID>",
20
Short: "get workspace last heartbeat time",
21
Args: cobra.ExactArgs(1),
22
Run: func(cmd *cobra.Command, args []string) {
23
ctx, cancel := context.WithCancel(context.Background())
24
defer cancel()
25
26
conn, client, err := getWorkspacesClient(ctx)
27
if err != nil {
28
log.WithError(err).Fatal("cannot connect")
29
}
30
defer conn.Close()
31
32
instanceID := args[0]
33
34
resp, err := client.DescribeWorkspace(ctx, &api.DescribeWorkspaceRequest{
35
Id: instanceID,
36
})
37
if err != nil {
38
log.WithError(err).Fatal("error during RPC call")
39
}
40
41
fmt.Println(resp.LastActivity)
42
},
43
}
44
45
func init() {
46
workspacesCmd.AddCommand(workspacesLastHeartbeatCmd)
47
}
48
49