Path: blob/main/dev/gpctl/cmd/imagebuilds-resolve-baseimage.go
2500 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/spf13/cobra"1011"github.com/gitpod-io/gitpod/common-go/log"12builder "github.com/gitpod-io/gitpod/image-builder/api"13)1415// clientResolveBaseimageCmd represents the clientResolveBaseimage command16var clientResolveBaseimageCmd = &cobra.Command{17Use: "base-image <ref>",18Short: "Resolves a base image ref to an absolute ref",19Args: cobra.ExactArgs(1),20Run: func(cmd *cobra.Command, args []string) {21ctx, cancel := context.WithCancel(context.Background())22defer cancel()2324conn, client, err := getImagebuildsClient(ctx)25if err != nil {26log.WithError(err).Fatal("cannot connect")27}28defer conn.Close()2930auth := &builder.BuildRegistryAuth{31Mode: &builder.BuildRegistryAuth_Total{32Total: &builder.BuildRegistryAuthTotal{33AllowAll: true,34},35},36}3738resp, err := client.ResolveBaseImage(ctx, &builder.ResolveBaseImageRequest{39Ref: args[0],40Auth: auth,41})4243if err != nil {44log.WithError(err).Fatal("error during RPC call")45}4647tpl := `{{ .Ref }}48`49getOutputFormat(tpl, "{.ref}").Print(resp)50},51}5253func init() {54imagebuildsResolveCmd.AddCommand(clientResolveBaseimageCmd)55}565758