Skip to content

Commit

Permalink
Support extra build arg in build_and_push
Browse files Browse the repository at this point in the history
  • Loading branch information
Victoremepunto committed Oct 30, 2023
1 parent f59b01f commit 15cc62f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shared/image_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cicd::image_builder::local_build() {
}

cicd::image_builder::build_and_push() {
cicd::image_builder::build || return 1
cicd::image_builder::build "$@" || return 1
if ! cicd::image_builder::local_build; then
cicd::image_builder::push || return 1
fi
Expand Down
21 changes: 19 additions & 2 deletions test/shared_image_builder.bats
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ setup() {
assert_output --regexp "^build.*-t foobar:pr-123-extra2"
}

@test "Support extra build args" {
@test "Support extra build args for build" {

# podman mock
podman() {
Expand All @@ -706,8 +706,25 @@ setup() {

export CICD_IMAGE_BUILDER_IMAGE_NAME='foobar'
export CICD_IMAGE_BUILDER_CONTAINERFILE_PATH='test/data/Containerfile.test'

run cicd::image_builder::build --some-extra-arg1 foo=foo:bar --another-extra-arg foobar=bazbar

assert_output --regexp "^build.*--some-extra-arg1 foo=foo:bar --another-extra-arg foobar=bazbar"
}

@test "Support extra build args for build_and_push" {

# podman mock
podman() {
echo "$@"
}

source load_module.sh image_builder

export CICD_IMAGE_BUILDER_IMAGE_NAME='foobar'
export CICD_IMAGE_BUILDER_CONTAINERFILE_PATH='test/data/Containerfile.test'

run cicd::image_builder::build_and_push --some-extra-arg1 foo=foo:bar --another-extra-arg foobar=bazbar

assert_output --regexp "^build.*--some-extra-arg1 foo=foo:bar --another-extra-arg foobar=bazbar"
}

0 comments on commit 15cc62f

Please sign in to comment.