2018-06-11 14:55:51 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
2018-09-03 19:20:52 +08:00
|
|
|
@test "commit-flags-order-verification" {
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah 1 commit cnt1 --tls-verify
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "--tls-verify"
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah 1 commit cnt1 -q
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "-q"
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah 1 commit cnt1 -f=docker --quiet --creds=bla:bla
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "-f=docker"
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah 1 commit cnt1 --creds=bla:bla
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "--creds=bla:bla"
|
|
|
|
}
|
|
|
|
|
2018-06-11 14:55:51 +08:00
|
|
|
@test "commit" {
|
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-11 14:55:51 +08:00
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah images alpine-image
|
2018-06-11 14:55:51 +08:00
|
|
|
buildah rm $cid
|
|
|
|
buildah rmi -a
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit format test" {
|
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-11 14:55:51 +08:00
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-oci
|
2018-06-06 22:41:40 +08:00
|
|
|
buildah commit --format docker --disable-compression=false --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-docker
|
2018-06-11 14:55:51 +08:00
|
|
|
|
2019-08-22 20:07:56 +08:00
|
|
|
buildah --log-level=error inspect --type=image --format '{{.Manifest}}' alpine-image-oci | grep "application/vnd.oci.image.layer.v1.tar"
|
|
|
|
buildah --log-level=error inspect --type=image --format '{{.Manifest}}' alpine-image-docker | grep "application/vnd.docker.image.rootfs.diff.tar.gzip"
|
2018-06-11 14:55:51 +08:00
|
|
|
buildah rm $cid
|
|
|
|
buildah rmi -a
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit quiet test" {
|
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-22 20:07:56 +08:00
|
|
|
run_buildah --log-level=error commit --iidfile /dev/null --signature-policy ${TESTSDIR}/policy.json -q $cid alpine-image
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output ""
|
2018-06-11 14:55:51 +08:00
|
|
|
buildah rm $cid
|
|
|
|
buildah rmi -a
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit rm test" {
|
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-11 14:55:51 +08:00
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json --rm $cid alpine-image
|
2019-08-22 20:07:56 +08:00
|
|
|
run_buildah 1 --log-level=error rm $cid
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "error removing container \"alpine-working-container\": error reading build container: container not known"
|
2018-06-11 14:55:51 +08:00
|
|
|
buildah rmi -a
|
|
|
|
}
|
2018-06-22 23:20:02 +08:00
|
|
|
|
|
|
|
@test "commit-alternate-storage" {
|
|
|
|
echo FROM
|
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 openshift/hello-openshift)
|
2018-06-22 23:20:02 +08:00
|
|
|
echo COMMIT
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid "containers-storage:[vfs@${TESTDIR}/root2+${TESTDIR}/runroot2]newimage"
|
|
|
|
echo FROM
|
2018-07-25 02:08:04 +08:00
|
|
|
buildah --storage-driver vfs --root ${TESTDIR}/root2 --runroot ${TESTDIR}/runroot2 from --signature-policy ${TESTSDIR}/policy.json newimage
|
2018-06-22 23:20:02 +08:00
|
|
|
}
|
2018-08-22 04:33:36 +08:00
|
|
|
|
|
|
|
@test "commit-rejected-name" {
|
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-22 20:07:56 +08:00
|
|
|
run_buildah 1 --log-level=error commit --signature-policy ${TESTSDIR}/policy.json $cid ThisNameShouldBeRejected
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "must be lower"
|
2018-08-22 04:33:36 +08:00
|
|
|
}
|
2019-04-04 02:57:55 +08:00
|
|
|
|
|
|
|
@test "commit-no-empty-created-by" {
|
2019-04-05 23:59:54 +08:00
|
|
|
if ! python3 -c 'import json, sys' 2> /dev/null ; then
|
2019-04-04 02:57:55 +08:00
|
|
|
skip "python interpreter with json module not found"
|
|
|
|
fi
|
|
|
|
target=new-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 alpine)
|
2019-04-04 02:57:55 +08:00
|
|
|
|
2019-08-22 20:07:56 +08:00
|
|
|
run_buildah --log-level=error config --created-by "untracked actions" $cid
|
|
|
|
run_buildah --log-level=error commit --signature-policy ${TESTSDIR}/policy.json $cid ${target}
|
|
|
|
run_buildah --log-level=error inspect --format '{{.Config}}' ${target}
|
2019-04-04 02:57:55 +08:00
|
|
|
config="$output"
|
2019-04-05 23:59:54 +08:00
|
|
|
run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config"
|
2019-04-04 02:57:55 +08:00
|
|
|
echo "$output"
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
[ "$output" == "untracked actions" ]
|
|
|
|
|
2019-08-22 20:07:56 +08:00
|
|
|
run_buildah --log-level=error config --created-by "" $cid
|
|
|
|
run_buildah --log-level=error commit --signature-policy ${TESTSDIR}/policy.json $cid ${target}
|
|
|
|
run_buildah --log-level=error inspect --format '{{.Config}}' ${target}
|
2019-04-04 02:57:55 +08:00
|
|
|
config="$output"
|
2019-04-05 23:59:54 +08:00
|
|
|
run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config"
|
2019-04-04 02:57:55 +08:00
|
|
|
echo "$output"
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
[ "$output" == "/bin/sh" ]
|
|
|
|
}
|
2019-03-21 01:06:29 +08:00
|
|
|
|
|
|
|
@test "commit-no-name" {
|
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-03-21 01:06:29 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid
|
|
|
|
}
|
2019-11-06 11:57:38 +08:00
|
|
|
|
|
|
|
@test "commit should fail with nonexist authfile" {
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
|
|
|
run_buildah 1 commit --authfile /tmp/nonexist --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
|
|
|
buildah rm $cid
|
|
|
|
buildah rmi -a
|
|
|
|
}
|
2019-11-13 00:50:21 +08:00
|
|
|
|
|
|
|
@test "commit-builder-identity" {
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
|
|
|
|
|
|
|
buildah_version=$(buildah --version | awk '{ print $3 }')
|
|
|
|
version=$(buildah inspect --format '{{ index .Docker.Config.Labels "io.buildah.version"}}' alpine-image)
|
|
|
|
|
|
|
|
[ "$version" == "$buildah_version" ]
|
|
|
|
buildah rm $cid
|
|
|
|
buildah rmi -f alpine-image
|
|
|
|
}
|