diff --git a/pkg/skaffold/build/kaniko/kaniko.go b/pkg/skaffold/build/kaniko/kaniko.go index 97ec88e03a1..927106d906b 100644 --- a/pkg/skaffold/build/kaniko/kaniko.go +++ b/pkg/skaffold/build/kaniko/kaniko.go @@ -35,11 +35,11 @@ func (b *Builder) Build(ctx context.Context, out io.Writer, tagger tag.Tagger, a } defer teardown() - return build.InParallel(ctx, out, tagger, artifacts, b.buildArtifact) + return build.InParallel(ctx, out, tagger, artifacts, b.buildArtifactWithKaniko) } -func (b *Builder) buildArtifact(ctx context.Context, out io.Writer, tagger tag.Tagger, artifact *latest.Artifact) (string, error) { - initialTag, err := b.run(ctx, out, artifact, b.KanikoBuild) +func (b *Builder) buildArtifactWithKaniko(ctx context.Context, out io.Writer, tagger tag.Tagger, artifact *latest.Artifact) (string, error) { + initialTag, err := b.run(ctx, out, artifact) if err != nil { return "", errors.Wrapf(err, "kaniko build for [%s]", artifact.ImageName) } diff --git a/pkg/skaffold/build/kaniko/run.go b/pkg/skaffold/build/kaniko/run.go index 4ad5e496137..c902e82a078 100644 --- a/pkg/skaffold/build/kaniko/run.go +++ b/pkg/skaffold/build/kaniko/run.go @@ -31,10 +31,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (b *Builder) run(ctx context.Context, out io.Writer, artifact *latest.Artifact, cfg *latest.KanikoBuild) (string, error) { +func (b *Builder) run(ctx context.Context, out io.Writer, artifact *latest.Artifact) (string, error) { initialTag := util.RandomID() - s := sources.Retrieve(cfg) + s := sources.Retrieve(b.KanikoBuild) context, err := s.Setup(ctx, out, artifact, initialTag) if err != nil { return "", errors.Wrap(err, "setting up build context") @@ -52,17 +52,17 @@ func (b *Builder) run(ctx context.Context, out io.Writer, artifact *latest.Artif fmt.Sprintf("--context=%s", context), fmt.Sprintf("--destination=%s", imageDst), fmt.Sprintf("-v=%s", logLevel().String())} - args = append(args, cfg.AdditionalFlags...) + args = append(args, b.AdditionalFlags...) args = append(args, docker.GetBuildArgs(artifact.DockerArtifact)...) - if cfg.Cache != nil { + if b.Cache != nil { args = append(args, "--cache=true") - if cfg.Cache.Repo != "" { - args = append(args, fmt.Sprintf("--cache-repo=%s", cfg.Cache.Repo)) + if b.Cache.Repo != "" { + args = append(args, fmt.Sprintf("--cache-repo=%s", b.Cache.Repo)) } } - pods := client.CoreV1().Pods(cfg.Namespace) + pods := client.CoreV1().Pods(b.Namespace) p, err := pods.Create(s.Pod(args)) if err != nil { return "", errors.Wrap(err, "creating kaniko pod")