From 535a0ab8c94723cff9ef91406cbbbd9226c60c03 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Sun, 18 Nov 2018 08:39:10 +1100 Subject: [PATCH] Allow passing arguments to bazel build To make a container capable of being used by skaffold I need to be able to provide additional parameters on the command line. Add an args: element to the bazel build configuration that is a list of strings that will be passed to the build command. --- pkg/skaffold/build/local/bazel.go | 6 +++++- pkg/skaffold/schema/latest/config.go | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/skaffold/build/local/bazel.go b/pkg/skaffold/build/local/bazel.go index 354b1e0b9ba..47c8f1f6fdf 100644 --- a/pkg/skaffold/build/local/bazel.go +++ b/pkg/skaffold/build/local/bazel.go @@ -31,7 +31,11 @@ import ( ) func (b *Builder) buildBazel(ctx context.Context, out io.Writer, workspace string, a *latest.BazelArtifact) (string, error) { - cmd := exec.CommandContext(ctx, "bazel", "build", a.BuildTarget) + args := []string{"build"} + args = append(args, a.BuildArgs...) + args = append(args, a.BuildTarget) + + cmd := exec.CommandContext(ctx, "bazel", args...) cmd.Dir = workspace cmd.Stdout = out cmd.Stderr = out diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 93f56c4a5af..115f0625c87 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -267,7 +267,8 @@ type DockerArtifact struct { // BazelArtifact describes an artifact built with Bazel. type BazelArtifact struct { - BuildTarget string `yaml:"target,omitempty"` + BuildTarget string `yaml:"target,omitempty"` + BuildArgs []string `yaml:"args,omitempty"` } type JibMavenArtifact struct {