2017-03-18 06:45:19 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
@test "run" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
2017-07-21 01:41:51 +08:00
|
|
|
runc --version
|
2017-03-18 06:45:19 +08:00
|
|
|
createrandom ${TESTDIR}/randomfile
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2017-03-25 00:49:22 +08:00
|
|
|
root=$(buildah mount $cid)
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah config --workingdir /tmp $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/tmp"
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah config --workingdir /root $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/root"
|
2017-03-18 06:45:19 +08:00
|
|
|
cp ${TESTDIR}/randomfile $root/tmp/
|
|
|
|
buildah run $cid cp /tmp/randomfile /tmp/other-randomfile
|
|
|
|
test -s $root/tmp/other-randomfile
|
|
|
|
cmp ${TESTDIR}/randomfile $root/tmp/other-randomfile
|
2017-07-21 01:41:51 +08:00
|
|
|
|
2019-06-12 18:19:28 +08:00
|
|
|
seq 100000 | buildah run $cid -- sh -c 'while read i; do echo $i; done'
|
|
|
|
|
2017-07-21 01:41:51 +08:00
|
|
|
buildah unmount $cid
|
|
|
|
buildah rm $cid
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "run--args" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2017-07-21 01:41:51 +08:00
|
|
|
|
|
|
|
# This should fail, because buildah run doesn't have a -n flag.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run -n $cid echo test
|
2017-07-21 01:41:51 +08:00
|
|
|
|
|
|
|
# This should succeed, because buildah run stops caring at the --, which is preserved as part of the command.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid echo -- -n test
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output -- "-- -n test"
|
2017-07-21 01:41:51 +08:00
|
|
|
|
|
|
|
# This should succeed, because buildah run stops caring at the --, which is not part of the command.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- echo -n -- test
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output -- "-- test"
|
2017-07-21 01:41:51 +08:00
|
|
|
|
|
|
|
# This should succeed, because buildah run stops caring at the --.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- echo -- -n test --
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output -- "-- -n test --"
|
2017-07-21 01:41:51 +08:00
|
|
|
|
|
|
|
# This should succeed, because buildah run stops caring at the --.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- echo -n "test"
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "test"
|
2017-07-18 05:09:30 +08:00
|
|
|
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
2017-03-18 06:45:19 +08:00
|
|
|
}
|
2017-04-05 05:31:02 +08:00
|
|
|
|
2017-06-23 23:53:51 +08:00
|
|
|
@test "run-cmd" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah config --workingdir /tmp $cid
|
2017-06-23 23:53:51 +08:00
|
|
|
|
2018-05-03 07:50:13 +08:00
|
|
|
|
|
|
|
# Configured entrypoint/cmd shouldn't modify behaviour of run with no arguments
|
|
|
|
|
|
|
|
# empty entrypoint, configured cmd, empty run arguments
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah config --entrypoint "" $cid
|
|
|
|
buildah config --cmd pwd $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "empty entrypoint, cmd, no args"
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2018-05-03 13:48:50 +08:00
|
|
|
# empty entrypoint, configured cmd, empty run arguments, end parsing option
|
|
|
|
buildah config --entrypoint "" $cid
|
|
|
|
buildah config --cmd pwd $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid --
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "empty entrypoint, cmd, no args, --"
|
2017-06-23 23:53:51 +08:00
|
|
|
|
2018-05-03 07:50:13 +08:00
|
|
|
# configured entrypoint, empty cmd, empty run arguments
|
2018-04-18 04:00:12 +08:00
|
|
|
buildah config --entrypoint pwd $cid
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah config --cmd "" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "entrypoint, empty cmd, no args"
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2018-05-03 13:48:50 +08:00
|
|
|
# configured entrypoint, empty cmd, empty run arguments, end parsing option
|
|
|
|
buildah config --entrypoint pwd $cid
|
|
|
|
buildah config --cmd "" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid --
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "entrypoint, empty cmd, no args, --"
|
2017-06-23 23:53:51 +08:00
|
|
|
|
2018-05-03 07:50:13 +08:00
|
|
|
# configured entrypoint only, empty run arguments
|
2018-04-18 04:00:12 +08:00
|
|
|
buildah config --entrypoint pwd $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "entrypoint, no args"
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2018-05-03 13:48:50 +08:00
|
|
|
# configured entrypoint only, empty run arguments, end parsing option
|
|
|
|
buildah config --entrypoint pwd $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid --
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "entrypoint, no args, --"
|
2017-06-23 23:53:51 +08:00
|
|
|
|
2019-11-17 00:31:41 +08:00
|
|
|
# configured cmd only, empty run arguments
|
2018-05-03 07:13:28 +08:00
|
|
|
buildah config --cmd pwd $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "cmd, no args"
|
2018-05-03 07:13:28 +08:00
|
|
|
|
2019-01-22 23:35:52 +08:00
|
|
|
# configured cmd only, empty run arguments, end parsing option
|
2018-05-03 13:48:50 +08:00
|
|
|
buildah config --cmd pwd $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid --
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "cmd, no args, --"
|
2018-05-03 13:48:50 +08:00
|
|
|
|
2018-05-03 07:50:13 +08:00
|
|
|
# configured entrypoint, configured cmd, empty run arguments
|
2018-05-03 07:13:28 +08:00
|
|
|
buildah config --entrypoint "pwd" $cid
|
|
|
|
buildah config --cmd "whoami" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "entrypoint, cmd, no args"
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2018-05-03 13:48:50 +08:00
|
|
|
# configured entrypoint, configured cmd, empty run arguments, end parsing option
|
|
|
|
buildah config --entrypoint "pwd" $cid
|
|
|
|
buildah config --cmd "whoami" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run $cid --
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "command must be specified" "entrypoint, cmd, no args"
|
2017-06-23 23:53:51 +08:00
|
|
|
|
2018-05-03 07:50:13 +08:00
|
|
|
|
|
|
|
# Configured entrypoint/cmd shouldn't modify behaviour of run with argument
|
|
|
|
# Note: entrypoint and cmd can be invalid in below tests as they should never execute
|
|
|
|
|
|
|
|
# empty entrypoint, configured cmd, configured run arguments
|
|
|
|
buildah config --entrypoint "" $cid
|
|
|
|
buildah config --cmd "/invalid/cmd" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/tmp" "empty entrypoint, invalid cmd, pwd"
|
2018-05-03 07:50:13 +08:00
|
|
|
|
|
|
|
# configured entrypoint, empty cmd, configured run arguments
|
|
|
|
buildah config --entrypoint "/invalid/entrypoint" $cid
|
|
|
|
buildah config --cmd "" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/tmp" "invalid entrypoint, empty cmd, pwd"
|
2018-05-03 07:50:13 +08:00
|
|
|
|
|
|
|
# configured entrypoint only, configured run arguments
|
|
|
|
buildah config --entrypoint "/invalid/entrypoint" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/tmp" "invalid entrypoint, no cmd(??), pwd"
|
2018-05-03 07:50:13 +08:00
|
|
|
|
2019-11-17 00:31:41 +08:00
|
|
|
# configured cmd only, configured run arguments
|
2018-05-03 07:50:13 +08:00
|
|
|
buildah config --cmd "/invalid/cmd" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/tmp" "invalid cmd, no entrypoint(??), pwd"
|
2018-05-03 07:50:13 +08:00
|
|
|
|
|
|
|
# configured entrypoint, configured cmd, configured run arguments
|
|
|
|
buildah config --entrypoint "/invalid/entrypoint" $cid
|
|
|
|
buildah config --cmd "/invalid/cmd" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid -- pwd
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "/tmp" "invalid cmd & entrypoint, pwd"
|
2018-05-03 07:50:13 +08:00
|
|
|
|
2017-06-23 23:53:51 +08:00
|
|
|
buildah rm $cid
|
|
|
|
}
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
function configure_and_check_user() {
|
|
|
|
local setting=$1
|
|
|
|
local expect_u=$2
|
|
|
|
local expect_g=$3
|
|
|
|
|
|
|
|
run_buildah config -u "$setting" $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run -- $cid id -u
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "$expect_u" "id -u ($setting)"
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run -- $cid id -g
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "$expect_g" "id -g ($setting)"
|
2019-04-02 05:56:29 +08:00
|
|
|
}
|
|
|
|
|
2017-04-05 05:31:02 +08:00
|
|
|
@test "run-user" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
2017-04-05 05:31:02 +08:00
|
|
|
eval $(go env)
|
|
|
|
echo CGO_ENABLED=${CGO_ENABLED}
|
|
|
|
if test "$CGO_ENABLED" -ne 1; then
|
2019-04-02 05:56:29 +08:00
|
|
|
skip "CGO_ENABLED = '$CGO_ENABLED'"
|
2017-04-05 05:31:02 +08:00
|
|
|
fi
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2017-04-05 05:31:02 +08:00
|
|
|
root=$(buildah mount $cid)
|
|
|
|
|
|
|
|
testuser=jimbo
|
2017-11-04 01:32:19 +08:00
|
|
|
testbogususer=nosuchuser
|
2017-04-05 05:31:02 +08:00
|
|
|
testgroup=jimbogroup
|
|
|
|
testuid=$RANDOM
|
2017-11-03 01:39:56 +08:00
|
|
|
testotheruid=$RANDOM
|
2017-04-05 05:31:02 +08:00
|
|
|
testgid=$RANDOM
|
|
|
|
testgroupid=$RANDOM
|
|
|
|
echo "$testuser:x:$testuid:$testgid:Jimbo Jenkins:/home/$testuser:/bin/sh" >> $root/etc/passwd
|
|
|
|
echo "$testgroup:x:$testgroupid:" >> $root/etc/group
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
configure_and_check_user "" 0 0
|
|
|
|
configure_and_check_user "${testuser}" $testuid $testgid
|
|
|
|
configure_and_check_user "${testuid}" $testuid $testgid
|
|
|
|
configure_and_check_user "${testuser}:${testgroup}" $testuid $testgroupid
|
|
|
|
configure_and_check_user "${testuid}:${testgroup}" $testuid $testgroupid
|
|
|
|
configure_and_check_user "${testotheruid}:${testgroup}" $testotheruid $testgroupid
|
|
|
|
configure_and_check_user "${testotheruid}" $testotheruid 0
|
|
|
|
configure_and_check_user "${testuser}:${testgroupid}" $testuid $testgroupid
|
|
|
|
configure_and_check_user "${testuid}:${testgroupid}" $testuid $testgroupid
|
|
|
|
|
|
|
|
buildah config -u ${testbogususer} $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run -- $cid id -u
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "unknown user" "id -u (bogus user)"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run -- $cid id -g
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "unknown user" "id -g (bogus user)"
|
2017-11-04 01:32:19 +08:00
|
|
|
|
2017-04-13 01:35:48 +08:00
|
|
|
ln -vsf /etc/passwd $root/etc/passwd
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah config -u ${testuser}:${testgroup} $cid
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run -- $cid id -u
|
2017-04-13 01:35:48 +08:00
|
|
|
echo "$output"
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "unknown user" "run as unknown user"
|
2017-04-13 01:35:48 +08:00
|
|
|
|
2017-04-05 05:31:02 +08:00
|
|
|
buildah unmount $cid
|
|
|
|
buildah rm $cid
|
|
|
|
}
|
2017-09-21 19:39:39 +08:00
|
|
|
|
|
|
|
@test "run --hostname" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_rootless
|
|
|
|
skip_if_no_runtime
|
|
|
|
|
2017-09-21 19:39:39 +08:00
|
|
|
runc --version
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid hostname
|
2017-09-21 19:39:39 +08:00
|
|
|
[ "$output" != "foobar" ]
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run --hostname foobar $cid hostname
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "foobar"
|
2017-09-21 19:39:39 +08:00
|
|
|
buildah rm $cid
|
|
|
|
}
|
2018-05-31 22:56:40 +08:00
|
|
|
|
|
|
|
@test "run --volume" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
2018-07-21 05:58:48 +08:00
|
|
|
zflag=
|
|
|
|
if which selinuxenabled > /dev/null 2> /dev/null ; then
|
|
|
|
if selinuxenabled ; then
|
|
|
|
zflag=z
|
|
|
|
fi
|
|
|
|
fi
|
2018-05-31 22:56:40 +08:00
|
|
|
runc --version
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2018-05-31 22:56:40 +08:00
|
|
|
mkdir -p ${TESTDIR}/was-empty
|
|
|
|
# As a baseline, this should succeed.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run -v ${TESTDIR}/was-empty:/var/not-empty${zflag:+:${zflag}} $cid touch /var/not-empty/testfile
|
2019-06-20 02:59:24 +08:00
|
|
|
# Parsing options that with comma, this should succeed.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run -v ${TESTDIR}/was-empty:/var/not-empty:rw,rshared${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
|
2018-05-31 22:56:40 +08:00
|
|
|
# If we're parsing the options at all, this should be read-only, so it should fail.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run -v ${TESTDIR}/was-empty:/var/not-empty:ro${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
|
2018-09-11 02:23:26 +08:00
|
|
|
# Even if the parent directory doesn't exist yet, this should succeed.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run -v ${TESTDIR}/was-empty:/var/multi-level/subdirectory $cid touch /var/multi-level/subdirectory/testfile
|
2018-09-11 02:23:26 +08:00
|
|
|
# And check the same for file volumes.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run -v ${TESTDIR}/was-empty/testfile:/var/different-multi-level/subdirectory/testfile $cid touch /var/different-multi-level/subdirectory/testfile
|
2018-05-31 22:56:40 +08:00
|
|
|
}
|
2018-06-02 02:54:45 +08:00
|
|
|
|
2019-06-20 02:17:11 +08:00
|
|
|
@test "run --mount" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
2019-06-20 02:17:11 +08:00
|
|
|
zflag=
|
|
|
|
if which selinuxenabled > /dev/null 2> /dev/null ; then
|
|
|
|
if selinuxenabled ; then
|
|
|
|
zflag=z
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
runc --version
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-06-20 02:17:11 +08:00
|
|
|
mkdir -p ${TESTDIR}/was:empty
|
|
|
|
# As a baseline, this should succeed.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run --mount type=tmpfs,dst=/var/tmpfs-not-empty $cid touch /var/tmpfs-not-empty/testfile
|
|
|
|
run_buildah run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/not-empty${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
|
2019-06-20 02:17:11 +08:00
|
|
|
# If we're parsing the options at all, this should be read-only, so it should fail.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/not-empty,ro${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
|
2019-06-20 02:17:11 +08:00
|
|
|
# Even if the parent directory doesn't exist yet, this should succeed.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/multi-level/subdirectory $cid touch /var/multi-level/subdirectory/testfile
|
2019-06-20 02:17:11 +08:00
|
|
|
# And check the same for file volumes.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run --mount type=bind,src=${TESTDIR}/was:empty/testfile,dst=/var/different-multi-level/subdirectory/testfile $cid touch /var/different-multi-level/subdirectory/testfile
|
2019-06-20 02:17:11 +08:00
|
|
|
}
|
|
|
|
|
2018-06-02 02:54:45 +08:00
|
|
|
@test "run symlinks" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
2018-06-02 02:54:45 +08:00
|
|
|
runc --version
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2018-06-02 02:54:45 +08:00
|
|
|
mkdir -p ${TESTDIR}/tmp
|
|
|
|
ln -s tmp ${TESTDIR}/tmp2
|
|
|
|
export TMPDIR=${TESTDIR}/tmp2
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid id
|
2018-06-02 02:54:45 +08:00
|
|
|
}
|
2018-06-05 05:36:26 +08:00
|
|
|
|
|
|
|
@test "run --cap-add/--cap-drop" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
2018-06-05 05:36:26 +08:00
|
|
|
runc --version
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2018-06-05 05:36:26 +08:00
|
|
|
# Try with default caps.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid grep ^CapEff /proc/self/status
|
2018-06-05 05:36:26 +08:00
|
|
|
defaultcaps="$output"
|
|
|
|
# Try adding DAC_OVERRIDE.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run --cap-add CAP_DAC_OVERRIDE $cid grep ^CapEff /proc/self/status
|
2018-06-05 05:36:26 +08:00
|
|
|
addedcaps="$output"
|
|
|
|
# Try dropping DAC_OVERRIDE.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run --cap-drop CAP_DAC_OVERRIDE $cid grep ^CapEff /proc/self/status
|
2018-06-05 05:36:26 +08:00
|
|
|
droppedcaps="$output"
|
|
|
|
# Okay, now the "dropped" and "added" should be different.
|
|
|
|
test "$addedcaps" != "$droppedcaps"
|
|
|
|
# And one or the other should be different from the default, with the other being the same.
|
|
|
|
if test "$defaultcaps" == "$addedcaps" ; then
|
|
|
|
test "$defaultcaps" != "$droppedcaps"
|
|
|
|
fi
|
|
|
|
if test "$defaultcaps" == "$droppedcaps" ; then
|
|
|
|
test "$defaultcaps" != "$addedcaps"
|
|
|
|
fi
|
|
|
|
}
|
2018-07-30 23:54:15 +08:00
|
|
|
|
|
|
|
@test "Check if containers run with correct open files/processes limits" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid awk '/open files/{print $4}' /proc/self/limits
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "1048576" "limits: open files (unlimited)"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid awk '/processes/{print $3}' /proc/self/limits
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "1048576" "limits: processes (unlimited)"
|
2018-07-30 23:54:15 +08:00
|
|
|
buildah rm $cid
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --ulimit nofile=300:400 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid awk '/open files/{print $4}' /proc/self/limits
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "300" "limits: open files (w/file limit)"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid awk '/processes/{print $3}' /proc/self/limits
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "1048576" "limits: processes (w/file limit)"
|
2018-07-30 23:54:15 +08:00
|
|
|
buildah rm $cid
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --ulimit nproc=100:200 --ulimit nofile=300:400 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid awk '/open files/{print $4}' /proc/self/limits
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "300" "limits: open files (w/file & proc limits)"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid awk '/processes/{print $3}' /proc/self/limits
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "100" "limits: processes (w/file & proc limits)"
|
2018-07-30 23:54:15 +08:00
|
|
|
buildah rm $cid
|
|
|
|
}
|
2018-10-25 03:15:40 +08:00
|
|
|
|
|
|
|
@test "run-builtin-volume-omitted" {
|
|
|
|
# This image is known to include a volume, but not include the mountpoint
|
|
|
|
# in the image.
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json docker.io/library/registry@sha256:a25e4660ed5226bdb59a5e555083e08ded157b1218282840e55d25add0223390)
|
2018-10-25 03:15:40 +08:00
|
|
|
mnt=$(buildah mount $cid)
|
|
|
|
# By default, the mountpoint should not be there.
|
|
|
|
run test -d "$mnt"/var/lib/registry
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
# We'll create the mountpoint for "run".
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid ls -1 /var/lib
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "registry"
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2018-10-25 03:15:40 +08:00
|
|
|
# Double-check that the mountpoint is there.
|
2019-04-02 05:56:29 +08:00
|
|
|
test -d "$mnt"/var/lib/registry
|
2018-10-25 03:15:40 +08:00
|
|
|
}
|
2019-08-23 00:45:36 +08:00
|
|
|
|
|
|
|
@test "run-exit-status" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-08-23 00:45:36 +08:00
|
|
|
run_buildah 42 run ${cid} sh -c 'exit 42'
|
|
|
|
}
|
2019-09-06 04:54:40 +08:00
|
|
|
|
|
|
|
@test "Verify /run/.containerenv exist" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-09-06 04:54:40 +08:00
|
|
|
# test a standard mount to /run/.containerenv
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid ls -1 /run/.containerenv
|
2019-09-06 04:54:40 +08:00
|
|
|
expect_output --substring "/run/.containerenv"
|
|
|
|
}
|
2019-09-07 03:07:18 +08:00
|
|
|
|
|
|
|
@test "run-device" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --device /dev/fuse --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-09-07 03:07:18 +08:00
|
|
|
run_buildah 0 run ${cid} ls /dev/fuse
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --device /dev/fuse:/dev/fuse:rm --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-09-07 03:07:18 +08:00
|
|
|
run_buildah 0 run ${cid} ls /dev/fuse
|
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --device /dev/fuse:/dev/fuse:rwm --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-09-07 03:07:18 +08:00
|
|
|
run_buildah 0 run ${cid} ls /dev/fuse
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "run-device-Rename" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
skip_if_chroot
|
|
|
|
skip_if_rootless
|
2019-09-07 03:07:18 +08:00
|
|
|
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
cid=$(buildah from --pull=false --device /dev/fuse:/dev/fuse1 --signature-policy ${TESTSDIR}/policy.json alpine)
|
2019-09-07 03:07:18 +08:00
|
|
|
run_buildah 0 run ${cid} ls /dev/fuse1
|
|
|
|
}
|