Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-daemon/cmd/client-snapshot.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
10
"github.com/alecthomas/repr"
11
"github.com/spf13/cobra"
12
13
"github.com/gitpod-io/gitpod/common-go/log"
14
"github.com/gitpod-io/gitpod/ws-daemon/api"
15
)
16
17
// clientSnapshotCmd creates a workspace snapshot
18
var clientSnapshotCmd = &cobra.Command{
19
Use: "snapshot <id>",
20
Short: "snapshots a workspace",
21
Args: cobra.ExactArgs(1),
22
Run: func(cmd *cobra.Command, args []string) {
23
req := api.TakeSnapshotRequest{Id: args[0]}
24
25
conn, err := getGRPCConnection()
26
if err != nil {
27
log.WithError(err).Fatal("cannot connect")
28
}
29
defer conn.Close()
30
31
client := api.NewWorkspaceContentServiceClient(conn)
32
ctx := context.Background()
33
34
resp, err := client.TakeSnapshot(ctx, &req)
35
if err != nil {
36
log.WithError(err).Fatal("error during RPC call")
37
}
38
39
repr.Println(resp)
40
},
41
}
42
43
func init() {
44
clientCmd.AddCommand(clientSnapshotCmd)
45
}
46
47