Skip to content

Commit

Permalink
Merge pull request #1426 from dgageot/small-improvements-kaniko
Browse files Browse the repository at this point in the history
Small improvements to kaniko builder
  • Loading branch information
dgageot authored Dec 27, 2018
2 parents 38a3404 + abfecc7 commit cf877dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pkg/skaffold/build/kaniko/kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/skaffold/build/kaniko/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit cf877dc

Please sign in to comment.