github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/runner/v1/render.go (about)

     1  /*
     2  Copyright 2019 The Skaffold Authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1
    18  
    19  import (
    20  	"context"
    21  	"fmt"
    22  	"io"
    23  
    24  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
    25  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
    26  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
    27  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
    28  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
    29  )
    30  
    31  func (r *SkaffoldRunner) Render(ctx context.Context, out io.Writer, builds []graph.Artifact, offline bool, filepath string) error {
    32  	// Fetch the digest and append it to the tag with the format of "tag@digest"
    33  	if r.runCtx.DigestSource() == runner.RemoteDigestSource {
    34  		for i, a := range builds {
    35  			digest, err := docker.RemoteDigest(a.Tag, r.runCtx, nil)
    36  			if err != nil {
    37  				return fmt.Errorf("failed to resolve the digest of %s: does the image exist remotely?", a.Tag)
    38  			}
    39  			builds[i].Tag = build.TagWithDigest(a.Tag, digest)
    40  		}
    41  	}
    42  	if r.runCtx.DigestSource() == runner.NoneDigestSource {
    43  		output.Default.Fprintln(out, "--digest-source set to 'none', tags listed in Kubernetes manifests will be used for render")
    44  	}
    45  	return r.deployer.Render(ctx, out, builds, offline, filepath)
    46  }