Path: blob/main/components/ws-daemon/cmd/client-snapshot.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"89"github.com/alecthomas/repr"10"github.com/spf13/cobra"1112"github.com/gitpod-io/gitpod/common-go/log"13"github.com/gitpod-io/gitpod/ws-daemon/api"14)1516// clientSnapshotCmd creates a workspace snapshot17var clientSnapshotCmd = &cobra.Command{18Use: "snapshot <id>",19Short: "snapshots a workspace",20Args: cobra.ExactArgs(1),21Run: func(cmd *cobra.Command, args []string) {22req := api.TakeSnapshotRequest{Id: args[0]}2324conn, err := getGRPCConnection()25if err != nil {26log.WithError(err).Fatal("cannot connect")27}28defer conn.Close()2930client := api.NewWorkspaceContentServiceClient(conn)31ctx := context.Background()3233resp, err := client.TakeSnapshot(ctx, &req)34if err != nil {35log.WithError(err).Fatal("error during RPC call")36}3738repr.Println(resp)39},40}4142func init() {43clientCmd.AddCommand(clientSnapshotCmd)44}454647