Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/gpctl/cmd/imagebuilds-resolve-baseimage.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
// clientResolveBaseimageCmd represents the clientResolveBaseimage command
17
var clientResolveBaseimageCmd = &cobra.Command{
18
Use: "base-image <ref>",
19
Short: "Resolves a base image ref to an absolute ref",
20
Args: cobra.ExactArgs(1),
21
Run: func(cmd *cobra.Command, args []string) {
22
ctx, cancel := context.WithCancel(context.Background())
23
defer cancel()
24
25
conn, client, err := getImagebuildsClient(ctx)
26
if err != nil {
27
log.WithError(err).Fatal("cannot connect")
28
}
29
defer conn.Close()
30
31
auth := &builder.BuildRegistryAuth{
32
Mode: &builder.BuildRegistryAuth_Total{
33
Total: &builder.BuildRegistryAuthTotal{
34
AllowAll: true,
35
},
36
},
37
}
38
39
resp, err := client.ResolveBaseImage(ctx, &builder.ResolveBaseImageRequest{
40
Ref: args[0],
41
Auth: auth,
42
})
43
44
if err != nil {
45
log.WithError(err).Fatal("error during RPC call")
46
}
47
48
tpl := `{{ .Ref }}
49
`
50
getOutputFormat(tpl, "{.ref}").Print(resp)
51
},
52
}
53
54
func init() {
55
imagebuildsResolveCmd.AddCommand(clientResolveBaseimageCmd)
56
}
57
58