Skip to content

Commit

Permalink
skip empty build args
Browse files Browse the repository at this point in the history
  • Loading branch information
foosinn committed May 6, 2020
1 parent 4c66584 commit e0d9a53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ func (b *build) args() []string {
log.Warnf("%s Building %s", b.ID, b.prettyName())
args := []string{"build", b.Path}
for _, k := range b.KeyOrder {
if b.Scenario[k] == "" {
log.Infof("skipping empty build arg %s", k)
continue
}
args = append(args, "--build-arg", fmt.Sprintf("%s=%s", k, b.Scenario[k]))
}
for _, tag := range b.tags() {
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestBuild(t *testing.T) {

want := `
build alpine --build-arg MESSAGE=multiply -t localhost:5000/images/alpine:multiply -t localhost:5000/images/alpine:multiply-7
build alpine --build-arg MESSAGE= -t localhost:5000/images/alpine:latest -t localhost:5000/images/alpine:7
build alpine -t localhost:5000/images/alpine:latest -t localhost:5000/images/alpine:7
build busybox -t localhost:5000/images/busybox:latest -t localhost:5000/images/busybox:7
build php --build-arg VERSION=7.2 --build-arg OS=alpine --build-arg NAME=test -t docker.io/bitsbeats/image1:7.2-alpine-test -t docker.io/bitsbeats/image1:7.2-alpine-test-7 -t docker.io/bitsbeats/image2:7.2-alpine-test -t docker.io/bitsbeats/image2:7.2-alpine-test-7 -t localhost:5000/images/php:7.2-alpine-test -t localhost:5000/images/php:7.2-alpine-test-7
build php --build-arg VERSION=7.2 --build-arg OS=debian --build-arg NAME=test -t docker.io/bitsbeats/image1:7.2-debian-test -t docker.io/bitsbeats/image1:7.2-debian-test-7 -t docker.io/bitsbeats/image2:7.2-debian-test -t docker.io/bitsbeats/image2:7.2-debian-test-7 -t localhost:5000/images/php:7.2-debian-test -t localhost:5000/images/php:7.2-debian-test-7
Expand Down

0 comments on commit e0d9a53

Please sign in to comment.