Path: blob/main/dev/gpctl/cmd/imagebuilds-resolve-workspaceimage.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)1415var clientResolveWorkspaceImageCmd = &cobra.Command{16Use: "workspace-image <base-image-ref>",17Short: "Resolves the workspace-image for a ref-based build source",18Args: cobra.ExactArgs(1),19Run: func(cmd *cobra.Command, args []string) {20ctx, cancel := context.WithCancel(context.Background())21defer cancel()2223conn, client, err := getImagebuildsClient(ctx)24if err != nil {25log.WithError(err).Fatal("cannot connect")26}27defer conn.Close()2829resp, err := client.ResolveWorkspaceImage(ctx, &builder.ResolveWorkspaceImageRequest{30Source: &builder.BuildSource{31From: &builder.BuildSource_Ref{32Ref: &builder.BuildSourceReference{33Ref: args[0],34},35},36},37})3839if err != nil {40log.WithError(err).Fatal("error during RPC call")41}4243tpl := `{{ .Ref }}44`45getOutputFormat(tpl, "{.ref}").Print(resp)46},47}4849func init() {50imagebuildsResolveCmd.AddCommand(clientResolveWorkspaceImageCmd)51}525354