Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements to kaniko builder #1426

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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