Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/gpctl/cmd/imagebuilds-resolve-workspaceimage.go
2500 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/spf13/cobra"
11
12
"github.com/gitpod-io/gitpod/common-go/log"
13
builder "github.com/gitpod-io/gitpod/image-builder/api"
14
)
15
16
var clientResolveWorkspaceImageCmd = &cobra.Command{
17
Use: "workspace-image <base-image-ref>",
18
Short: "Resolves the workspace-image for a ref-based build source",
19
Args: cobra.ExactArgs(1),
20
Run: func(cmd *cobra.Command, args []string) {
21
ctx, cancel := context.WithCancel(context.Background())
22
defer cancel()
23
24
conn, client, err := getImagebuildsClient(ctx)
25
if err != nil {
26
log.WithError(err).Fatal("cannot connect")
27
}
28
defer conn.Close()
29
30
resp, err := client.ResolveWorkspaceImage(ctx, &builder.ResolveWorkspaceImageRequest{
31
Source: &builder.BuildSource{
32
From: &builder.BuildSource_Ref{
33
Ref: &builder.BuildSourceReference{
34
Ref: args[0],
35
},
36
},
37
},
38
})
39
40
if err != nil {
41
log.WithError(err).Fatal("error during RPC call")
42
}
43
44
tpl := `{{ .Ref }}
45
`
46
getOutputFormat(tpl, "{.ref}").Print(resp)
47
},
48
}
49
50
func init() {
51
imagebuildsResolveCmd.AddCommand(clientResolveWorkspaceImageCmd)
52
}
53
54