Commit Graph

21 Commits

Author SHA1 Message Date
Aditya R e67bb0904c
refactor: stop using Normalize directly from containerd package
Stop using containerd's `platform.Normalize` instead use libimage's
`NormalizePlatform` which calls containerd's `platform.Normalize` along
with `platform.Parse` internally.

See discussion here: https://github.com/containers/buildah/pull/4286/files#r977389931

Signed-off-by: Aditya R <arajan@redhat.com>
2022-09-28 12:54:16 +05:30
Aditya R dfba70e9b9
test: manifest inspect should have OCIv1 annotation
Signed-off-by: Aditya R <arajan@redhat.com>
2022-07-29 22:52:25 +05:30
Ed Santiago 267f309911 Rename $TESTSDIR (the plural one), step 1 of 3
...refactor '--signature-policy .../policy.json' to $WITH_POLICY_JSON

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-04-26 09:11:05 -06:00
Nalin Dahyabhai 9f9f32cedd config: support the variant field
Add the variant field, along with methods for setting and querying it,
and expose them in the `buildah config` and `buildah inspect` commands.

When setting an initial architecture for a container based on an image
which doesn't contain an architecture, or from "scratch", normalize the
architecture name we've been given, and set both it and the variant
field at the same time.

Provide normalized architecture+variant values in `buildah info`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-11-05 09:37:00 -04:00
Daniel J Walsh 2f671a26b2
Return exit code from failed containers
Buildah run was exiting with the correct exit code, when a container
failed.  Buildah bud was not, so this should fix this.

Also switched to the proper exit codes when containers fail.  When
Buildah fails to execute it will exit with a 125 exit code like
Podman does.  If a command fails to execute inside of a container
we will exit with a 126. Currently we do not support the 127 for
exiting when the command does not exist.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 11:24:52 -04:00
Ed Santiago 0f5fd98218 Flake handling: cache and prefetch images
Show of hands: who here loves submitting a PR, then coming back
hours later to find one job failed, then spending time poring
over logs and finding a network error? Anyone? Anyone?

This is a lame attempt to minimize such flakes by caching
commonly-used images and restoring them on demand. We
introduce a new helper, _prefetch(), which podman-pulls
an image the first time, podman-saves it, then on
subsequent calls (for the same image) podman-loads it:

    @test foo {
        _prefetch alpine busybox
        ...tests that run buildah-from either
    }

This is an imperfect solution: it is incomplete and will
grow more so over time as new tests are added. It is
difficult to verify its coverage. I'm really unhappy
with it but if it works, the Total Sum Of Unhappiness
might decrease overall thanks to fewer flakes. If it
doesn't work, it's trivial to remove _prefetch calls
using a sed script. Shall we give it a chance?

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-06 08:16:02 -07:00
Ed Santiago 77db7f959e BATS major cleanup: part 4: manual stuff
This is the manual part of the cleanup.

  - remove most 'buildah rm's from cleanup steps
  - remove unused variables
  - use expect_output when possible, not 'test [ x = y ]'
    - includes fixing some not-what-you-think-it-is uses
      of run_buildah | grep
  - be careful not to leave droppings in current directory

Special attention to:

  - authenticate.bats: create Dockerfile in temp dir, not pwd!
  - push.bats: remove broken output check
  - registries.bats: refactor, remove duplicate tests & code
  - rmi.bats: better checking of messages
  - secrets.bats: use TESTDIR (tmp), not TESTSDIR (/usr/share) !
    We don't want to leave droppings behind if we fail; this has
    bitten us before. And, since there's only one test, there's
    no need to override setup() / teardown(). Do setup inline,
    and take advantage of existing defaults.

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2029
Approved by: rhatdan
2019-12-17 18:16:45 +00:00
Ed Santiago 6063bff02a BATS major cleanup, step 3: yet more run_buildah
Replace plain 'buildah' invocations with run_buildah

For ease of review, this commit was entirely machine-generated via:

   $ perl -pi -e 's/^(\s+)buildah(\s)/${1}run_buildah${2}/' *.bats

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2029
Approved by: rhatdan
2019-12-17 18:16:45 +00:00
Ed Santiago 229b18f6a8 BATS major cleanup, part 2: use more run_buildah
Replace this pattern:

       cid=$(buildah ...)
with:
       run_buildah ...
       cid=$output

As a special case, if the buildah command is 'from' and the
string 'scratch' does not appear in the arguments, add '--quiet'.
Otherwise we'll get Pulling messages as part of $output. This
is an overkill solution.

For ease of review, this commit was entirely machine-generated via:

   $ perl -pi -e 's{^(\s+)(\S+)=\$\(buildah (.*)\)$}{$indent=$1;$var=$2;$cmd=$3; $cmd =~ s/(\bfrom)\s(?!.*scratch)/$1 --quiet $2/; "${indent}run_buildah $cmd\n$indent$var=\$output"}e' *.bats

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2029
Approved by: rhatdan
2019-12-17 18:16:45 +00:00
Ed Santiago d55a9f8893 PR takeover of #1966
PR 1966 has languished for three weeks without activity from
submitter. In the interests of getting it online, I have
taken it over and:

  - rebased
  - fixed several misunderstandings (bugs) noted in review feedback
  - fixed a few more

I also slightly rewrote two tests (tag by id, commit with name)
that were incomprehensible to me: unnecessary mount/umount and
no actual testing of anything other than checking exit status.
I believe the new code is closer to the intention of testing
but please pay closer attention to those bits.

Also: fixed the basic 'inspect' test. It looks like at some
point in the last month #1917 added a version string to
the buildah-inspect output. The test was fixed on master,
but ypu's PR did not incorporate those fixes and the
test was breaking. I took the liberty of cleaning up
the entire test for readability and maintainability.

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2004
Approved by: rhatdan
2019-12-04 01:56:01 +00:00
Yiqiao Pu 3e1d45a8d6 Tests: Add inspect test check steps
Add check steps for inspect with container id and image id.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>

Closes: #2004
Approved by: rhatdan
2019-12-04 01:56:01 +00:00
caiges 9ff68b3cde Add builder identity annotations.
Use io.podman.version and fix inspect tests

Signed-off-by: caiges <caigesn@gmail.com>

Closes: #1917
Approved by: TomSweeneyRedHat
2019-11-16 19:27:47 +00:00
TomSweeneyRedHat 89bc2a6a6a 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-11-06 22:20:24 +00:00
Ed Santiago 6ecc6d6cb4 BATS tests - extensive but minor cleanup
This started off as bug fixes necessary to get BATS tests
actually working on RHEL8 (they weren't). It grew. I will
defend my actions in the first comment post.

Primary change: import some helpers from podman BATS tests,
most importantly 'run_buildah' and 'is'. The vast majority
of the changes you'll see here are of the form:

    - run buildah ...
    - [ $status = 0 ]
    - [ check $output ]
    + run_buildah ...            ! automatically checks status
    + is "$output" "..."

Also: chmod'ed some files -x. Necessary because rpmbuild tries
to be oh-so-clever about requirements, and when it sees an
executable file with a shebang line like '#!env bats' it
helpfully adds 'Requires: /usr/bin/bats' to the rpm, which
then fails to install because RHEL8 does not have bats.

Also: refactored duplicate code in a few places, by writing
and invoking module-specific helper functions.

Also: changed a handful of 'buildah's to run_buildah, in
order to get error checking and debug logging.

Also: added descriptive reasons to many "skip"s.

Also: selinux test: some tweakery to make it run on production
system (context is different if /usr/bin/buildah is chcon'ed
appropriately). I can't get this test to pass on Fedora from
a build dir, and I'm actually not convinced that this test
has ever passed, but let's see what CI shows.

Also: selinux test: skip broken test (#1465).

Also: version test: skip parts of it if running w/o sources.

Tests are now passing as root on RHEL8; rootless has numerous
failures which I don't believe are related to this PR.

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #1472
Approved by: TomSweeneyRedHat
2019-04-06 16:25:42 +00:00
Boaz Shuster e04613f051 Add flags/arguments order verification to one arg commands
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>

Closes: #984
Approved by: rhatdan
2018-09-04 14:46:36 +00:00
Zhou Hao fa8991f732 add test to inspect
Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>

Closes: #725
Approved by: rhatdan
2018-05-28 11:48:20 +00:00
Zhou Hao 858bd4fc71 add test to inspect
Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>

Closes: #715
Approved by: rhatdan
2018-05-22 13:19:07 +00:00
Boaz Shuster 5b4389cf69 Show Config/Manifest as JSON string in inspect when format is not set
In https://github.com/projectatomic/buildah/issues/363:
Config and Manifest are displayed as a string representing JSON
only when "--format" is set. However, this is necessary too if
"--format" is not set.

This patch fixes this by using the same technique above
to make the representation of Manifest and Config consistent.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>

Closes: #522
Approved by: rhatdan
2018-03-20 09:21:22 +00:00
baude e623e5c004 Initial ginkgo framework
This is an initial attempt at bringing in the ginkgo test framework into
buildah.  The inspect bats file was also imported.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #472
Approved by: rhatdan
2018-02-22 13:06:08 +00:00
Boaz Shuster 947714fbd2 Unescape HTML characters output into the terminal
By default, the JSON encoder from the Go standard library
escapes the HTML characters which causes the maintainer output
looks strange:

"maintainer": "NGINX Docker Maintainers \u003cdocker-maint@nginx.com\u003e"
Instead of:
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"

This patch fixes this issue in "buildah-inspect" only as this is
the only place that such characters are displayed.

Note: if the output of "buildah-inspect" is piped or redirected
then the HTML characters are not escaped.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>

Closes: #421
Approved by: rhatdan
2018-01-30 04:51:17 +00:00
Nalin Dahyabhai 76395efa52 Add an initial "inspect" command
Add an "inspect" command, which can be used to dump the contents of the
Buildah object for a working container, or the starting one we'd get for
a specified image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #109
Approved by: rhatdan
2017-05-19 11:29:12 +00:00