Path: blob/main/dev/gpctl/cmd/workspaces-last-heartbeat.go
2500 views
// Copyright (c) 2022 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"fmt"910"github.com/spf13/cobra"1112"github.com/gitpod-io/gitpod/common-go/log"13"github.com/gitpod-io/gitpod/ws-manager/api"14)1516// workspacesLastHeartbeatCmd get workspace last heartbeat time17var workspacesLastHeartbeatCmd = &cobra.Command{18Use: "last-heartbeat <instanceID>",19Short: "get workspace last heartbeat time",20Args: cobra.ExactArgs(1),21Run: func(cmd *cobra.Command, args []string) {22ctx, cancel := context.WithCancel(context.Background())23defer cancel()2425conn, client, err := getWorkspacesClient(ctx)26if err != nil {27log.WithError(err).Fatal("cannot connect")28}29defer conn.Close()3031instanceID := args[0]3233resp, err := client.DescribeWorkspace(ctx, &api.DescribeWorkspaceRequest{34Id: instanceID,35})36if err != nil {37log.WithError(err).Fatal("error during RPC call")38}3940fmt.Println(resp.LastActivity)41},42}4344func init() {45workspacesCmd.AddCommand(workspacesLastHeartbeatCmd)46}474849