Compare commits

...

1048 Commits

Author SHA1 Message Date
openshift-merge-bot[bot] b03bc242a7
Merge pull request #6294 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.64.0
2025-07-17 17:11:10 +00:00
openshift-merge-bot[bot] 1c0fb347c3
Merge pull request #6292 from containers/renovate/github.com-spf13-pflag-1.x
fix(deps): update module github.com/spf13/pflag to v1.0.7
2025-07-17 14:30:13 +00:00
renovate[bot] e729f60d50
fix(deps): update module github.com/containers/common to v0.64.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-17 05:14:17 +00:00
renovate[bot] 8b5354ee8c
fix(deps): update module github.com/spf13/pflag to v1.0.7
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-16 22:12:08 +00:00
openshift-merge-bot[bot] b3eab30b05
Merge pull request #6290 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.36.0
2025-07-16 14:05:02 +00:00
renovate[bot] 9c525fd526
fix(deps): update module github.com/containers/image/v5 to v5.36.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-15 23:26:18 +00:00
openshift-merge-bot[bot] db61e10b3f
Merge pull request #6287 from containers/renovate/github.com-containers-storage-1.x
fix(deps): update module github.com/containers/storage to v1.59.0
2025-07-14 21:07:21 +00:00
renovate[bot] b8c6fcf211
fix(deps): update module github.com/containers/storage to v1.59.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-14 18:59:21 +00:00
openshift-merge-bot[bot] 8403fd604b
Merge pull request #6269 from flouthoc/cache-canidates
stage_executor: check platform of cache candidates
2025-07-11 17:45:22 +00:00
flouthoc 3502889676
stage_executor: check platform of cache candidates
When building images for `manifest` list using `--platform` same image
is used for multiple platform if base is `scratch` , following PR adds a
check to always verify `platform` of `cache` with `target`.

Closes: https://github.com/containers/podman/issues/18723

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-11 09:44:07 -07:00
openshift-merge-bot[bot] 252cc24fd5
Merge pull request #6240 from 2004joshua/link
feat: ADD/COPY --link support for buildah
2025-07-11 15:27:00 +00:00
openshift-merge-bot[bot] 869997e379
Merge pull request #6278 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.40.0
2025-07-11 15:07:26 +00:00
openshift-merge-bot[bot] aa807d5863
Merge pull request #6252 from pstoeckle/main
chore(typos): fix typos
2025-07-11 09:20:15 +00:00
renovate[bot] 96588db2e6
fix(deps): update module golang.org/x/crypto to v0.40.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 18:07:11 +00:00
openshift-merge-bot[bot] 1c0e79c974
Merge pull request #6277 from containers/renovate/golang.org-x-term-0.x
fix(deps): update module golang.org/x/term to v0.33.0
2025-07-10 18:05:47 +00:00
openshift-merge-bot[bot] a2108716b5
Merge pull request #6272 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.3.2+incompatible
2025-07-10 17:38:18 +00:00
renovate[bot] d9443fe42f
fix(deps): update module golang.org/x/term to v0.33.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 16:53:00 +00:00
openshift-merge-bot[bot] cc938ce53f
Merge pull request #6273 from containers/renovate/golang.org-x-sync-0.x
fix(deps): update module golang.org/x/sync to v0.16.0
2025-07-10 16:11:04 +00:00
renovate[bot] d6e5cbaf74
fix(deps): update module golang.org/x/sync to v0.16.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 02:45:42 +00:00
renovate[bot] c694e3c7a2
fix(deps): update module github.com/docker/docker to v28.3.2+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-09 23:15:31 +00:00
Joshua Arrevillaga eea4838d88 ADD/COPY --link support added
What type of PR is this?
/kind feature

What this PR does / why we need it:
It implements --link for COPY and ADD instructions and enables the creation of
cachable layers that can be reused independently across builds.

Follows buildkit `--link` specifications

How to verify it
bats tests/bud.bats

Which issue(s) this PR fixes:
Fixes #4325

Does this PR introduce a user-facing change?
Yes, gives extra functionality to Containerfiles

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
2025-07-09 17:14:28 -04:00
openshift-merge-bot[bot] 1b5cdd50fa
Merge pull request #6259 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.3.1+incompatible
2025-07-09 18:43:29 +00:00
openshift-merge-bot[bot] d23f64120a
Merge pull request #6264 from flouthoc/passwd-test
buildah: move `passwd` command to tests
2025-07-09 17:51:38 +00:00
Lokesh Mandvekar 063ee76258
RPM/TMT: account for passwd binary moving to tests
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
Co-authored-by: flouthoc <flouthoc.git@gmail.com>
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-09 06:31:09 -07:00
flouthoc af210ea877
buildah: move passwd command to tests
https://github.com/containers/buildah/issues/6182

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-09 06:31:04 -07:00
openshift-merge-bot[bot] f67acf9a69
Merge pull request #6267 from rahilarious/main
Remove BUILDTAG btrfs_noversion as no longer effective
2025-07-09 09:21:08 +00:00
openshift-merge-bot[bot] 68c0bbacdf
Merge pull request #6271 from nalind/cgroups
Update "bud with --cpu-shares" test, and rename it
2025-07-09 04:42:40 +00:00
openshift-merge-bot[bot] 1b4cb34e0f
Merge pull request #6256 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.23.2
2025-07-08 23:24:28 +00:00
Nalin Dahyabhai 16c0bdad5f Update "bud with --cpu-shares" test, and rename it
Update "the bud with --cpu-shares" test to expect the a cgroupsv2 value
computed using either the older formula or the newer one introduced in
github.com/opencontainers/cgroups v0.0.3, and give it a unique name so
that it can be selected more easily with bats's "--filter" flag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-07-08 16:38:40 -04:00
openshift-merge-bot[bot] 564f525213
Merge pull request #6255 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to bc60f96
2025-07-08 18:06:09 +00:00
Rahil Bhimjiani 7a482acebc
Remove BUILDTAG btrfs_noversion as no longer effective
https://github.com/containers/storage/pull/2308

Signed-off-by: Rahil Bhimjiani <me@rahil.rocks>
2025-07-07 19:30:09 +05:30
renovate[bot] c0fdc9a056
fix(deps): update module github.com/docker/docker to v28.3.1+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-03 02:37:47 +00:00
renovate[bot] 513775f3f3
fix(deps): update module github.com/moby/buildkit to v0.23.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-01 20:44:06 +00:00
renovate[bot] 34488b5497
fix(deps): update github.com/containers/luksy digest to bc60f96
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-01 05:10:26 +00:00
openshift-merge-bot[bot] 5408a8b3e9
Merge pull request #6251 from Luap99/vendor
vendor: update c/{common,image,storage} to main
2025-06-30 16:57:15 +00:00
Patrick Stoeckle 9f809a88ff
chore(typos): fix typos
Signed-off-by: Patrick Stoeckle <patrick.stoeckle@siemens.com>
2025-06-30 15:45:47 +02:00
Paul Holzinger d95b2dad17
vendor: update c/{common,image,storage} to main
Pull in the rekor removal from c/image which reduces the dependencies.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-30 13:40:22 +02:00
openshift-merge-bot[bot] 4ceee32d77
Merge pull request #6250 from containers/renovate/go-github.com-go-viper-mapstructure-v2-vulnerability
chore(deps): update module github.com/go-viper/mapstructure/v2 to v2.3.0 [security]
2025-06-27 21:36:35 +00:00
renovate[bot] b47791a931
chore(deps): update module github.com/go-viper/mapstructure/v2 to v2.3.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-27 17:10:01 +00:00
openshift-merge-bot[bot] 7a243f955e
Merge pull request #6249 from containers/renovate/go.etcd.io-bbolt-1.x
fix(deps): update module go.etcd.io/bbolt to v1.4.2
2025-06-27 17:08:38 +00:00
renovate[bot] 46e8141739
fix(deps): update module go.etcd.io/bbolt to v1.4.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-27 15:27:30 +00:00
openshift-merge-bot[bot] f28c074787
Merge pull request #6247 from nalind/source-date-epoch-build-arg
Accept SOURCE_DATE_EPOCH as a build-arg
2025-06-26 19:30:16 +00:00
openshift-merge-bot[bot] e6d26dd363
Merge pull request #6248 from actionmancan/update-neil-smith-github-username
Update Neil Smith's GitHub username in MAINTAINERS.md
2025-06-26 18:18:34 +00:00
G A Neil Smith f172a9d1de Update Neil Smith's GitHub username in MAINTAINERS.md
- Changed GitHub username from 'Neil-Smith' to 'actionmancan'
- Fixed GitHub URL from https://github.com/Neil-Smith to https://github.com/actionmancan
- Corrected column alignment by removing extra spaces
- Maintains Neil Smith's role as Community Manager

Does this PR introduce a user-facing change?

```release-note
None
```

Signed-off-by: G A Neil Smith <nesmith@redhat.com>
2025-06-26 13:14:41 -04:00
openshift-merge-bot[bot] 9f6205610c
Merge pull request #6242 from nalind/common-formats
Use containers/common's formats package instead of our own
2025-06-25 19:53:42 +00:00
openshift-merge-bot[bot] f828ea2f75
Merge pull request #6243 from cevich/add_release_test
Add conditional release-checking system test
2025-06-25 19:26:02 +00:00
Nalin Dahyabhai 149bf968f5 Accept SOURCE_DATE_EPOCH as a build-arg
When SOURCE_DATE_EPOCH is passed in as a build-arg, treat it as we would
if it was passed in via the environment or its own CLI flag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-25 15:19:32 -04:00
openshift-merge-bot[bot] b9c485c123
Merge pull request #6239 from nalind/oci-created-annotation
build, commit: set the OCI ...created annotation on OCI images
2025-06-25 19:17:49 +00:00
openshift-merge-bot[bot] 06abe5fc77
Merge pull request #6244 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.3.0+incompatible
2025-06-25 14:18:35 +00:00
renovate[bot] 5bb8d5ed43
fix(deps): update module github.com/docker/docker to v28.3.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-25 02:29:26 +00:00
Chris Evich 0832c3e081
Add conditional release-checking system test
Unfortunately on a number of occasions, Buildah has been released
officially with a `-dev` suffix in the version number.  Assist in
catching this mistake at release time by the addition of a simple
conditional test.  Note that it must be positively enabled by a
magic env. var. before executing the system tests.

Also (thanks to @lsm5) update the TMT test to trigger the new
condition for future Fedora releases.

Signed-off-by: Chris Evich <cevich@redhat.com>
2025-06-24 10:57:46 -04:00
Nalin Dahyabhai 52bbc61e1f info,inspect: use the "formats" package to get some builtins
Use the "formats" package to format `info` and `inspect` output, so that
template users will be able to use whatever functions are provided with
`images` and `containers` output, including "json", "lower", and "upper".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-23 16:17:04 -04:00
Nalin Dahyabhai 7944b4b2b0 Use containers/common's formats package instead of our own
Use the containers/common "formats" package, which started off as a copy
of our own and is still mostly the same, instead of our own.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-23 15:53:55 -04:00
Nalin Dahyabhai 5968d82047 build, commit: set the OCI ...created annotation on OCI images
When building or committing an image in OCI format, default to setting
the org.opencontainers.image.created annotation to the value used in the
image's config blob for the image's creation date. The behavior can be
controlled using the new --created-annotation flag.

Add --annotation and --unsetannotation flags to `buildah commit` which
mimic the same flags for `buildah build`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-23 15:05:02 -04:00
openshift-merge-bot[bot] e6375b3c28
Merge pull request #6236 from nalind/omit-layer-history-entry
Add CommitOptions.OmitLayerHistoryEntry, for skipping the new bits
2025-06-22 16:16:08 +00:00
openshift-merge-bot[bot] 9bfdf2a0b5
Merge pull request #6233 from nalind/mount-targets
run,commit: clean up parents of mount targets, too
2025-06-22 16:13:24 +00:00
Nalin Dahyabhai df36bb835a commit: exclude parents of mount targets, too
When RUN requires us to create the target for a mountpoint, make note of
it and any parent directories that needed to be created, and filter them
out when generating a layer diff or --output data.

The exceptions will be directories that the conformance tests confirm
that BuildKit also leaves behind, though for compatibility with the
classic builder, we have to make that conditional.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-20 11:19:27 -04:00
Nalin Dahyabhai a3bea818b8 run: clean up parents of mount targets, too
When RUN requires us to create the target for a mountpoint, make note of
it and any parent directories that needed to be created, and clear them
all out if they look basically the same after the command finishes.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-20 11:19:27 -04:00
Nalin Dahyabhai 7d5f1e1ca9 tarFilterer: always flush after writing
Always call the nested TarWriter's Flush() method after writing file
contents.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-20 11:19:27 -04:00
Nalin Dahyabhai fce45b77d0 Builder: drop the TempVolumes field
The TempVolumes field is used to track data that's specific to a Run()
call, and there can be more than one of those going at a time.  Merge
its data into the runMountArtifacts struct, which already keeps a list
of locations that we have to clean up in exactly the same way.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-20 11:19:27 -04:00
openshift-merge-bot[bot] dc1a1f5b3b
Merge pull request #6238 from containers/renovate/github.com-moby-buildkit-0.x
Update module github.com/moby/buildkit to v0.23.1
2025-06-20 15:18:37 +00:00
openshift-merge-bot[bot] c2a39c2cfa
Merge pull request #6237 from containers/renovate/github.com-opencontainers-cgroups-0.x
Update module github.com/opencontainers/cgroups to v0.0.3
2025-06-20 15:15:51 +00:00
renovate[bot] fe4c1b7342
Update module github.com/moby/buildkit to v0.23.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-20 11:58:54 +00:00
renovate[bot] 128153867b
Update module github.com/opencontainers/cgroups to v0.0.3
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-19 03:32:15 +00:00
Nalin Dahyabhai 5b1d3e666f Add CommitOptions.OmitLayerHistoryEntry, for skipping the new bits
Add an OmitLayerHistoryEntry field to CommitOptions, which more or less
causes us to reproduce our base image, except with PrependedEmptyLayers,
AppendedEmptyLayers, PrependedLinkedLayers, AppendedLinkedLayers, and
config changes still added in.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-18 10:48:54 -04:00
openshift-merge-bot[bot] 0b3a01c386
Merge pull request #6235 from containers/renovate/github.com-fsouza-go-dockerclient-1.x
Update module github.com/fsouza/go-dockerclient to v1.12.1
2025-06-18 12:49:33 +00:00
openshift-merge-bot[bot] 18deda6ee2
Merge pull request #6229 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.23.0
2025-06-18 12:35:27 +00:00
renovate[bot] 5995db7af7
Update module github.com/fsouza/go-dockerclient to v1.12.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-18 04:08:59 +00:00
openshift-merge-bot[bot] d944211073
Merge pull request #6231 from nalind/bats-tmpdir
commit-with-extra-files test: use $TEST_SCRATCH_DIR
2025-06-18 04:07:49 +00:00
openshift-merge-bot[bot] 3ffed0fd6b
Merge pull request #6228 from nalind/ci-rootless-supplemental-groups
CI: ensure rootless groups aren't duplicates
2025-06-18 01:15:20 +00:00
openshift-merge-bot[bot] 8b31e72fa1
Merge pull request #6232 from nalind/mirror-frontend
conformance: use mirrored frontend and base images
2025-06-17 21:35:03 +00:00
openshift-merge-bot[bot] b0541b60a2
Merge pull request #6230 from nalind/mounted-once-test
"root fs only mounted once" test: accept root with only the rw option
2025-06-17 21:13:03 +00:00
Nalin Dahyabhai c12808594b conformance: use mirrored frontend and base images
In conformance tests, use more mirrored frontend and base images.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-17 15:30:56 -04:00
Nalin Dahyabhai ee5fd19c8f commit-with-extra-files test: use $TEST_SCRATCH_DIR
Use $TEST_SCRATCH_DIR instead of $BATS_TMPDIR for temporary files that
we create during this test.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-17 15:02:16 -04:00
renovate[bot] c578786e55
fix(deps): update module github.com/moby/buildkit to v0.23.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-17 17:41:27 +00:00
Nalin Dahyabhai 3e11fea02e "root fs only mounted once" test: accept root with only the rw option
When checking /proc/self/mountinfo for a root filesystem, also match "/"
mounted with "rw" as its only mount option, as an alternative to being
mounted with "rw" and other options at the same time.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-17 12:55:55 -04:00
Nalin Dahyabhai f8f398bb3c Run with --device /dev/fuse and not just -v /dev/fuse:/dev/fuse
When passing /dev/fuse to a container, use --device instead of a plain
volume mount.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-17 09:22:47 -04:00
Nalin Dahyabhai a9a9a43962 CI: pass $BUILDAH_RUNTIME through to in-container test runs
Pass BUILDAH_RUNTIME through to tests that we run inside of containers,
and discard the CI_DESIRED_RUNTIME variable, which sort of did the same
thing.  We still set OCI to the name of the runtime because tests
consult it directly.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-17 09:22:14 -04:00
Nalin Dahyabhai b97fd7d686 CI: ensure rootless groups aren't duplicates
When adding an unprivileged user to run tests as, ensure that the
primary and supplemental groups are not repeated, and that at least one
supplemental group is outside of the user's subgid range.  When skipping
a test because the invoking user doesn't have any supplemental groups,
log the user's IDs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-17 09:18:47 -04:00
openshift-merge-bot[bot] 6a367e69a3
Merge pull request #6226 from ricardobranco777/runc
bud,run: runc does not support keep-groups
2025-06-17 12:08:30 +00:00
openshift-merge-bot[bot] 228f0cd1c5
Merge pull request #6227 from nalind/ci-rootless-supplemental-group
CI: give the rootless test user some supplemental groups
2025-06-16 15:44:06 +00:00
openshift-merge-bot[bot] 37706208b4
Merge pull request #6198 from flouthoc/inherit-annotation
build: add support for `--inherit-annotations`
2025-06-16 15:35:41 +00:00
flouthoc 47da2f29b2
build: add support for --inherit-annotations
Allows users to specify if they want to inherit annotations from base image
or not.

Closes: https://github.com/containers/buildah/issues/6153

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-06-13 12:28:12 -07:00
Nalin Dahyabhai 9ecc98e584 CI: give the rootless test user some supplemental groups
Exercise preservation of supplemental groups in the tests that use
`buildah build` and `buildah from` with `--group-add keep-groups`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-13 10:32:33 -04:00
openshift-merge-bot[bot] 1b39f59dd3
Merge pull request #5452 from aaronlehmann/support-zstd-commit
Support zstd compression in image commit
2025-06-12 20:43:05 +00:00
Ricardo Branco ab8fc6deeb
bud,run: runc does not support keep-groups
Signed-off-by: Ricardo Branco <rbranco@suse.de>
2025-06-12 15:19:57 +02:00
Aaron Lehmann 2eb666c22d Fix lint issue in TestCommitCompression
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2025-06-11 22:53:13 +00:00
Nalin Dahyabhai 873e5458c6 Add a unit test for compression types in OCI images
Add a unit test that commits OCI layouts with various types of
compression specified, and verifies that the layers end up written with
the desired compression and media type descriptors.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-11 22:42:59 +00:00
Aaron Lehmann aa84d9c347 Support zstd compression in image commit
Without this change, specifying `Compression: imagebuildah.Zstd` in
`imagebuildah`'s `BuildOptions fails, so it is not possible to push
cache to a registry with zstd compression.

Note this is only applicable to OCI manifests.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2025-06-11 22:42:59 +00:00
openshift-merge-bot[bot] 22201dbaa0
Merge pull request #6219 from containers/renovate/go.etcd.io-bbolt-1.x
fix(deps): update module go.etcd.io/bbolt to v1.4.1
2025-06-11 17:38:29 +00:00
openshift-merge-bot[bot] bf6d1ccbb8
Merge pull request #6214 from nalind/source-date-epoch-no-identity-label
commit,build: --source-date-epoch/--timestamp omit identity label
2025-06-11 17:24:36 +00:00
renovate[bot] 1aa6c1e35a
fix(deps): update module go.etcd.io/bbolt to v1.4.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-11 14:42:22 +00:00
openshift-merge-bot[bot] 2d8c3078ad
Merge pull request #6216 from Luap99/sqlite-dynamic-link
dynamically link sqlite
2025-06-11 13:28:45 +00:00
Paul Holzinger 03b980a3ef
rpm: build rpm with libsqlite3 tag
So we dynamically link to sqlite in fedora instead of vendoring a static
copy.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-11 10:31:54 +02:00
Paul Holzinger e5b876571b
Makefile: use libsqlite3 build when possible
Dynamically link sqlite3 when installed, the main motivation is that we
reduce the podman binary size with that. I see about 3.2 MB savings.

But also dynamically linking it means if there a vulnerabilities only
the sqlite3 distro package needs updating and we don't have to make a
new podman release with the vendored update.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-11 10:31:53 +02:00
Nalin Dahyabhai 962ab4bb1e commit,build: --source-date-epoch/--timestamp omit identity label
When using either --source-date-epoch or --timestamp, default to not
adding a label with our version number in it, since it can change
between builds.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-10 16:18:50 -04:00
openshift-merge-bot[bot] 5777aa3694
Merge pull request #6215 from nalind/countme
docs: add --setopt "*.countme=false" to dnf examples
2025-06-10 19:58:02 +00:00
Nalin Dahyabhai b167073d54 docs: add --setopt "*.countme=false" to dnf examples
* Consistently use --releasever instead of --release in dnf examples
* Remove trailing whitespace
* Use --use-host-config --setopt "*.countme=false" when running dnf with
  an empty --installroot
* Use Fedora 42 instead of Fedora 30 in examples
* Block quote console examples in tutorials

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-10 14:16:36 -04:00
openshift-merge-bot[bot] f46d15d721
Merge pull request #6217 from nalind/sbom-user
Builder.sbomScan(): don't break non-root scanners
2025-06-10 18:15:44 +00:00
Nalin Dahyabhai 9f35e8a2ac Builder.sbomScan(): don't break non-root scanners
Set up permissions on the scanner output directory so that scanners
whose images specify that they be run as non-root users can still write
to it.  The most recent syft image exposed our bug.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-10 13:22:20 -04:00
openshift-merge-bot[bot] d14b4f8dc7
Merge pull request #6211 from nalind/source-date-epoch-static-hostname
build: --source-date-epoch/--timestamp use static hostname/cid
2025-06-10 13:55:54 +00:00
openshift-merge-bot[bot] 714f5ba2e5
Merge pull request #6195 from flouthoc/unsetanno
build,config: add support for `--unsetannotation`
2025-06-09 14:19:35 +00:00
Nalin Dahyabhai 2d0152e99d build: --source-date-epoch/--timestamp use static hostname/cid
When using either --source-date-epoch or --timestamp, make sure that
handling of RUN instructions uses a defined hostname if possible, and
commits using a reference to a static container name.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-06 15:33:01 -04:00
openshift-merge-bot[bot] 12e41eca79
Merge pull request #6210 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.39.0
2025-06-06 19:22:48 +00:00
renovate[bot] 87d9db82c6
fix(deps): update module golang.org/x/crypto to v0.39.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-05 21:55:11 +00:00
openshift-merge-bot[bot] f05fe6e568
Merge pull request #6208 from nalind/build-source-date-epoch
build: add --source-date-epoch and --rewrite-timestamp flags
2025-06-05 21:54:10 +00:00
openshift-merge-bot[bot] da45fc8b82
Merge pull request #6209 from containers/renovate/golang.org-x-sync-0.x
fix(deps): update module golang.org/x/sync to v0.15.0
2025-06-05 17:35:29 +00:00
renovate[bot] 5842593d28
fix(deps): update module golang.org/x/sync to v0.15.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-05 16:11:23 +00:00
Nalin Dahyabhai 865daceebb build: add --source-date-epoch and --rewrite-timestamp flags
Use $SOURCE_DATE_EPOCH as the default for the --source-date-epoch flag
to the "build" CLI.

When a source-date-epoch is set, we'll use it when writing new history
entries, force timestamps in data written for --output to the specified
timestamp, and populate a "SOURCE_DATE_EPOCH" ARG that we treat as
always being set, and which we don't complain about being left unused.
By default, this will not affect timestamps in newly-added layers.

Add a --rewrite-timestamp flag, which "clamps" timestamps in newly-added
layers to not be later than the --source-date-epoch value if the
--source-date-epoch flag is set, but has no effect otherwise.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-05 10:22:56 -04:00
flouthoc 83acf720d9
build,config: add support for --unsetannotation
Just like `--unsetlabel` add support for `--unsetannotation`.

Closes: https://github.com/containers/buildah/issues/6183

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-06-04 12:58:43 -07:00
openshift-merge-bot[bot] b8d8cc375f
Merge pull request #6189 from nalind/commit-source-date-epoch
commit: add --source-date-epoch and --rewrite-timestamp flags
2025-06-04 19:30:37 +00:00
Nalin Dahyabhai 6c82e7eac0 commit: add --source-date-epoch and --rewrite-timestamp flags
Add a --source-date-epoch flag, defaulting to $SOURCE_DATE_EPOCH if set,
which sets the created-on date and the timestamp for the new history
entries, but does not default to modifying the timestamps on contents in
new layers.

Add a --rewrite-timestamp flag, which "clamps" timestamps in the new
layers to not be later than the --source-date-epoch value if both
the --rewrite-timestamp and --source-date-epoch flags were set.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-04 13:02:26 -04:00
openshift-merge-bot[bot] 2d32c9af2f
Merge pull request #6169 from Honny1/sort-glob-output
Ensure extendedGlob returns paths in lexical order
2025-06-04 17:02:03 +00:00
openshift-merge-bot[bot] bd021becfb
Merge pull request #6203 from containers/renovate/github.com-openshift-imagebuilder-1.x
fix(deps): update module github.com/openshift/imagebuilder to v1.2.16
2025-06-03 20:08:20 +00:00
renovate[bot] a4a30cf5e8
fix(deps): update module github.com/openshift/imagebuilder to v1.2.16
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-03 18:33:08 +00:00
openshift-merge-bot[bot] 9ece6d4ce8
Merge pull request #6200 from Luap99/vendor
vendor latest c/{common,image,storage}
2025-06-03 10:23:05 +00:00
Paul Holzinger 5b26b79221
vendor latest c/{common,image,storage}
Just to make sure tests are still passing, I mostly care about
https://github.com/containers/common/pull/2445.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-03 11:28:06 +02:00
openshift-merge-bot[bot] 7be35e17d3
Merge pull request #6190 from nalind/platforms
Tweak our handling of variant values, again
2025-06-02 15:46:18 +00:00
openshift-merge-bot[bot] 5da34800de
Merge pull request #6192 from mtrmac/ostree
Don't BuildRequires: ostree-devel
2025-06-02 14:23:27 +00:00
Nalin Dahyabhai 9c2b43cccb Tweak our handling of variant values, again
Ensure that when not invoked with --platform, we use the default
platform, and that when invoked with --platform, we use the platform
information from the base image that we ended up using for the build,
with no accidental mixing of the two.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-02 09:33:25 -04:00
openshift-merge-bot[bot] a5f229f155
Merge pull request #6188 from flouthoc/host-gateway
parse, validateExtraHost: honor `host-gateway` in format
2025-06-01 10:47:38 +00:00
Miloslav Trmač db336cef4d Don't BuildRequires: ostree-devel
We are not opting into the ostree backend, and it doesn't
build: https://github.com/containers/image/pull/2821 .
So, stop referencing the dependency.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-05-31 01:38:27 +02:00
openshift-merge-bot[bot] 7a56587b5d
Merge pull request #6191 from Luap99/nix-rm
remove static nix build
2025-05-30 17:51:37 +00:00
flouthoc 56f3171ab0
parse, validateExtraHost: honor Hostgateway in format
Flag `--add-host` should support `host-gateway` when argument is in the
form of `buildah build --add-host=proxyhost:host-gateway .`

This is consistent with podman.

Closes: https://github.com/containers/podman/issues/26034

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-05-30 09:56:35 -07:00
Paul Holzinger 56cfd2fdfc
remove static nix build
It is no longer working and no maintainer is using it.

Fixes: #6086

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-30 18:53:28 +02:00
openshift-merge-bot[bot] 5cc3e7d776
Merge pull request #6187 from JayKayy/fix-maintainers-link
fix link to Maintainers file
2025-05-30 14:25:49 +00:00
Jan Rodák 2717599f93
Ensure extendedGlob returns paths in lexical order
The `filepath.Glob` function does not provide deterministic output. In order to achieve a reproducible build, files must be copied in a deterministic manner, and `filepath.Glob` did not guarantee this. Other functions such as `filepath.Walk` and `os.ReadDir` return deterministic output. So copying files to the image is done in the same order each time.

Fixes: https://issues.redhat.com/browse/RUN-2661

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-05-30 10:32:11 +02:00
John Kwiatkoski 2158a0c331
Merge branch 'main' into fix-maintainers-link 2025-05-29 21:32:27 -04:00
openshift-merge-bot[bot] 5a02e74b5d
Merge pull request #6132 from nalind/relabel-binds
run: handle relabeling bind mounts ourselves
2025-05-29 23:50:22 +00:00
Nalin Dahyabhai 910933b33f CI: run integration tests on Fedora with both crun and runc
Run integration tests (both as root and rootless) with both crun and
runc on Fedora, to help ensure that we can use either.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-29 14:17:43 -04:00
Nalin Dahyabhai b122c325fa buildah-build(1): clarify that --cgroup-parent affects RUN instructions
Tweak the wording that describes the effects of --cgroup-parent to be
clear that it only affects handling of RUN instructions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-29 14:17:43 -04:00
Nalin Dahyabhai 8178c3a5d3 runUsingRuntime: use named constants for runtime states
Use the named constants for the status values that runtimes can report
to us when we run them with the "state" command.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-29 14:17:43 -04:00
Nalin Dahyabhai 4ea64c3871 Add a dummy "runtime" that just dumps its config file
Add a dummy "runtime" that just dumps its runtime config, either the
entirety of it, or a section of it corresponding to each command line
argument.  Tests can use it to ensure that we set the right thing in the
configuration without also depending on the runtime to do as its asked,
which isn't always something we have control over.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-29 14:17:37 -04:00
Nalin Dahyabhai d53d837e0e run: handle relabeling bind mounts ourselves
Handle requested relabeling of bind mounts (i.e., the "z" and "Z" flags)
directly, instead of letting the runtime handle the relabeling.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-29 09:27:09 -04:00
openshift-merge-bot[bot] 328e613826
Merge pull request #6186 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.2.0+incompatible
2025-05-29 13:22:03 +00:00
John Kwiatkoski 913e4d2d35 fix link to Maintainers file
Signed-off-by: John Kwiatkoski <jkwiatkoski@protonmail.com>
2025-05-28 22:34:33 -04:00
Nalin Dahyabhai c0c4148fc5 Update to avoid deprecated types
Replace our use of the
github.com/docker/docker/api/types.BuildCachePruneOptions with the
github.com/docker/docker/api/types/build.CachePruneOptions type, which
the former is now an alias for.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-28 17:55:13 -04:00
renovate[bot] 285dcc9140
fix(deps): update module github.com/docker/docker to v28.2.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-28 21:31:30 +00:00
openshift-merge-bot[bot] 199468a453
Merge pull request #6181 from lsm5/openssf-passing
[CI:DOCS] README.md: add openssf passing badge
2025-05-28 19:24:13 +00:00
openshift-merge-bot[bot] 279e47d3ca
Merge pull request #6124 from TomSweeneyRedHat/dev/tsweeney/cncfstart
[CI:DOCS] Add CNCF roadmap, touchup other CNCF files
2025-05-28 19:21:27 +00:00
openshift-merge-bot[bot] bdc01479ad
Merge pull request #6164 from lsm5/disable-osh-diff-scan
[skip-ci] Packit: Disable osh_diff_scan
2025-05-28 19:18:44 +00:00
openshift-merge-bot[bot] 9986534eea
Merge pull request #6178 from nalind/add-timestamp
add: add a new --timestamp flag
2025-05-28 19:16:00 +00:00
openshift-merge-bot[bot] 5168237d2b
Merge pull request #6179 from nalind/copier-ensure
copier: add Ensure and ConditionalRemove
2025-05-28 19:07:41 +00:00
openshift-merge-bot[bot] b178f3b7ef
Merge pull request #6177 from nalind/build-outputs
build: allow --output to be specified multiple times
2025-05-28 19:02:01 +00:00
openshift-merge-bot[bot] 0637485b62
Merge pull request #6176 from nalind/parse-get-build-output-cut
pkg/parse.GetBuildOutput(): use strings.Cut()
2025-05-28 18:58:37 +00:00
openshift-merge-bot[bot] 232cb99b76
Merge pull request #6175 from nalind/man-lists
[CI:DOCS] update a couple of lists in the build man page
2025-05-28 18:55:49 +00:00
openshift-merge-bot[bot] b535d02d0e
Merge pull request #6174 from nalind/42
Use Fedora 42 instead of 41 in that one conformance test
2025-05-23 15:16:39 +00:00
openshift-merge-bot[bot] 8b940c7062
Merge pull request #6170 from lsm5/packit-post-f40
[skip-ci] Packit: set fedora-all after F40 EOL
2025-05-22 14:59:36 +00:00
Lokesh Mandvekar 1f6302a6ef
[skip-ci] Packit: cleanup redundant targets and unused anchors
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-05-22 09:02:23 -04:00
Lokesh Mandvekar a99ad87afe
[skip-ci] Packit: set fedora-all after F40 EOL
As the title says.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-05-22 09:02:22 -04:00
Nalin Dahyabhai 26f4f3a025 Use Fedora 42 instead of 41 in that one conformance test
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 14:35:12 -04:00
openshift-merge-bot[bot] cc66b6e9d8
Merge pull request #6171 from flouthoc/select-recent-cache
imagebuildah: select most recent layer for cache in case on conflict
2025-05-21 17:55:04 +00:00
Lokesh Mandvekar eee1f2102a
[CI:DOCS] README.md: add openssf passing badge
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-05-21 10:50:49 -04:00
openshift-merge-bot[bot] ad17dac13a
Merge pull request #6180 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.22.0
2025-05-21 14:36:21 +00:00
renovate[bot] 48a4a446e3
fix(deps): update module github.com/moby/buildkit to v0.22.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-21 14:04:19 +00:00
Nalin Dahyabhai dda8e65e84 copier: add Ensure and ConditionalRemove
Add copier.Ensure() and copier.ConditionalRemove(), for controlling the
permissions and datestamps we set on multiple items we create with one
call (along with any parents), and selectively removing multiple items
with one call.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 09:54:21 -04:00
Nalin Dahyabhai d568dda6c0 [CI:DOCS] update a couple of lists in the build man page
The buildah-build man page enumerates the default set of masked and
read-only paths, but that list is hardwired into one of our
dependencies, and we didn't update this man page when it changed.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 09:53:28 -04:00
Nalin Dahyabhai 3a85df003e build: allow --output to be specified multiple times
Allow --output to be specified multiple times for `buildah build`.
That's of limited usefulness right now, but as exporters get added, it
won't be, and it's better to provide the new multiple-values API field
sooner rather than later.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 09:53:04 -04:00
Nalin Dahyabhai b9a65a9d86 add: add a new --timestamp flag
Add a --timestamp flag to the "add" and "copy" CLIs, along with a
corresponding field in AddAndCopyOptions.

When a timestamp is set, we'll force the timestamp on data copied in to
be the specified value while reading it, so that the content will have
the specified datestamp in the rootfs and when the image is committed.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 09:51:51 -04:00
Nalin Dahyabhai a57e7f4b24 tests/helpers.bash: add some helpers for parsing images
Add some helper functions for parsing the information from dir: and oci:
locations that we'd just have to do over and over with minor variations,
to try to save some time and a refactor down the road.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 09:51:51 -04:00
Nalin Dahyabhai 5cfbf72410 pkg/parse.GetBuildOutput(): use strings.Cut()
Use strings.Cut() to make this a little easier to follow.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-21 09:44:46 -04:00
Lokesh Mandvekar ca3271a15c
[skip-ci] Packit: Disable osh_diff_scan
No golang support yet in osh diff scan.
Ref: https://github.com/openscanhub/known-false-positives/pull/30#issuecomment-2858698495

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-05-21 09:19:42 -04:00
openshift-merge-bot[bot] e7b6bd0089
Merge pull request #6173 from nalind/set-has
internal/util.SetHas(): handle maps of [generic]generic
2025-05-20 23:59:25 +00:00
Nalin Dahyabhai ee0f750ea7 internal/util.SetHas(): handle maps of [generic]generic
Make SetHas() a generic function for checking if a map holds a value of
whatever kind for a key of some comparable kind.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-20 17:53:33 -04:00
openshift-merge-bot[bot] 5a60789759
Merge pull request #6172 from lsm5/ignore-centos-eln
[skip-ci] Packit: Ignore ELN and CentOS Stream jobs
2025-05-20 21:33:33 +00:00
Aaron Lehmann cf4635e86b
Refactor NewImageSource to add a manifest type abstraction (#5743)
* Refactor NewImageSource to add a manifest type abstraction

Currently, NewImageSource creates a Docker schema2 manifest and an OCI
manifest at the same time. This precludes functionality that isn't
supported by both manifest types, for example zstd compression.
Refactoring this to create only the desired manifest type solves this
and also cleans up the code by separating manifest-type-specific code
into distinct implementations of a "manifest builder".

See discussion in https://github.com/containers/buildah/pull/5452.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>

* Review feedback

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>

* Review feedback, round 2

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>

---------

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
Co-authored-by: flouthoc <flouthoc@users.noreply.github.com>
2025-05-20 13:08:17 -07:00
Lokesh Mandvekar 964ec24c13
[skip-ci] Packit: Ignore ELN and CentOS Stream jobs
Ignore these jobs until go 1.23.3+ is available in their buildroots

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-05-20 15:48:28 -04:00
flouthoc 8f885843db
imagebuildah: select most recent layer for cache
If multiple layers are found as cache candidates then select the layer
which was created recently.

Closes: https://github.com/containers/buildah/issues/6152

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-05-20 10:34:21 -07:00
tomsweeneyredhat 7fbca08c02 [CI:DOCS] Add CNCF roadmap, touchup other CNCF files
Added a ROADMAP.md file per CNCF requirements.

Updated the GOVERNANCE.md file to point to and use the local
MAINTAINERS.md file instead of the one in Podman.  Also added
links to the OWNERS file.

Updated the MAINTAINERS.md file to bump Aditya Rajan to a
Maintainer from a reviewer. Having him as a reviewer was
a cut/paste error that was not caught when the file was
first generated from the Podman file.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-05-20 13:21:45 -04:00
openshift-merge-bot[bot] a1dad28e32
Merge pull request #6156 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.38.0
2025-05-14 14:53:50 +00:00
renovate[bot] 168eef4734
fix(deps): update module golang.org/x/crypto to v0.38.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-14 13:33:24 +00:00
Sascha Brawer ada0ac0b89
Fix typo in comment (#6167)
Signed-off-by: Sascha Brawer <sascha@brawer.ch>
2025-05-13 19:04:04 -07:00
openshift-merge-bot[bot] cd2bb6169f
Merge pull request #6161 from rhatdan/security
Support label_users in buildah
2025-05-06 14:20:15 +00:00
Daniel J Walsh 081e9b308d
Support label_users in buildah
Fixes: https://github.com/containers/buildah/issues/6160

label_users tells buildah and podman to maintain the user and role
from the SELinux label, the default is to change the user and role to
system_u:system_r.

With this change we end up with an unconfined_u user running the
container as unconfined_u:unconfined_r.

I don't believe our CI/CD system can test this, because it runs with
system_u:system_r by default.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2025-05-06 07:13:27 -04:00
openshift-merge-bot[bot] 646fb21ef2
Merge pull request #6154 from containers/renovate/golang.org-x-sync-0.x
fix(deps): update module golang.org/x/sync to v0.14.0
2025-05-05 15:41:52 +00:00
renovate[bot] 27c2c3e4ba
fix(deps): update module golang.org/x/sync to v0.14.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-05 14:48:34 +00:00
openshift-merge-bot[bot] 7ba98de415
Merge pull request #6151 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to 4bb4c3f
2025-05-02 13:44:03 +00:00
openshift-merge-bot[bot] a79f540723
Merge pull request #6146 from nalind/serve-leak
test/serve: fix a descriptor leak, add preliminary directory support
2025-05-02 09:38:09 +00:00
renovate[bot] ffcbec7f79
fix(deps): update github.com/containers/luksy digest to 4bb4c3f
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-01 03:02:39 +00:00
Nalin Dahyabhai cbe5823958 test/serve: fix a descriptor leak, add preliminary directory support
Fix a descriptor leak in the helper, and add some minimal support for
clients that might want to scrape HTML of a directory to walk the
filesystem.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-04-30 11:50:42 -04:00
openshift-merge-bot[bot] 36c3f13d85
Merge pull request #6150 from containers/renovate/github.com-opencontainers-cgroups-0.x
fix(deps): update module github.com/opencontainers/cgroups to v0.0.2
2025-04-30 15:47:51 +00:00
renovate[bot] f97596adf3
fix(deps): update module github.com/opencontainers/cgroups to v0.0.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-30 14:45:32 +00:00
openshift-merge-bot[bot] 8e43db65ca
Merge pull request #6147 from containers/renovate/github.com-opencontainers-runc-1.x
fix(deps): update module github.com/opencontainers/runc to v1.3.0
2025-04-30 14:44:23 +00:00
openshift-merge-bot[bot] f91b3f70fe
Merge pull request #6149 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.21.1
2025-04-30 14:41:37 +00:00
openshift-merge-bot[bot] 5731583e94
Merge pull request #6141 from hanwen-flow/image-fixes
Filter image only when necessary
2025-04-30 13:02:18 +00:00
renovate[bot] fd8e85e833
fix(deps): update module github.com/moby/buildkit to v0.21.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-29 23:28:31 +00:00
Nalin Dahyabhai 9ac03e6bf9 Update to avoid deprecated types
Replace our use of the
github.com/opencontainers/runc/libcontainer/devices.Permissions type
with the github.com/opencontainers/cgroups/devices/config.Permissions
type, which the former is now an alias for.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-04-29 14:17:29 -04:00
renovate[bot] 7ce7072f25
fix(deps): update module github.com/opencontainers/runc to v1.3.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-29 17:49:49 +00:00
Han-Wen Nienhuys a59af89cd8 Only filter if containerImageRef.created != nil
This option is set from CommitOptions.HistoryTimestamp, which
corresponds to the buildah option '--timestamp', and therefore is off
by default.

If this option is not given, we can save ourselves one layer of
copying (tar filtering is a tar.Reader/tar.Writer connnected with io.Pipe())

Signed-off-by: Han-Wen Nienhuys <hanwen@engflow.com>
2025-04-29 08:21:28 +02:00
Han-Wen Nienhuys 2dae3b4656 Drop superfluous cast
Signed-off-by: Han-Wen Nienhuys <hanwen@engflow.com>
2025-04-29 08:21:28 +02:00
Han-Wen Nienhuys 15278aa27d Remove UID/GID scrubbing.
As of
e024854ba3,
Uname/Gname fields are not populated on Unix. On Windows, the golang
tar package leaves the Uname/Gname fields empty.

Signed-off-by: Han-Wen Nienhuys <hanwen@engflow.com>
2025-04-29 08:21:28 +02:00
openshift-merge-bot[bot] e886f271ee
Merge pull request #6144 from containers/renovate/github.com-seccomp-libseccomp-golang-0.x
fix(deps): update module github.com/seccomp/libseccomp-golang to v0.11.0
2025-04-24 20:06:56 +00:00
renovate[bot] ef7ad851a6
fix(deps): update module github.com/seccomp/libseccomp-golang to v0.11.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-23 22:55:14 +00:00
openshift-merge-bot[bot] 420e4bfd0a
Merge pull request #6142 from containers/renovate/major-ci-vm-image
chore(deps): update dependency containers/automation_images to v20250422
2025-04-23 15:48:04 +00:00
Paul Holzinger e4cf6cbb90
cirrus: turn prior fedora testing back on
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-23 16:07:43 +02:00
renovate[bot] 5de286ca8e
chore(deps): update dependency containers/automation_images to v20250422
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-23 16:05:19 +02:00
openshift-merge-bot[bot] d6370d08de
Merge pull request #6138 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.1.1+incompatible
2025-04-21 19:40:56 +00:00
renovate[bot] 97cf88f504
fix(deps): update module github.com/docker/docker to v28.1.1+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-21 19:03:21 +00:00
openshift-merge-bot[bot] 614e42b808
Merge pull request #6136 from TomSweeneyRedHat/dev/tsweeney/v1.40.0
Bump c/storage v1.58.0, c/image v5.35.0, c/common v0.63.0, Buildah v1.40.0, then to dev
2025-04-21 15:10:17 +00:00
Tom Sweeney 58b1f29836
Merge branch 'main' into dev/tsweeney/v1.40.0 2025-04-17 16:59:01 -04:00
tomsweeneyredhat 36adabb2d6 Bump to Buildah v1.41.0-dev
Bump the main Buildah branch to the next dev version,
Buildah v1.41.0-dev

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-04-17 15:21:28 -04:00
tomsweeneyredhat ff62e3e8a5 Bump Buildah to v1.40.0
Bump Buildah to v1.40.0 in preparation
for Podman v5.5.0

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-04-17 15:21:28 -04:00
tomsweeneyredhat d8495826cc Bump c/storage to v1.58.0, c/image v5.35.0, c/common v0.63.0
Bumps:
c/storage to v1.58.0
c/image to v5.35.0
c/common to v0.63.0

In preparation for Buildah 1.40.0 and Podman v5.5.0

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-04-17 15:21:20 -04:00
openshift-merge-bot[bot] 1db3b5465b
Merge pull request #6135 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.63.0
2025-04-17 17:37:55 +00:00
Nalin Dahyabhai 365ad53dfc CI vendor_task: pin to go 1.23.3 for now
Pin to 1.23.3 specifically instead of 1.23, for now.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-04-17 12:41:11 -04:00
renovate[bot] 522bc8ba58
fix(deps): update module github.com/containers/common to v0.63.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-17 15:36:04 +00:00
openshift-merge-bot[bot] a0945beb1e
Merge pull request #6134 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.1.0+incompatible
2025-04-17 15:29:22 +00:00
renovate[bot] a1df886a81
fix(deps): update module github.com/docker/docker to v28.1.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-17 14:26:17 +00:00
openshift-merge-bot[bot] 01d92cd614
Merge pull request #6129 from nalind/chroot-troubleshoot
chroot: use symbolic names when complaining about mount() errors
2025-04-17 13:51:54 +00:00
openshift-merge-bot[bot] 3a4249802e
Merge pull request #6099 from ninja-quokka/update_issue_template
Update Buildah issue template to new version and support podman build
2025-04-17 13:49:12 +00:00
openshift-merge-bot[bot] 01b8522d7a
Merge pull request #6127 from nalind/doc-src
[CI:DOCS] Document rw/src for --mount in buildah-run(1)
2025-04-17 13:45:52 +00:00
openshift-merge-bot[bot] a9d6f2d7f8
Merge pull request #6131 from containers/renovate/github.com-containers-storage-1.x
fix(deps): update module github.com/containers/storage to v1.58.0
2025-04-16 17:57:35 +00:00
openshift-merge-bot[bot] 018e1915d2
Merge pull request #6130 from Luap99/cirrus-rootless
cirrus: make Total Success wait for rootless integration
2025-04-16 17:54:53 +00:00
renovate[bot] aedcd3d19e
fix(deps): update module github.com/containers/storage to v1.58.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-16 16:19:48 +00:00
openshift-merge-bot[bot] 352eda35bc
Merge pull request #6128 from nalind/completion
cli: hide the `completion` command instead of disabling it outright
2025-04-16 16:18:31 +00:00
Paul Holzinger 5789a60072
cirrus: make Total Success wait for rootless integration
As discovered by Matt[1], without this we could merge PRs even if they
have failing rootless integration tests.

[1] https://github.com/containers/buildah/pull/6120#issuecomment-2797581476

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-16 18:09:30 +02:00
Nalin Dahyabhai 0da7ea1cc4 chroot: use symbolic names when complaining about mount() errors
Translate flags passed to mount() and read back using statfs() from hex
to named constants, to make troubleshooting a bit easier.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-04-15 17:53:43 -04:00
Nalin Dahyabhai 08cc023eef cli: hide the `completion` command instead of disabling it outright
Hide the cobra built-in `completion` command instead of disabling it
outright, since eventually we want to switch to using it instead of the
hand-written scripts we're currently using.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-04-15 17:28:28 -04:00
Nalin Dahyabhai 26ad103469 Document rw and src options for --mount flag in buildah-run(1)
Per discussion item 6084.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-04-15 17:22:01 -04:00
openshift-merge-bot[bot] dca9197ba1
Merge pull request #6125 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.21.0
2025-04-15 19:35:33 +00:00
renovate[bot] b85a67e5ce
fix(deps): update module github.com/moby/buildkit to v0.21.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-15 17:24:09 +00:00
openshift-merge-bot[bot] 9a82bcc989
Merge pull request #6103 from flouthoc/inherit-labels
build: add support for `--inherit-labels`
2025-04-15 17:15:12 +00:00
Aditya R a235033662
build: add support for inherit-labels
Allows users to specify if they want to inherit labels from base image
or not.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-04-14 14:01:00 -07:00
openshift-merge-bot[bot] ebbfb3ab13
Merge pull request #6122 from containers/renovate/golangci-golangci-lint-2.x
chore(deps): update dependency golangci/golangci-lint to v2.1.0
2025-04-14 14:08:47 +00:00
renovate[bot] d2e334df97
chore(deps): update dependency golangci/golangci-lint to v2.1.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-12 18:13:55 +00:00
openshift-merge-bot[bot] 0db475592c
Merge pull request #6120 from Luap99/github
.github: check_cirrus_cron work around github bug
2025-04-11 17:30:22 +00:00
Paul Holzinger e6a7608219
.github: check_cirrus_cron work around github bug
So I wondered why our email workflow only reported things for podman...

It seems the secrets: inherit is broken and no longer working, I see all
jobs on all repos failing with:

Error when evaluating 'secrets'. .github/workflows/check_cirrus_cron.yml (Line: 19, Col: 11): Secret SECRET_CIRRUS_API_KEY is required, but not provided while calling.

This makes no sense to me I doubled checked the names, nothing changed
on our side and it is consistent for all projects. Interestingly this
same thing passed on March 10 and 11 (on all repos) but failed before
and after this as well.

Per[1] we are not alone, anyway let's try to get this working again even
if it means more duplication.

[1] actions/runner#2709

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-11 18:59:18 +02:00
openshift-merge-bot[bot] 025e3e572f
Merge pull request #6110 from flouthoc/expand-mount-source
stage_executor,getCreatedBy: expand buildArgs before invoking `generatePathChecksum`
2025-04-10 17:34:59 +00:00
flouthoc bc05858e50
stage_executor,getCreatedBy: expand buildArgs for sources correctly
Patch in PR https://github.com/containers/buildah/pull/5691 added a
function to calculate and write checksum to history of `source` in
`--mount` instructions but it did not add part to expand build args if
they are present in `source` path.

Following PR Just corrects the above issue and also adds a new test to
make sure we don't break this in future again.

Closes: https://github.com/containers/podman/issues/25425

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-04-10 10:02:56 -07:00
openshift-merge-bot[bot] 2de361a69a
Merge pull request #6108 from mheon/add_governance_and_owners
Add a link to project governance and MAINTAINERS file
2025-04-10 15:11:16 +00:00
Matt Heon 53cd313e10 Add a link to project governance and MAINTAINERS file
The MAINTAINERS file is based on the current OWNERS file. I added
our core maintainers as they are expected to have commit bits on
all project repositories.

The existing MAINTAINERS file, which appears out of date, was
removed in favor of the new one (which has all CNCF mandated
information).

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-04-10 10:39:49 -04:00
openshift-merge-bot[bot] 5367a714f2
Merge pull request #6118 from kolyshkin/modernize
Modernize
2025-04-10 10:04:57 +00:00
openshift-merge-bot[bot] 47b3b1e783
Merge pull request #6100 from containers/renovate/github.com-containers-storage-digest
fix(deps): update github.com/containers/storage digest to b1d1b45
2025-04-09 21:57:59 +00:00
renovate[bot] d753211f60
fix(deps): update github.com/containers/storage digest to b1d1b45
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-09 20:15:23 +00:00
Kir Kolyshkin 608e4cc24f generateHostname: simplify
No functionality change, just code simplification.

Covered by existing test (e.g. "run should also override /etc/hostname"
in tests/run.bats).

NO NEW TESTS NEEDED

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 15:26:09 -07:00
Kir Kolyshkin f261d6641c Use maps.Copy
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 15:26:09 -07:00
Kir Kolyshkin 76e58eea14 Use slices.Concat
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 15:26:09 -07:00
Kir Kolyshkin 0835cb4760 Use slices.Clone
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 15:26:09 -07:00
Kir Kolyshkin 84a3905f61 Use slices.Contains
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 15:26:01 -07:00
Kir Kolyshkin 17777cf8ac Use for range over integers
Available since Go 1.22 (see https://tip.golang.org/ref/spec#For_range).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 10:19:51 -07:00
Kir Kolyshkin c46bbf46af tests/testreport: don't copy os.Environ
A slice returned by os.Environ is a already a brand new copy, no need to
copy it again.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 10:19:51 -07:00
Kir Kolyshkin 1ede7ddce7 Use any instead of interface{}
Brought to you by

	gofmt -r 'interface{} -> any' -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 10:19:51 -07:00
openshift-merge-bot[bot] bb240a6e40
Merge pull request #6109 from kolyshkin/golangci-v2
Golangci v2
2025-04-08 15:36:10 +00:00
openshift-merge-bot[bot] f42c70ea3a
Merge pull request #6117 from containers/renovate/github.com-containernetworking-cni-1.x
fix(deps): update module github.com/containernetworking/cni to v1.3.0
2025-04-07 21:59:58 +00:00
Kir Kolyshkin d9978eb2fa ci: add golangci-lint run with --tests=false
This helps to find out code which is unused except in its own self
tests. For example, see PR 6101.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:02:39 -07:00
Kir Kolyshkin e8dba98314 ci: add nolintlint, fix found issues
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:02:39 -07:00
Kir Kolyshkin 2162b3c93a copier: rm nolint:unparam annotation
This function always returns nil as the first parameter, which makes
unparam linter sad.

Rather than adding //nolint:unparam, let's just move nil to actual
returns.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:02:34 -07:00
Kir Kolyshkin 757175d2e6 .golangci.yml: add unused linter
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 4249d94d76 chroot: fix unused warnings
When running golangci-lint run --tests=false, it complains:

> chroot/seccomp.go:15:7: const `seccompAvailable` is unused (unused)
> const seccompAvailable = true
>       ^
> chroot/seccomp.go:182:6: func `setupSeccomp` is unused (unused)
> func setupSeccomp(spec *specs.Spec, seccompProfilePath string) error {
>      ^

Fix this.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin e548eaf146 copier: fix unused warnings
Found when running golangci-lint with --tests=false, which results in:

> copier/syscall_unix.go:89:2: const `testModeMask` is unused (unused)
> 	testModeMask           = int64(os.ModePerm)
> 	^
> copier/syscall_unix.go:90:2: const `testIgnoreSymlinkDates` is unused (unused)
> 	testIgnoreSymlinkDates = false
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 8b3c045638 tests/conformance: fix unused warning
There is some code in tests/conformance which is only used by tests.
Move it to *_test.go files.

Found by golangci-lint run --tests=false, which shows this warning:

> tests/conformance/selinux.go:9:6: func `selinuxMountFlag` is unused (unused)
> func selinuxMountFlag() string {
>      ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin e8a5d77b09 ci: switch to golangci-lint v2
Also, add a way to update golangci-lint locally, if an old version is
installed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 195c6b0c9e internal/mkcw: disable ST1003 warnings
Disable warnings like this one:

> internal/mkcw/workload.go:34:2: ST1003: should not use ALL_CAPS in Go names; use CamelCase instead (staticcheck)
> 	SEV_NO_ES = types.SEV_NO_ES //revive:disable-line:var-naming
> 	^

(

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin b13670be84 tests/conformance: do not double import (fix ST1019)
This fixes the following warning:

> tests/conformance/conformance_test.go:37:2: ST1019: package "github.com/containers/image/v5/storage" is being imported more than once (staticcheck)
> 	is "github.com/containers/image/v5/storage"
> 	^
> tests/conformance/conformance_test.go:38:2: ST1019(related information): other import of "github.com/containers/image/v5/storage" (staticcheck)
> 	istorage "github.com/containers/image/v5/storage"
> 	^

Fixes: 3a61cc099 ("Add OverrideChanges and OverrideConfig to CommitOptions")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 794715f9ae cmd/buildah: don't double import (fix ST1019)
This fixes the following warning:

> cmd/buildah/manifest.go:29:2: ST1019: package "github.com/opencontainers/image-spec/specs-go/v1" is being imported more than once (staticcheck)
> 	imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
> 	^
> cmd/buildah/manifest.go:30:2: ST1019(related information): other import of "github.com/opencontainers/image-spec/specs-go/v1" (staticcheck)
> 	v1 "github.com/opencontainers/image-spec/specs-go/v1"
> 	^

Fixes: aca884a89 ("`buildah manifest`: add artifact-related options")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin b343757b11 Do not capitalize error strings
This fixes "ST1005: error strings should not be capitalized
(staticcheck)" warnings.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 444edbee0c cmd/buildah: do not capitalize error strings
This fixes "ST1005: error strings should not be capitalized (staticcheck)" warnings

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 6cf417995b tests/conformance: fix QF1012 warnings
These:

> tests/conformance/conformance_test.go:1361:16: QF1012: Use fmt.Fprintf(...) instead of Write([]byte(fmt.Sprintf(...))) (staticcheck)
> 		if _, err := tw.Write([]byte(fmt.Sprintf("Field\tDocker\t%s\n", notDocker))); err != nil {
> 		             ^
> tests/conformance/conformance_test.go:1393:16: QF1012: Use fmt.Fprintf(...) instead of Write([]byte(fmt.Sprintf(...))) (staticcheck)
> 		if _, err := tw.Write([]byte(fmt.Sprintf("File:attr\tDocker\t%s\n", notDocker))); err != nil {
> 		             ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin f6e63ef10c tests/serve: fix QF1012 warning
This one:

> tests/serve/serve.go:56:16: QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
> 		if _, err := f.WriteString(fmt.Sprintf("%d", os.Getpid())); err != nil {
> 		             ^

Instead of following the (decent) recommendation, use os.WriteFile
and replace printf(%d) with strconv.Itoa.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin f9aed9704e Use strings.ReplaceAll to fix QF1004 warnings
These:

> cmd/buildah/images.go:192:10: QF1004: could use strings.ReplaceAll instead (staticcheck)
> 		return strings.Replace(opts.format, `\t`, "\t", -1)
> 		       ^
> pkg/formats/formats.go:97:16: QF1004: could use strings.ReplaceAll instead (staticcheck)
> 		t.Template = strings.Replace(strings.TrimSpace(t.Template[5:]), " ", "\t", -1)
> 		             ^
> tests/testreport/testreport.go:328:13: QF1004: could use strings.ReplaceAll instead (staticcheck)
> 		sysctl := strings.Replace(path, "/", ".", -1)
> 		          ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 52001ac4de Use switch to fix QF1003 warnings
These:

> copier/copier.go:1664:2: QF1003: could use tagged switch on hdr.Typeflag (staticcheck)
> 	if hdr.Typeflag == tar.TypeReg {
> 	^
> pkg/parse/parse.go:708:4: QF1003: could use tagged switch on arr[1] (staticcheck)
> 			if arr[1] == "local" {
> 			^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 7b15646547 Apply De Morgan's law to fix QF1001 warnings
This fixes the following warnings:

> chroot/run_test.go:319:39: QF1001: could apply De Morgan's law (staticcheck)
> 				if limit == unix.RLIM_INFINITY && !(rlim == nil || (rlim.Soft == unix.RLIM_INFINITY && rlim.Hard == unix.RLIM_INFINITY)) {
> 				                                  ^
> copier/copier.go:1012:92: QF1001: could apply De Morgan's law (staticcheck)
> 			if target, err := os.Readlink(filepath.Join(workingPath, components[0])); err == nil && !(len(components) == 1 && !evaluateFinalComponent) {
> 			                                                                                        ^
> run_linux.go:459:118: QF1001: could apply De Morgan's law (staticcheck)
> 	if !slices.Contains(volumes, resolvconf.DefaultResolvConf) && options.ConfigureNetwork != define.NetworkDisabled && !(len(b.CommonBuildOpts.DNSServers) == 1 && strings.ToLower(b.CommonBuildOpts.DNSServers[0]) == "none") {
> 	                                                                                                                    ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 35a5b3aaef Fix QF1007 staticcheck warnings
These:

> add.go:457:2: QF1007: could merge conditional assignment into variable declaration (staticcheck)
> 	newDestDirFound := false
> 	^
> cmd/buildah/umount.go:33:2: QF1007: could merge conditional assignment into variable declaration (staticcheck)
> 	umountAll := false
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin cc2c6d361c imagebuildah: fix revive warning
> imagebuildah/stage_executor.go:714:13: superfluous-else: if block ends with a break statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
> 					} else {
> 						// Treat the source's name as the name of an image.
> 						mountPoint, err := s.getImageRootfs(s.ctx, from)
> 						if err != nil {
> 							return nil, fmt.Errorf("%s from=%s: no stage or image found with that name", flag, from)
> 						}
> 						stageMountPoints[from] = internal.StageMountDetails{
> 							IsImage:    true,
> 							DidExecute: true,
> 							MountPoint: mountPoint,
> 						}
> 						break
> 					}
>

(The alternative is to keep "else" and remove "break", but there are
other break statements above it, so for style consistency it's better to
keep using break.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin dcabec56ec Rename max variable
This fixes the following warnings:

> run_linux.go:1065:3: redefines-builtin-id: redefinition of the built-in function max (revive)
> 		max := define.RLimitDefaultValue
> 		^
> run_linux.go:1069:5: redefines-builtin-id: redefinition of the built-in function max (revive)
> 				max = rlimit.Max
> 				^
> run_linux.go:1077:3: redefines-builtin-id: redefinition of the built-in function max (revive)
> 		max := define.RLimitDefaultValue
> 		^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin ea1baab2c3 tests/tools: install lint from binary, use renovate
This way is recommended by golangci-lint developers, plus we'll save
some build time.

In addition, add GOLANGCI_LINT_VERSION to the top-level Makefile,
so it can be updated by renovate.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
openshift-merge-bot[bot] 1051965337
Merge pull request #5971 from flouthoc/reset-context-platform
stage_executor: reset platform in systemcontext for every stage.
2025-04-07 18:41:45 +00:00
openshift-merge-bot[bot] b25cf06bd3
Merge pull request #6115 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.37.0
2025-04-07 17:26:35 +00:00
renovate[bot] 76be539d63
fix(deps): update module github.com/containernetworking/cni to v1.3.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-07 16:41:19 +00:00
Lewis 17bb74308c
Update Buildah issue template to new version and support podman build
Signed-off-by: Lewis Denny <lewis@redhat.com>
2025-04-07 09:51:57 +10:00
renovate[bot] b459a0720d
fix(deps): update module golang.org/x/crypto to v0.37.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-06 17:32:12 +00:00
flouthoc 022ff233fc
stage_executor: reset platform in systemcontext for stages
Every stage now has its own copy of systemcontext.

On processing of every stage platform spec in systemcontext must be
correctly reset.

Closes: https://github.com/containers/buildah/issues/5968

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-04-03 09:19:05 -07:00
openshift-merge-bot[bot] 7509c34542
Merge pull request #6102 from containers/renovate/github.com-opencontainers-runtime-tools-digest
fix(deps): update github.com/opencontainers/runtime-tools digest to 260e151
2025-04-02 20:45:52 +00:00
openshift-merge-bot[bot] 72fddb21db
Merge pull request #6101 from kolyshkin/unused
cmd/buildah: rm unused code
2025-04-02 18:44:47 +00:00
openshift-merge-bot[bot] 32d78c69be
Merge pull request #6092 from flouthoc/git-error-cde
build: return `ExecErrorCodeGeneric` when git operation fails instead of relaying error code directly from git
2025-04-01 18:08:30 +00:00
renovate[bot] e758787602
fix(deps): update github.com/opencontainers/runtime-tools digest to 260e151
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-01 07:28:54 +00:00
Kir Kolyshkin 03da194c75 cmd/buildah: rm unused containerOutputUsingTemplate
Its last user was removed by commit 726e24d5e ("make --format
columnizing consistent with buildah images) in 2019, so since that time
it is not used by anyone but its own unit tests.

Remove it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 23:01:38 -07:00
Kir Kolyshkin 5e6c645e63 cmd/buildah: rm unused getDateAndDigestAndSize
The last user of getDateAndDigestAndSize was removed by commit dcd2a92e5
("use new containers/common/libimage package") in 2021, so since that it
is not used anywhere except its own unit test.

Remove it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 23:00:49 -07:00
flouthoc a4bc357820
build: return ExecErrorCodeGeneric when git operation fails
Only propagate error message from git and let buildah reflect error code
`125`.

Reason: Buildah should return predicatable error code from the set of
defined error codes in exec_codes.go at https://github.com/containers/buildah/blob/main/pkg/cli/exec_codes.go#L6
anything other that predefined error codes introduces inconsistency thus making testing difficult in CI and podman.

Users should expect buildah to refect ExecErrorCodeGeneric with error message kept intact from the underlying `git`
commands.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-03-28 07:06:44 -07:00
openshift-merge-bot[bot] 898fbb2d25
Merge pull request #6083 from danegsta/danegsta/windowsExtendedGlob
Allow extendedGlob to work with Windows paths
2025-03-26 20:40:00 +00:00
openshift-merge-bot[bot] e4d3dc08b1
Merge pull request #6087 from flouthoc/add-report-err
add: report error while creating dir for URL source.
2025-03-26 18:00:37 +00:00
openshift-merge-bot[bot] 6e77a5cf84
Merge pull request #6085 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.0.3+incompatible
2025-03-26 17:08:15 +00:00
flouthoc 0c377816a9
add: report error while creating dir for URL source.
Correctly report back error when attempting to create `Tmpdir` for a
given url source.

Also remove superfluous `isGitTag` from define/types.go since `git
fetch` correctly resolves by provided reference.

Closes: https://github.com/containers/podman/issues/25679

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-03-26 08:10:59 -07:00
openshift-merge-bot[bot] f15866c9f7
Merge pull request #6088 from nalind/image-mode
createPlatformContainer: drop MS_REMOUNT|MS_BIND
2025-03-26 14:42:06 +00:00
Nalin Dahyabhai c1fcbb2d96 createPlatformContainer: drop MS_REMOUNT|MS_BIND
When attempting to change the mount propagation of the old root
directory tree before unmounting it, it's enough that we pass the
requested propagation flags.

In particular, MS_REC is the only flag that is supposed to be allowed to
be specified along with a mount propagation flag, but in practice it was
only triggering an error some of the time, and CI wasn't one of those
times.

The added test mounts the root filesystem as an overlay and then runs
buildah as a rootless user on top of that, which is more comparable to a
root-on-composefs configuration, which manages to trigger the error.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-03-25 17:47:46 -04:00
openshift-merge-bot[bot] 243d8976d8
Merge pull request #6023 from aeijdenberg/usehistorytimestampinociarchive
feat: use HistoryTimestamp, if set, for oci-archive entries
2025-03-25 15:28:22 +00:00
openshift-merge-bot[bot] a6826938b8
Merge pull request #6082 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.20.2
2025-03-25 14:35:50 +00:00
renovate[bot] 28dec564af
fix(deps): update module github.com/docker/docker to v28.0.3+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-25 14:34:25 +00:00
openshift-merge-bot[bot] 3828ac91b6
Merge pull request #6017 from containers/renovate/github.com-openshift-imagebuilder-digest
fix(deps): update github.com/openshift/imagebuilder digest to e87e4e1
2025-03-25 14:33:10 +00:00
Adam Eijdenberg 42e63dc0b9 fix: bats won't fail on ! without cleverness
Signed-off-by: Adam Eijdenberg <adam@continusec.com>
2025-03-25 10:23:44 +00:00
Adam Eijdenberg 9b41f3c9b5 feat: use HistoryTimestamp, if set, for oci-archive entries
Signed-off-by: Adam Eijdenberg <adam@continusec.com>
2025-03-25 07:14:04 +00:00
David Negstad 74cfd3cfc3 Allow extendedGlob to work with Windows paths
Signed-off-by: David Negstad <David.Negstad@microsoft.com>
2025-03-24 18:15:16 -07:00
openshift-merge-bot[bot] 915769a07b
Merge pull request #5998 from containers/renovate/github.com-docker-docker-28.x
fix(deps): update module github.com/docker/docker to v28.0.2+incompatible
2025-03-24 20:43:19 +00:00
renovate[bot] 42b5630f56
fix(deps): update module github.com/moby/buildkit to v0.20.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 20:42:14 +00:00
renovate[bot] 72562d8145
fix(deps): update github.com/openshift/imagebuilder digest to e87e4e1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 20:41:59 +00:00
openshift-merge-bot[bot] 06b397f4c2
Merge pull request #6081 from containers/renovate/major-ci-vm-image
chore(deps): update dependency containers/automation_images to v20250324
2025-03-24 18:28:34 +00:00
renovate[bot] 1edce9c5e0
fix(deps): update module github.com/docker/docker to v28.0.2+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 17:22:43 +00:00
openshift-merge-bot[bot] bf439b70fb
Merge pull request #6078 from containers/renovate/tags.cncf.io-container-device-interface-1.x
fix(deps): update module tags.cncf.io/container-device-interface to v1.0.1
2025-03-24 17:08:48 +00:00
renovate[bot] 3466f149a5
fix(deps): update module tags.cncf.io/container-device-interface to v1.0.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 15:38:52 +00:00
renovate[bot] d38eceee19
chore(deps): update dependency containers/automation_images to v20250324
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 15:30:45 +00:00
openshift-merge-bot[bot] 6d9381d082
Merge pull request #6079 from Luap99/selinux
vendor: update github.com/opencontainers/selinux to v1.12.0
2025-03-24 15:30:01 +00:00
Paul Holzinger cbf7e361e6
vendor: update github.com/opencontainers/selinux to v1.12.0
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-24 13:36:19 +01:00
Paul Holzinger a1715cc863
replace deprecated selinux/label calls
These functions were removed in github.com/opencontainers/selinux
v1.12.0.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-24 13:32:00 +01:00
openshift-merge-bot[bot] b478b9f6d8
Merge pull request #6076 from Honny1/fix-arm64-1
Fix built-in args on ARM64
2025-03-21 19:08:47 +00:00
openshift-merge-bot[bot] a7ea2aeb2d
Merge pull request #6039 from flouthoc/vendor-common
vendor: bump c/common to `dbeb17e40c80`
2025-03-21 19:06:01 +00:00
flouthoc 2029431a2d
vendor: bump c/common to dbeb17e40c80
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-03-21 10:27:52 -07:00
Jan Rodák 38df169fcb
Use builtin arg defaults from imagebuilder
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-03-21 15:06:10 +01:00
openshift-merge-bot[bot] bc4d7eb70f
Merge pull request #6074 from giuseppe/mask-thermal-paths
Mask thermal paths
2025-03-21 12:32:19 +00:00
Giuseppe Scrivano 2031709a69
linux: accept unmask paths as glob values
That is the same configuration used already by Podman.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-03-21 08:54:32 +01:00
Giuseppe Scrivano 4dcc397ac5
vendor: update containers/common
Closes: https://github.com/containers/buildah/issues/6073

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-03-21 08:50:11 +01:00
openshift-merge-bot[bot] 3e3baeeb2c
Merge pull request #6008 from Honny1/copy-parents
Add --parents option for COPY in Containerfiles
2025-03-20 10:48:59 +00:00
Jan Rodák 7ca9f3464b
Add --parents option for COPY in Dockerfiles
It also includes an implementation of the --parents flag for the buildah copy command.

Fixes: https://issues.redhat.com/browse/RUN-2193
Fixes: https://github.com/containers/buildah/issues/5557

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-03-18 21:58:27 +01:00
openshift-merge-bot[bot] e8d8be71cd
Merge pull request #6070 from containers/renovate/github.com-opencontainers-runc-1.x
fix(deps): update module github.com/opencontainers/runc to v1.2.6
2025-03-18 15:50:21 +00:00
renovate[bot] e2062cb0f3
fix(deps): update module github.com/opencontainers/runc to v1.2.6
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-18 02:20:03 +00:00
openshift-merge-bot[bot] 981bea61b7
Merge pull request #6045 from containers/renovate/tags.cncf.io-container-device-interface-1.x
fix(deps): update module tags.cncf.io/container-device-interface to v1
2025-03-17 15:01:29 +00:00
Nalin Dahyabhai 2adb9e288e update go.sum from the previous commit
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-03-13 15:13:36 -04:00
renovate[bot] 218afc9211
fix(deps): update module tags.cncf.io/container-device-interface to v1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-13 18:48:21 +00:00
openshift-merge-bot[bot] 78d2c1f03e
Merge pull request #6064 from containers/renovate/go-golang.org-x-net-vulnerability
chore(deps): update module golang.org/x/net to v0.36.0 [security]
2025-03-13 18:37:24 +00:00
renovate[bot] ab5c5e519f
chore(deps): update module golang.org/x/net to v0.36.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-13 15:41:10 +00:00
openshift-merge-bot[bot] bfe568d354
Merge pull request #6060 from Luap99/go-1.23
Update to Go 1.23 and bump golang.org/x/crypto v0.36.0
2025-03-13 15:39:51 +00:00
Paul Holzinger 8e9e02c103
packit: remove f40 from copr builds
go 1.22 is to old, once F40 is updated to go 1.23 we can revert this.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-13 14:36:42 +01:00
Paul Holzinger 8670aebc68
cirrus: update to go 1.23 image
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-13 14:32:48 +01:00
Paul Holzinger 12f89d1314
vendor bump to golang.org/x/crypto v0.36.0
This also bumps us to go 1.23 as minimum supported version.

Fixes: CVE-2025-22869
Fixes: https://issues.redhat.com/browse/RHEL-82771
Fixes: https://issues.redhat.com/browse/RHEL-81310

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-13 14:32:48 +01:00
Paul Holzinger 9d1ecbb7f5
cirrus: update PRIOR_FEDORA comment
Oh well, so much to paying attention to buildah CI. Nobody seemed to
have noticed that F40 is not tested, anyway now that we bumpt to go 1.23
we can no longer build on it until go 1.23 is shipped on f40 which might
still take a few weeks.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-13 14:32:48 +01:00
openshift-merge-bot[bot] 1f44a9760c
Merge pull request #6047 from aeijdenberg/altsimpler
fix: dockerfiles... always evaluates to an empty list
2025-03-12 20:06:04 +00:00
openshift-merge-bot[bot] 0850612f5d
Merge pull request #6063 from Luap99/remove-cirrus-rerun
github: remove cirrus rerun action
2025-03-12 19:39:50 +00:00
openshift-merge-bot[bot] 443eace8be
Merge pull request #6062 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.62.2
2025-03-12 19:33:00 +00:00
Paul Holzinger 1192c71b63
github: remove cirrus rerun action
It is broken and we have removed the original in podman, so remove it
here as well as it will no longer work.

Fixes #6035

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-12 18:24:52 +01:00
renovate[bot] 21f8dd3731
fix(deps): update module github.com/containers/common to v0.62.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-12 15:30:38 +00:00
openshift-merge-bot[bot] 45b31a92ee
Merge pull request #5999 from hdub-tech/secret-examples
buildah-build.1.md: secret examples
2025-03-11 17:41:54 +00:00
openshift-merge-bot[bot] dea716529e
Merge pull request #6057 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.34.2
2025-03-11 14:10:30 +00:00
renovate[bot] 225a6fcd2b
fix(deps): update module github.com/containers/image/v5 to v5.34.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-11 02:30:20 +00:00
Adam Eijdenberg 2bc7ac11a2 fix: close files properly when BuildDockerfiles exits
Previous code called defer with argument "dockerfiles..." which is
always empty at time of evaluation.

Even when dockerfiles is appended to later in this method, it has no
entries at time of evaluation as an argument to the defer function, thus
no files were ever closed as a result.

Minor refactor so that all referenced files and HTTP requests are now
closed at end of function.

Signed-off-by: Adam Eijdenberg <adam@continusec.com>
2025-03-10 03:35:18 +00:00
openshift-merge-bot[bot] 8fd8abcf38
Merge pull request #6041 from flouthoc/heredoc-buildarg
stage_executor: history should include heredoc summary correctly
2025-03-07 21:25:22 +00:00
openshift-merge-bot[bot] ac000a6f23
Merge pull request #6042 from containers/renovate/github.com-containers-storage-1.x
fix(deps): update module github.com/containers/storage to v1.57.2
2025-03-07 19:13:22 +00:00
openshift-merge-bot[bot] 81eaf4fc3a
Merge pull request #6014 from mtrmac/enforce-digests
Use UnparsedInstance.Manifest instead of ImageSource.GetManifest
2025-03-07 18:34:53 +00:00
renovate[bot] 1c9cc54aa1
fix(deps): update module github.com/containers/storage to v1.57.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-07 16:28:16 +00:00
openshift-merge-bot[bot] 1922841243
Merge pull request #6021 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.62.1
2025-03-07 16:14:39 +00:00
flouthoc 4dd300b1a7
stage_executor: history should include heredoc summary correctly
getCreatedBy ignores heredoc summary when build args are specified
following PR makes sure the behaviour is correct.

Also test is modified to make sure buildah correctly burst cache if
heredoc content is changed.

Closes: https://github.com/containers/podman/issues/25469

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-03-07 07:56:52 -08:00
renovate[bot] 03c54f8647
fix(deps): update module github.com/containers/common to v0.62.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-06 21:48:30 +00:00
openshift-merge-bot[bot] 7776f50395
Merge pull request #6036 from Luap99/cron-rerun-disable
github: disable cron rerun action
2025-03-06 21:13:46 +00:00
openshift-merge-bot[bot] b2d07d9710
Merge pull request #6016 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to 40bd943
2025-03-06 20:29:54 +00:00
Paul Holzinger df4b04f959
github: disable cron rerun action
Something is very wrong with the rerun script here, it needs more
investigation. For now let's disable it as it doesn't work correctly.

see #6035

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-06 19:43:37 +01:00
openshift-merge-bot[bot] 0bab4329ee
Merge pull request #6032 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.20.1
2025-03-05 18:39:07 +00:00
renovate[bot] c5d6b9e7b9
fix(deps): update module github.com/moby/buildkit to v0.20.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-05 17:20:35 +00:00
openshift-merge-bot[bot] 524a4c63f1
Merge pull request #6031 from nalind/fix-import
internal/mkcw.Archive(): use github.com/containers/storage/pkg/ioutils
2025-03-05 17:19:23 +00:00
Nalin Dahyabhai 264f557dbe internal/mkcw.Archive(): use github.com/containers/storage/pkg/ioutils
Use the AtomicWriteFile() from github.com/containers/storage/pkg/ioutils
instead of the one from github.com/docker/docker/pkg/ioutils.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-03-05 10:54:36 -05:00
openshift-merge-bot[bot] ae1e1d55dc
Merge pull request #5885 from lsm5/tmt-system-tests
[skip-ci] TMT: system tests
2025-03-04 15:54:44 +00:00
Lokesh Mandvekar c54e43a9fb
[skip-ci] TMT: system tests
This commit adds TMT jobs for system tests triggered via Packit for
all active Fedora and CentOS Stream releases on x86_64.

TODO: enable aarch64 tests.

Official Fedora and CentOS Stream spec and gating test configs can be
synced from upstream by Packit, effectively upstreaming almost all
mainteenance.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-03-04 16:22:48 +05:30
H Dub 1547d4f787
buildah-build.1.md: secret examples
Signed-off-by: H Dub <14808878+hdub-tech@users.noreply.github.com>
Helped-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-03-03 21:39:52 -06:00
renovate[bot] a1054580ec
fix(deps): update github.com/containers/luksy digest to 40bd943
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-03 19:16:55 +00:00
openshift-merge-bot[bot] 2517aa202f
Merge pull request #6020 from containers/renovate/github.com-opencontainers-image-spec-1.x
fix(deps): update module github.com/opencontainers/image-spec to v1.1.1
2025-03-03 18:53:02 +00:00
openshift-merge-bot[bot] 23b7736113
Merge pull request #6015 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.34.1
2025-03-03 18:39:16 +00:00
renovate[bot] 68330c1699
fix(deps): update module github.com/opencontainers/image-spec to v1.1.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-03 16:15:17 +00:00
renovate[bot] 1f8f75eefa
fix(deps): update module github.com/containers/image/v5 to v5.34.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-28 22:34:02 +00:00
Miloslav Trmač cc4cca08d4 Use UnparsedInstance.Manifest instead of ImageSource.GetManifest
... to validate that the manifests match expected digests, if any.

In some cases, using an UnparsedInstance can also avoid redundant I/O.

Do this everywhere, even where we read local storage which is
mostly trusted, because it is cheap enough and being consistent
makes it less likely for the code to be copied into other
contexts where the sources are not trusted.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-02-28 20:16:07 +01:00
openshift-merge-bot[bot] c2e6d012d4
Merge pull request #6013 from containers/renovate/github.com-opencontainers-runtime-spec-1.x
fix(deps): update module github.com/opencontainers/runtime-spec to v1.2.1
2025-02-28 18:00:37 +00:00
renovate[bot] e10af36639
fix(deps): update module github.com/opencontainers/runtime-spec to v1.2.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-28 16:26:01 +00:00
openshift-merge-bot[bot] 5a57a86a38
Merge pull request #6012 from nalind/origin-raw
tests/conformance/testdata/Dockerfile.add: update some URLs
2025-02-28 15:36:24 +00:00
Nalin Dahyabhai d5b30b000a tests/conformance/testdata/Dockerfile.add: update some URLs
The origin repository renamed its "master" branch to "main", so we need
to update our references to items in that branch.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-02-27 14:09:15 -05:00
openshift-merge-bot[bot] 4c3081b63e
Merge pull request #5990 from Honny1/fix-arm64
Fix Conformance tests on ARM64
2025-02-27 16:00:04 +00:00
openshift-merge-bot[bot] bb6e3d45de
Merge pull request #6005 from containers/renovate/go-github.com-go-jose-go-jose-v4-vulnerability
chore(deps): update module github.com/go-jose/go-jose/v4 to v4.0.5 [security]
2025-02-25 16:42:17 +00:00
Jan Rodák 177b845bd6
Vendor imagebuilder
New imagebuilder contains fix that sets empty TARGETVARIANT and BUILDVARIANT. Docker does not set these values for ARM64.
This fixes the TestConformance/multistage-builtin-args and TestConformance/builtins tests on ARM64.

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-02-25 17:01:21 +01:00
Jan Rodák 1f142eb581
Fix source of OS, architecture and variant
This fixes getting of cpu variants for ARM64
Fixes the TestConformance/setuid-file-in-archive test on ARM64.

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-02-25 17:01:21 +01:00
renovate[bot] 2b96c386e0
chore(deps): update module github.com/go-jose/go-jose/v4 to v4.0.5 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-25 15:24:34 +00:00
openshift-merge-bot[bot] f61d2ae9d3
Merge pull request #5995 from flouthoc/parallel-conformance
conformance: make `TestCommit` and `TestConformance` parallel
2025-02-25 14:59:53 +00:00
openshift-merge-bot[bot] 9743a49322
Merge pull request #6004 from containers/renovate/tags.cncf.io-container-device-interface-0.x
fix(deps): update module tags.cncf.io/container-device-interface to v0.8.1
2025-02-24 23:23:31 +00:00
renovate[bot] ee83bf608e
fix(deps): update module tags.cncf.io/container-device-interface to v0.8.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 16:41:09 +00:00
openshift-merge-bot[bot] 778213a7c6
Merge pull request #5997 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.20.0
2025-02-20 15:41:36 +00:00
renovate[bot] 7ed99c6ae7
fix(deps): update module github.com/moby/buildkit to v0.20.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-19 22:59:11 +00:00
openshift-merge-bot[bot] 5b8423e1bc
Merge pull request #5992 from nalind/remount-pivot
chroot createPlatformContainer: use MS_REMOUNT
2025-02-19 19:09:36 +00:00
Nalin Dahyabhai 699c84d40b chroot createPlatformContainer: use MS_REMOUNT
When setting mount propagation on the root mount before unmounting it,
use MS_REBIND, since we know it's already a bind mount, and we actually
want to affect the extant bind mount instead of creating another right
over it. Otherwise, we might as well have not bothered.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-02-19 13:29:20 -05:00
openshift-merge-bot[bot] 318f35e75c
Merge pull request #5994 from Luap99/cirrus-timeout
cirrus: reduce task timeout
2025-02-19 18:00:53 +00:00
flouthoc fca3ca46bf
conformance: make TestCommit and TestConformance parallel
Two tests `TestCommit` and `TestConformance` can be made parallel given
that we are already using multiple cores for conformance tests.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-19 08:36:40 -08:00
openshift-merge-bot[bot] 5868f44b52
Merge pull request #5943 from nalind/container_name_as_hostname
Support the containers.conf container_name_as_hostname option
2025-02-19 14:07:03 +00:00
openshift-merge-bot[bot] 3d14858281
Merge pull request #5959 from flouthoc/integrate-experiment
Use tmpfs for integration tests
2025-02-19 14:04:18 +00:00
Paul Holzinger 36467356d6
cirrus: reduce task timeout
With all the recent speed-ups here the timeout is way to high, all tasks
should complete in under 30 mins generally. The smoke test in under
10min as it does not do much.

In particular I noticed at least two separate rootless integration tests
time out after 120min[1,2], obviously the tests do not take that long and
they are hanging somehwere instead. With a lower timeout we do not waste
so much time when this happens.

[1] https://cirrus-ci.com/task/4733420225429504
[2] https://cirrus-ci.com/task/5597909967699968

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-02-19 14:06:19 +01:00
flouthoc c87fd8e191
mkcw: mkcw_check_image use bats run_with_log
Add `run_with_log` to mkcw tests.

Add `sleep 1` during cleanup between attempting `luksClose`
and unmounting the filesystem mounted on the device /dev/mapper/"$uuid".
Without this somehow we end up in a state where mount is still being
used by the kernel because when we do `lsof /dev/mapper/"$uuid"` it
shows nothing but `dmsetup info -c $uuid` shows the device is still
under use. Adding `sleep 1` in between somehow fixes this.

Also this problem with `cryptsetup` is pretty common for reference
one thread which I found https://lore.kernel.org/all/508950BA.1030309@dennis.birkholz.biz/T/

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-18 14:50:04 -08:00
flouthoc d7d7878622
test: use /tmp as TMPDIR
use /tmp as TMPDIR so tests use tmpfs

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-18 14:50:01 -08:00
flouthoc efb28dcf7b
heredoc: create temp subdirs for each build
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-18 14:49:57 -08:00
flouthoc c86f554a18
test: heredoc remove python dependency from test
Use regular `cat` to test the same functionality instead
of using python image specifically for this part of test.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-18 14:49:52 -08:00
Nalin Dahyabhai 72e2bf4c69 Support the containers.conf container_name_as_hostname option
When containers.conf has the "container_name_as_hostname" option set,
use that value, with values that don't fit `[A-Za-z0-9][A-Za-z0-9.-]+`
stripped out.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-02-18 17:43:07 -05:00
openshift-merge-bot[bot] 5dc3c23a3e
Merge pull request #5989 from containers/renovate/github.com-opencontainers-runc-1.x
fix(deps): update module github.com/opencontainers/runc to v1.2.5
2025-02-18 22:37:03 +00:00
renovate[bot] a45e659216
fix(deps): update module github.com/opencontainers/runc to v1.2.5
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-18 21:23:49 +00:00
Tom Sweeney 7fea494a9c
Merge pull request #5991 from containers/renovate/github.com-spf13-cobra-1.x
fix(deps): update module github.com/spf13/cobra to v1.9.0
2025-02-17 16:54:47 -05:00
renovate[bot] 6e5f6d8fd2
fix(deps): update module github.com/spf13/cobra to v1.9.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-15 19:06:27 +00:00
openshift-merge-bot[bot] 6cc75b8e0f
Merge pull request #5986 from flouthoc/bump-smoke-cores
.cirrus: use more cores for smoke task
2025-02-11 21:13:02 +00:00
flouthoc b5e7a84d2e
.cirrus: use more cores for smoke
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-11 10:42:24 -08:00
openshift-merge-bot[bot] d5a4770e8b
Merge pull request #5982 from mheon/cncf_code_of_conduct
Switch to the CNCF Code of Conduct
2025-02-11 16:02:37 +00:00
openshift-merge-bot[bot] 57b0afcfb3
Merge pull request #5981 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.33.0
2025-02-11 15:29:22 +00:00
Matt Heon bd62d5afc7 Switch to the CNCF Code of Conduct
As part of the CNCF Sandbox, we are replacing our existing COC
with the standard CNCF version.

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-02-10 14:40:48 -05:00
openshift-merge-bot[bot] f89450213c
Merge pull request #5978 from nalind/cache-ownership
Distinguish --mount=type=cache locations by ownership, too
2025-02-10 19:31:25 +00:00
openshift-merge-bot[bot] a35f5fa04d
Merge pull request #5979 from flouthoc/bump-ci-resources
.cirrus: bump ci resources
2025-02-10 18:58:23 +00:00
flouthoc 03cd7821c9
.cirrus: bump ci resources
Timeplot of various tests after the resource bump

>> 28:49
| type        | user     | fs      |      d13 |      f40 |      f41 |
| ----------- | -------- | ------- | -------- | -------- | -------- |
| Unit        | root     | vfs     |          |    08:22 |          |
| Unit        | root     | overlay |          |    08:18 |          |
| Conformance | root     | vfs     |    20:52 |          |          |
| Conformance | root     | overlay |    11:55 |          |          |
| Integration | root     | vfs     |    19:15 |    17:36 |    17:18 |
| Integration | root     | overlay |    15:14 |          |    20:52 |
| Integration | rootless | overlay |    17:27 |          |    17:06 |

Timeplot of various tests before the test bump from PR #5978

>> 01:03:34
| type        | user     | fs      |      d13 |      f40 |      f41 |
| ----------- | -------- | ------- | -------- | -------- | -------- |
| Unit        | root     | vfs     |          |    08:31 |          |
| Unit        | root     | overlay |          |    08:15 |          |
| Conformance | root     | vfs     |    24:30 |          |          |
| Conformance | root     | overlay |    14:27 |          |          |
| Integration | root     | vfs     |    25:40 |    28:08 |    26:19 |
| Integration | root     | overlay |    23:15 |          |    24:10 |
| Integration | rootless | overlay |    27:01 |          |    28:46 |

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-10 06:54:41 -08:00
renovate[bot] ecd200a89c
fix(deps): update module golang.org/x/crypto to v0.33.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-08 01:49:41 +00:00
Nalin Dahyabhai 24826435f8 Distinguish --mount=type=cache locations by ownership, too
Normally, we select and distinguish --mount=type=cache directories that
we create by either the "id" or "target" value used when mounting them,
but we should also be distinguishing them by the "uid" and "gid" flags,
or lack thereof.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-02-07 13:38:56 -05:00
openshift-merge-bot[bot] a3701cb97d
Merge pull request #5972 from containers/renovate/golang.org-x-term-0.x
fix(deps): update module golang.org/x/term to v0.29.0
2025-02-06 14:53:30 +00:00
renovate[bot] 4b234a19c1
fix(deps): update module golang.org/x/term to v0.29.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-06 00:03:05 +00:00
openshift-merge-bot[bot] d5ed8b4788
Merge pull request #5954 from flouthoc/parallel-unit-test
CI: parallize unit tests
2025-02-05 21:28:43 +00:00
flouthoc 147a3ca916
.cirrus: run -race only on non-PR branch
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-05 06:57:14 -08:00
flouthoc de3c3baf09
unit: deparallize some tests
See issue: https://github.com/containers/buildah/issues/5967

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:43 -08:00
flouthoc 81479b200c
.cirrus: use multiple cpu for unit tests
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:36 -08:00
flouthoc 1879f3dc65
Makefile: use -parallel for go test
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:27 -08:00
flouthoc aadfc5cf30
unit_test: use Parallel test where possible
Add `t.Parallel()` to unit tests whereever its possible without race.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:15 -08:00
openshift-merge-bot[bot] ae5e123314
Merge pull request #5970 from containers/renovate/golang.org-x-sys-0.x
Update module golang.org/x/sys to v0.30.0
2025-02-04 17:53:15 +00:00
renovate[bot] 3f9bc73d59
Update module golang.org/x/sys to v0.30.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-04 16:08:05 +00:00
openshift-merge-bot[bot] 30bf35f3f1
Merge pull request #5969 from containers/renovate/golang.org-x-sync-0.x
Update module golang.org/x/sync to v0.11.0
2025-02-04 16:05:52 +00:00
renovate[bot] 04febc5813
Update module golang.org/x/sync to v0.11.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-04 14:39:20 +00:00
openshift-merge-bot[bot] 324df7da73
Merge pull request #5966 from containers/renovate/major-ci-vm-image
Update dependency containers/automation_images to v20250131
2025-02-03 21:24:54 +00:00
renovate[bot] a13fa87ea2
Update dependency containers/automation_images to v20250131
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-03 17:03:29 +00:00
openshift-merge-bot[bot] 53872d88fa
Merge pull request #5962 from TomSweeneyRedHat/dev/tsweeney/1.39.0
Bump Buildah to v1.39.0, c/storage v1.57.1, c/image v5.34.0, c/common v0.62.0
2025-02-03 15:54:59 +00:00
tomsweeneyredhat 6c3d7546e3 Bump to Buildah v1.40.0-dev
Bumping back to a dev version.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-01-31 18:19:08 -05:00
tomsweeneyredhat c15ab104a1 Bump to Buildah v1.39.0
Bump to Buildah v1.39.0 in preparation
for Podman v5.4

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-01-31 18:15:22 -05:00
tomsweeneyredhat 298a64106e Bump c/storage v1.57.1, c/image 5.34.0, c/common v0.62.0
Bump:
c/storage to v1.57.1
c/image   to v5.34.0
c/common  to v0.62.0

in preparation for Podman v5.4

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-01-31 18:06:51 -05:00
openshift-merge-bot[bot] 2fe355bb15
Merge pull request #5957 from containers/renovate/github.com-containers-storage-1.x
Update module github.com/containers/storage to v1.57.0
2025-01-30 19:50:07 +00:00
renovate[bot] 3c7c611c7a
Update module github.com/containers/storage to v1.57.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-30 17:11:15 +00:00
openshift-merge-bot[bot] 607ca3065c
Merge pull request #5947 from flouthoc/containerized_integration_parallel
CI, .cirrus: parallelize containerized integration
2025-01-29 12:22:08 +00:00
flouthoc d11bd71f43
CI, .cirrus: parallelize containerized integration
[NO NEW TESTS NEEDED]

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-27 12:43:20 -08:00
openshift-merge-bot[bot] 042414a056
Merge pull request #5552 from edsantiago/bats-parallel
bats tests - parallelize
2025-01-27 20:38:36 +00:00
flouthoc bd2d78e408
ed's comment: cleanup
Address comment here for cleanup https://github.com/containers/buildah/pull/5552#discussion_r1854283414

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-25 11:25:09 -08:00
flouthoc ea39556a6f
use seperate blobinfocache for flaky test
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-25 08:14:27 -08:00
Ed Santiago 72161b3a14
bump CI VMs to 4 CPUs (was: 2) for integration tests
Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-25 08:09:16 -08:00
Ed Santiago 56078ef2d6
cleanup, debug, and disable parallel in blobcache tests
Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-25 08:09:11 -08:00
Ed Santiago 708fe0aff5
bats tests - parallelize
All bats tests run with custom root/runroot, so it should be
possible to parallelize them.

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-25 08:09:05 -08:00
openshift-merge-bot[bot] 92015b7f43
Merge pull request #5927 from nalind/overlay-cleanups
pkg/overlay: cleanups
2025-01-25 11:41:11 +00:00
openshift-merge-bot[bot] e08082fa22
Merge pull request #5691 from flouthoc/burst-cache-mount
build, run: record hash or digest in image history for sources used in `--mount`
2025-01-25 11:35:40 +00:00
Nalin Dahyabhai 670a7bec6e pkg/overlay: cleanups
Change generateOverlayStructure() to not return its first argument
unchanged, since both of its callers already have that value, and adjust
a few error messages.

In the Linux MountWithOptions(), ensure that, if UpperDirOptionFragment
and WorkDirOptionFragment values were specified, they are absolute
paths, otherwise place them under the top-level parent of the various
directories we have for this mount.

Update a number of comments.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-24 15:54:08 -05:00
openshift-merge-bot[bot] 21fe6dcf1f
Merge pull request #5929 from Luap99/vendor
vendor to latest c/{common,image,storage}
2025-01-24 18:35:31 +00:00
openshift-merge-bot[bot] 865427c61e
Merge pull request #5938 from lsm5/rpm-gobuild-macro
[skip-ci] RPM: use default gobuild macro on RHEL
2025-01-24 15:50:29 +00:00
Lokesh Mandvekar ca957c4878
RPM: include check section to silence rpmlint
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-01-24 17:02:05 +05:30
Lokesh Mandvekar 6cee07f52e
RPM: use default gobuild macro on RHEL
The default gobuild macro on RHEL now includes support for BUILDTAGS. So
we don't need to redefine it here.

`libtrust_openssl` buildtag will be set in the spec file for RHEL environments.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2025-01-24 16:43:03 +05:30
Paul Holzinger 2119c8da3c
tests: remove masked /sys/dev/block check
The c/common defaults were changed to no longer mask this path[1]. As
such we need to remove it from this test.

[1] https://github.com/containers/common/pull/2278

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-01-24 11:45:28 +01:00
Paul Holzinger 4887a4fb1b
vendor to latest c/{common,image,storage}
Make sure all the test pass before we do a final vendor dance.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-01-24 11:45:26 +01:00
flouthoc 4383e34c0f
build, run: record hash or digest in image history
When using `--mount=type=bind` or `--mount=type=cache` the hash or
digest of source in these flags should be added to image history so
buildah can burst cache if files on host or image which is being used as
source is changed.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-01-23 15:44:07 -08:00
openshift-merge-bot[bot] a7fe4793a8
Merge pull request #5934 from nalind/cache-mount-images
Accept image names as sources for cache mounts
2025-01-23 22:28:05 +00:00
Nalin Dahyabhai 3541a3ce2a Accept image names as sources for cache mounts
Allow the "from" option for cache mounts to refer to an image, which, if
we attempt to mount read-write, is mounted using an overlay to avoid
getting errors if the process we're running with the cache mount
attempts to write to it.

Add logic to clean up the bind mount in Builder.getBindMount() that's
triggered if Builder.runSetupVolumeMounts() returns an error.

When creating cache directories for cache mounts, process the
container's ID mappings.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-23 13:38:02 -05:00
openshift-merge-bot[bot] ea50c7be71
Merge pull request #5924 from nalind/run-cleanup
Run(): always clean up options.ExternalImageMounts
2025-01-23 18:12:05 +00:00
openshift-merge-bot[bot] 0c4864e676
Merge pull request #5937 from Juneezee/refactor/exp
refactor: replace `golang.org/x/exp` with stdlib
2025-01-23 17:44:36 +00:00
Nalin Dahyabhai 9e00b6b399 Run(): always clean up options.ExternalImageMounts
Make sure that we consistently unmount the list of images that we're
told to, even in cases where we return an error before arranging to do
so in Run().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-23 11:29:28 -05:00
Eng Zer Jun 59024c41ad
refactor: replace golang.org/x/exp with stdlib
These experimental packages are now available in the Go standard
library since Go 1.21:

	1. golang.org/x/exp/slices -> slices [1]
	2. golang.org/x/exp/maps -> maps [2]

[1]: https://go.dev/doc/go1.21#slices
[2]: https://go.dev/doc/go1.21#maps

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2025-01-24 00:27:55 +08:00
openshift-merge-bot[bot] b48b0fce4c
Merge pull request #5932 from mtrmac/c-image-tests
Update c/image and update tests
2025-01-23 16:18:33 +00:00
openshift-merge-bot[bot] 17edf29c1f
Merge pull request #5935 from nalind/specs
run_freebsd.go: only import runtime-spec once
2025-01-23 15:45:35 +00:00
openshift-merge-bot[bot] 72df882dae
Merge pull request #5936 from cheesesashimi/zzlotnik/fix-broken-link
fix broken doc link
2025-01-22 23:10:01 +00:00
Miloslav Trmač a67b079577 Update to c/image @main
To do this, update expected errors when pulling encrypted images

https://github.com/containers/image/issues/2646 will track actually
returning a meaningful error instead of these internal details.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-01-22 23:33:05 +01:00
Zack Zlotnik d694644ae5
fix broken doc link
Signed-off-by: Zack Zlotnik <zzlotnik@redhat.com>
2025-01-22 16:55:43 -05:00
Nalin Dahyabhai e40f629415 run_freebsd.go: only import runtime-spec once
The github.com/opencontainers/runtime-spec/specs-go module was being
imported twice, once with a non-default package name, and once with its
default name, which is more than we needed.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-22 16:31:05 -05:00
openshift-merge-bot[bot] a886140bca
Merge pull request #5933 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.5.1+incompatible
2025-01-22 21:27:20 +00:00
renovate[bot] eca1c8e901
fix(deps): update module github.com/docker/docker to v27.5.1+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-22 18:05:10 +00:00
openshift-merge-bot[bot] faaa804b46
Merge pull request #5930 from nalind/update-tar-split
bump github.com/vbatts/tar-split
2025-01-21 18:49:35 +00:00
openshift-merge-bot[bot] b0fff6dc9f
Merge pull request #5926 from nalind/chroot-test
chroot mount flags integration test: copy binaries
2025-01-21 18:46:49 +00:00
Nalin Dahyabhai 678dca8fd0 bump github.com/vbatts/tar-split
Update github.com/vbatts/tar-split to pull in a fix for CVE-2022-2879.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-21 11:10:27 -05:00
openshift-merge-bot[bot] eac9331dff
Merge pull request #5925 from nalind/mount-flags-parsing
Add more checks to the --mount flag parsing logic
2025-01-21 16:04:20 +00:00
Nalin Dahyabhai 9b9c161ff5 Add more checks to the --mount flag parsing logic
* Make volumes.GetBindMount(), volumes.GetCacheMount(), and
  volumes.GetTmpfsMount() return errors when flags which expect
  arguments are given empty arguments, when flags which don't expect
  arguments are given arguments, and when the "relabel" flag, which
  expects an argument, doesn't get one.
* Make volumes.GetCacheMount() not treat the "U" flag as affecting bind
  propagation.
* Drop the special-case error message when a caller attempts to use
  "src" or "source" options in volumes.GetTmpfsMount(), which would
  already be covered by the general-purpose "unrecognized option"
  default.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-20 17:51:11 -05:00
Nalin Dahyabhai 1ccc34515e chroot mount flags integration test: copy binaries
Copy the binaries that we call from inside of a UID-mapped `unshare` to
a location where the permissions on the parent directories that contain
them are less likely to render them inaccessible, and use the copies.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-20 17:40:39 -05:00
openshift-merge-bot[bot] 833420ea0b
Merge pull request #5923 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.19.0
2025-01-20 21:19:46 +00:00
renovate[bot] 80100ac447
fix(deps): update module github.com/moby/buildkit to v0.19.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-20 20:06:32 +00:00
openshift-merge-bot[bot] b08311f3ce
Merge pull request #5922 from nalind/misleading-parameter-name
relabel(): correct a misleading parameter name
2025-01-20 20:05:12 +00:00
Nalin Dahyabhai e7f790296e relabel(): correct a misleading parameter name
The "recurse" parameter of the relabel() function signature is passed to
a function which calls it "shared".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-20 13:24:35 -05:00
Nalin Dahyabhai 1e4af433f7
Merge commit from fork
Fix TOCTOU error when bind and cache mounts use "src" values
2025-01-20 13:00:23 -05:00
Nalin Dahyabhai 6e62bd0835 Fix TOCTOU error when bind and cache mounts use "src" values
Fix a time-of-check/time-of-use error when mounting type=bind and
type=cache directories that use a "src" flag.  A hostile writer could
use a concurrently-running stage or build to replace that "src" location
between the point when we had resolved possible symbolic links and when
runc/crun/whatever actually went to create the bind mount
(CVE-2024-11218).

Stop ignoring the "src" option for cache mounts when there's no "from"
option.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
Nalin Dahyabhai c30f5784da define.TempDirForURL(): always use an intermediate subdirectory
Ensure that the temporary directory that we create is never itself the
top-level directory of the content that we're downloading, in case it's
an archive which includes a "." with weird permissions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
Nalin Dahyabhai 25a3b385af internal/volume.GetBindMount(): discard writes in bind mounts
When handling RUN --mount=type=bind, where the mount is read-write,
instead of a simple bind mount, create an overlay mount with an upper
directory that will be discarded after the overlay mount is unmounted.
This brings us in line with the expected behavior, wherein writes to
bind mounts should be discarded.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
Nalin Dahyabhai 0f5c6fc504 pkg/overlay: add a MountLabel flag to Options
Add a way to pass a "set the SELinux contexts" labels to
MountWithOptions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
Nalin Dahyabhai c0efbe8210 pkg/overlay: add a ForceMount flag to Options
Add a ForceMount flag to pkg/overlay.Options that forces mounting the
overlay filesystem and returning a bind mount to it instead of trying to
leave that for later in cases where we're able to have the kernel do it.

This is mainly for the sake of callers that want to do more things with
the mounted overlay filesystem before passing them to the (presumably)
OCI runtime.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
Nalin Dahyabhai 50210d51c9 Add internal/volumes.bindFromChroot()
Add a helper that uses the new internal/open package to bind mount a
location inside of a chroot direct to a new temporary location, for
ensuring that the latter is not bind-mounted from outside of the chroot.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
Nalin Dahyabhai f7155c0abd Add an internal/open package
Add a package that lets us open a directory in a chroot, pass its
descriptor up, and then bind mount that directory to a specified
location.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-17 09:59:55 -05:00
openshift-merge-bot[bot] cda428282f
Merge pull request #5912 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.61.1
2025-01-16 23:17:42 +00:00
renovate[bot] 9a9fa9607a
fix(deps): update module github.com/containers/common to v0.61.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-16 22:00:14 +00:00
openshift-merge-bot[bot] 4fcaadbffc
Merge pull request #5909 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.33.1
2025-01-16 17:58:54 +00:00
renovate[bot] ccfd61bdde
fix(deps): update module github.com/containers/image/v5 to v5.33.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-15 22:24:42 +00:00
Daniel J Walsh 989e6a59e9
Merge pull request #5907 from TomSweeneyRedHat/dev/tsweeney/changemain1
[CI:DOCS] Touch up changelogs
2025-01-15 17:23:29 -05:00
tomsweeneyredhat 9beaf1018a [CI:DOCS] Touch up changelogs
The changelog.txt and CHANGELOG.md files each had "vv1.37" instead of
"v1.37".  This corrects that.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-01-15 16:54:23 -05:00
openshift-merge-bot[bot] 608cf9fb73
Merge pull request #5904 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.5.0+incompatible
2025-01-14 21:59:56 +00:00
renovate[bot] 9b55ec998f
fix(deps): update module github.com/docker/docker to v27.5.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-13 22:05:08 +00:00
openshift-merge-bot[bot] 826d9036cf
Merge pull request #5883 from rhatdan/security
Add support for --security-opt mask and unmask
2025-01-09 19:57:20 +00:00
openshift-merge-bot[bot] 85bcd7e968
Merge pull request #5901 from nalind/copy-preserving-extended-attributes-test
copy-preserving-extended-attributes: use a different base image
2025-01-08 11:55:44 +00:00
Nalin Dahyabhai 65b634b7de copy-preserving-extended-attributes: use a different base image
The Fedora 39-based image this test is using is having trouble finding
mirrors from CI.  Use a different one that can still provide the setcap
and setfattr commands.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-07 15:44:10 -05:00
openshift-merge-bot[bot] 471de48c63
Merge pull request #5890 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to a3a812d
2025-01-07 20:43:37 +00:00
openshift-merge-bot[bot] 676e588044
Merge pull request #5888 from lsm5/rpm-changelog-cleanup
[skip-ci] RPM: cleanup changelog conditionals
2025-01-07 20:07:53 +00:00
renovate[bot] 292ecfe0fb
fix(deps): update github.com/containers/luksy digest to a3a812d
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-07 19:18:45 +00:00
openshift-merge-bot[bot] 73e5522eb6
Merge pull request #5887 from containers/renovate/go-golang.org-x-net-vulnerability
chore(deps): update module golang.org/x/net to v0.33.0 [security]
2025-01-07 19:15:36 +00:00
openshift-merge-bot[bot] 9191c9ff7e
Merge pull request #5896 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.32.0
2025-01-07 18:26:19 +00:00
openshift-merge-bot[bot] 7662aec0b4
Merge pull request #5900 from Luap99/new-images
New VM Images
2025-01-07 17:03:39 +00:00
renovate[bot] 67991e0d54
chore(deps): update module golang.org/x/net to v0.33.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-07 16:14:41 +00:00
openshift-merge-bot[bot] c32529f8c5
Merge pull request #5898 from containers/renovate/github.com-opencontainers-runc-1.x
fix(deps): update module github.com/opencontainers/runc to v1.2.4
2025-01-07 16:14:09 +00:00
renovate[bot] 6b53330c3f
fix(deps): update module golang.org/x/crypto to v0.32.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-07 16:13:39 +00:00
openshift-merge-bot[bot] 04cf61ed1b
Merge pull request #5882 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.4.1+incompatible
2025-01-07 16:11:24 +00:00
openshift-merge-bot[bot] c778b89b87
Merge pull request #5878 from containers/renovate/github.com-containers-ocicrypt-1.x
fix(deps): update module github.com/containers/ocicrypt to v1.2.1
2025-01-07 16:08:39 +00:00
Paul Holzinger 727f00bf4a
New VM Images
https://github.com/containers/automation_images/pull/398

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-01-07 16:41:00 +01:00
renovate[bot] e2b33d252f
fix(deps): update module github.com/opencontainers/runc to v1.2.4
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-07 14:41:17 +00:00
renovate[bot] ac98159920
fix(deps): update module github.com/docker/docker to v27.4.1+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-07 14:40:20 +00:00
renovate[bot] 5a336bf1a8
fix(deps): update module github.com/containers/ocicrypt to v1.2.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-07 14:40:05 +00:00
Daniel J Walsh adf54cde0e
Add support for --security-opt mask and unmask
Fixes: https://github.com/containers/buildah/issues/5881

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2025-01-07 08:46:48 -05:00
openshift-merge-bot[bot] 996c49d8ec
Merge pull request #5897 from nalind/cache-additional-build-context
Allow cache mounts to be stages and additional build contexts
2025-01-07 13:09:50 +00:00
Nalin Dahyabhai 77e3570202 Allow cache mounts to be stages or additional build contexts
Allow cache mounts (RUN --mount=type=cache) to refer to other stages or
additional build contexts.

Update the build-check-cve-2024-9675 integration test to use different
directories for its main build context and the additional build context
that it uses for its final run.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-01-06 15:45:50 -05:00
Lokesh Mandvekar a1dede87eb
[skip-ci] RPM: cleanup changelog conditionals
rpmautospec is now supported on all active Fedora and CentOS Stream
envs. So we don't need these conditionals anymore.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2024-12-24 15:17:29 +05:30
openshift-merge-bot[bot] 247c786943
Merge pull request #5880 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.6
2024-12-17 18:26:33 +00:00
openshift-merge-bot[bot] 975c1b14c2
Merge pull request #5693 from flouthoc/use-cache-with-build-context
stage_executor: set `avoidLookingCache` only if mounting stage and not additional build context
2024-12-17 18:23:47 +00:00
openshift-merge-bot[bot] 3cdc8b3bde
Merge pull request #5879 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.18.2
2024-12-17 18:21:02 +00:00
renovate[bot] d183444166
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.6
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-17 11:31:24 +00:00
renovate[bot] d77314a7a0
fix(deps): update module github.com/moby/buildkit to v0.18.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-17 01:37:55 +00:00
openshift-merge-bot[bot] 4018418495
Merge pull request #5876 from nalind/chroot-pivot_root-text
Fix an error message in the chroot unit test
2024-12-16 13:46:04 +00:00
Nalin Dahyabhai 62709d718e Fix an error message in the chroot unit test
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-13 15:16:16 -05:00
openshift-merge-bot[bot] cf7d80a72a
Merge pull request #5874 from nalind/chroot-pivot-root
chroot: on Linux, try to pivot_root before falling back to chroot
2024-12-13 19:47:34 +00:00
openshift-merge-bot[bot] 81015fa555
Merge pull request #5854 from nalind/manifest-add-artifact-annotation
manifest add: add --artifact-annotation
2024-12-13 18:57:59 +00:00
openshift-merge-bot[bot] c7f9925ba7
Merge pull request #5873 from nalind/minor-error-context
Add context to an error message
2024-12-13 18:55:15 +00:00
openshift-merge-bot[bot] ac62622c00
Merge pull request #5875 from nalind/paxrecords
copier: use .PAXRecords instead of .Xattrs
2024-12-13 18:52:31 +00:00
Nalin Dahyabhai cfd98d782a copier: use .PAXRecords instead of .Xattrs
When processing tar headers, use the .PAXRecords field instead of the
deprecated .Xattrs field.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-12 14:54:30 -05:00
Nalin Dahyabhai 4adca286fe chroot: on Linux, try to pivot_root before falling back to chroot
Unless --no-pivot or the equivalent API flag is set, try to pivot_root()
to enter the rootfs during Run().  Fall back to using chroot() as before
if that fails for any reason.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-12 14:33:12 -05:00
Nalin Dahyabhai 5f3975333c manifest add: add --artifact-annotation
Add a --artifact-annotation flag to `buildah manifest add` that can be
used to set annotations in the artifact manifest that we generate and
then add to an image index.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-12 14:09:32 -05:00
Nalin Dahyabhai c41f021306 Add context to an error message
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-12 14:03:53 -05:00
openshift-merge-bot[bot] 79bb8ab310
Merge pull request #5872 from containers/renovate/golang.org-x-crypto-0.x
Update module golang.org/x/crypto to v0.31.0
2024-12-11 21:51:40 +00:00
openshift-merge-bot[bot] 2c918c6acb
Merge pull request #5871 from containers/renovate/github.com-opencontainers-runc-1.x
Update module github.com/opencontainers/runc to v1.2.3
2024-12-11 21:49:13 +00:00
renovate[bot] f81b26560e
Update module golang.org/x/crypto to v0.31.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-11 19:08:14 +00:00
renovate[bot] e9932b7bbb
Update module github.com/opencontainers/runc to v1.2.3
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-11 03:35:52 +00:00
openshift-merge-bot[bot] d2830a0336
Merge pull request #5870 from containers/renovate/github.com-docker-docker-27.x
Update module github.com/docker/docker to v27.4.0+incompatible
2024-12-09 19:53:26 +00:00
renovate[bot] ad5b02cdce
Update module github.com/docker/docker to v27.4.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-09 17:38:40 +00:00
openshift-merge-bot[bot] 493c4b10fa
Merge pull request #5865 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
Update module github.com/cyphar/filepath-securejoin to v0.3.5
2024-12-06 18:04:36 +00:00
renovate[bot] 2b7e1e9be4
Update module github.com/cyphar/filepath-securejoin to v0.3.5
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-06 16:25:13 +00:00
openshift-merge-bot[bot] a0fa244df6
Merge pull request #5863 from containers/renovate/github.com-docker-docker-27.x
Update module github.com/docker/docker to v27.4.0-rc.4+incompatible
2024-12-06 15:00:25 +00:00
openshift-merge-bot[bot] a3a7ece54d
Merge pull request #5856 from nalind/ci-deps
CI: remove some inter-job dependencies, run cross-compile task with make -j, use /tmp for Go build cache
2024-12-06 14:30:10 +00:00
Nalin Dahyabhai a82826f56f CI: don't build a binary in the unit tests task
The unit tests don't use the binary, so we shouldn't be spending time
compiling it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-05 14:40:01 -05:00
Nalin Dahyabhai 8eb6b10b03 CI: use /tmp for $GOCACHE
Point the compiler's build cache at /tmp.  This generally requires more
memory, but it's faster, and the build cache would be discarded anyway.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-05 14:40:01 -05:00
Nalin Dahyabhai 36f6038d30 CI: remove dependencies on the cross-build task
Remove the bits of the CI configuration that prevent some jobs from
starting unless/until the cross-compile tests have passed.  That costs
more time than we're willing to wait, at this time at least.  Use the
skip directive to avoid having to get all of the dependencies and
only_if directives to agree.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-05 14:39:59 -05:00
Nalin Dahyabhai 83b280599b CI: run cross-compile task with make -j
Tell make to run all of the cross-compile tasks at once. This uses a lot
of space in /tmp, and a later patch will also use it for the build
cache, so we request more memory for the task.  Also request more CPUs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-05 10:52:59 -05:00
renovate[bot] 2b6cf64520
Update module github.com/docker/docker to v27.4.0-rc.4+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-05 15:37:23 +00:00
openshift-merge-bot[bot] 0e2fd7305b
Merge pull request #5859 from containers/renovate/golang.org-x-crypto-0.x
Update module golang.org/x/crypto to v0.30.0
2024-12-05 15:12:40 +00:00
openshift-merge-bot[bot] 42ef924ed4
Merge pull request #5848 from containers/renovate/github.com-moby-buildkit-0.x
Update module github.com/moby/buildkit to v0.18.1
2024-12-05 14:47:55 +00:00
renovate[bot] 4afa31d077
Update module github.com/moby/buildkit to v0.18.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-04 22:19:02 +00:00
renovate[bot] c35374f9c7
Update module golang.org/x/crypto to v0.30.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-04 21:55:32 +00:00
openshift-merge-bot[bot] 13bb88d06f
Merge pull request #5853 from containers/renovate/golang.org-x-exp-digest
Update golang.org/x/exp digest to 2d47ceb
2024-12-04 21:53:23 +00:00
openshift-merge-bot[bot] 6f0af0192f
Merge pull request #5849 from lsm5/packit-f39-eol-no-rhel
[skip-ci] Packit: f39 and rhel cleanups
2024-12-04 21:50:41 +00:00
openshift-merge-bot[bot] 6522b0dc8d
Merge pull request #5852 from containers/renovate/github.com-opencontainers-runtime-tools-digest
Update github.com/opencontainers/runtime-tools digest to f7e3563
2024-12-04 21:47:56 +00:00
openshift-merge-bot[bot] 0287fdc0a7
Merge pull request #5846 from containers/renovate/github.com-stretchr-testify-1.x
Update module github.com/stretchr/testify to v1.10.0
2024-12-04 21:45:08 +00:00
renovate[bot] 041c1f26ff
Update golang.org/x/exp digest to 2d47ceb
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-01 06:48:55 +00:00
renovate[bot] 058a2d37f1
Update github.com/opencontainers/runtime-tools digest to f7e3563
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-01 03:14:07 +00:00
Lokesh Mandvekar a34792457e
[skip-ci] Packit: remove rhel copr build jobs
RHEL targets are frequently out of date when it comes to golang and
other important dependencies, causing frequent build failures. Best to
not test for them on upstream main branch. CentOS jobs ensure that
everything that lands eventually into RHEL has been tested.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2024-11-28 15:06:33 +05:30
Lokesh Mandvekar 7a8312a617
[skip-ci] Packit: switch to fedora-all for copr
F39 is EOL.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2024-11-28 15:01:49 +05:30
renovate[bot] 564f90f09c
Update module github.com/stretchr/testify to v1.10.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-23 13:50:41 +00:00
Tom Sweeney da08204ab0
Merge pull request #5844 from containers/renovate/github.com-moby-buildkit-0.x
Update module github.com/moby/buildkit to v0.17.2
2024-11-22 17:44:03 -05:00
renovate[bot] 7b45052fd6
Update module github.com/moby/buildkit to v0.17.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-22 10:56:15 +00:00
openshift-merge-bot[bot] 998312277d
Merge pull request #5841 from edsantiago/parallel-safe-prefetch
Tests: make _prefetch() parallel-safe
2024-11-22 02:53:41 +00:00
openshift-merge-bot[bot] d7c1963fce
Merge pull request #5807 from danishprakash/makefile-sources-all
Makefile: list sources via `find` conditionally
2024-11-20 23:32:23 +00:00
Danish Prakash 17ee51d753
Makefile: use `find` to detect source files
The current list of sources doesn't list vendor sources and some other
.go files, requiring manual modifications to the Makefile to build
binaries. This change uses `find` (from Podman's Makefile) to detect .go
files across the repo.

Removes the validation script since we're no longer specifying sources
manually. And removes explicit *.go files as binary sources.

Signed-off-by: Danish Prakash <contact@danishpraka.sh>
2024-11-20 22:14:18 +05:30
openshift-merge-bot[bot] 52437ef15d
Merge pull request #5840 from containers/renovate/github.com-opencontainers-runc-1.x
Update module github.com/opencontainers/runc to v1.2.2
2024-11-19 21:31:49 +00:00
Ed Santiago 75c8852a8c Tests: make _prefetch() parallel-safe
The _prefetch helper, introduced in #2036, is not parallel-safe: two
or more parallel jobs fetching the same image can step on each other
and produce garbage images.

Although we still can't run buildah tests in parallel (see #5552),
we can at least set up the scaffolding for that to happen. This
commit reworks _prefetch() such that the image work is wrapped
inside flock. It has been working fine for months in #5552,
and is IMO safe for production. This can then make it much
easier to flip the parallelization switch once the final zstd
bug is squashed.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-11-19 10:11:24 -07:00
renovate[bot] 8e525d4451
Update module github.com/opencontainers/runc to v1.2.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-16 03:56:33 +00:00
openshift-merge-bot[bot] f1543bdd7d
Merge pull request #5838 from giuseppe/executor-pass-no-pivot-root
executor: allow to specify --no-pivot-root
2024-11-15 14:35:00 +00:00
openshift-merge-bot[bot] 55b5e814d6
Merge pull request #5836 from containers/renovate/github.com-moby-sys-capability-0.x
Update module github.com/moby/sys/capability to v0.4.0
2024-11-14 21:05:29 +00:00
Giuseppe Scrivano eb7a422176
executor: allow to specify --no-pivot-root
the functionality is already implemented, it must be exposed through
the BuildOptions struct.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-11-13 13:06:37 +01:00
renovate[bot] 6cfd93424c
Update module github.com/moby/sys/capability to v0.4.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-12 22:56:46 +00:00
openshift-merge-bot[bot] a65fd39480
Merge pull request #5832 from kolyshkin/makefile-cleanups
(not just) Makefile cleanups
2024-11-12 22:55:43 +00:00
openshift-merge-bot[bot] 787018179b
Merge pull request #5835 from nalind/go1.22
Finish updating to go 1.22
2024-11-11 20:54:06 +00:00
Kir Kolyshkin 135431f8d5 Makefile: mv codespell config to .codespellrc
It is cleaner that way.

While at it, let's try to minimize it.

[NO NEW TESTS NEEDED]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 10:49:04 -08:00
Kir Kolyshkin c2b42c5e4f Fix some codespell errors
[NO NEW TESTS NEEDED]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 10:49:04 -08:00
Kir Kolyshkin f0361414de Makefile,install.md: rm gopath stuff
For quite some time (Go 1.16? To be honest, I don't remember) placing
sources in a specific directory under $GOPATH is no longer required.

[NO NEW TESTS NEEDED]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 10:49:04 -08:00
Kir Kolyshkin c07a5eb567 Makefile: rm targets working on ..
It looks like those were added to aim in CI, and is no longer required.
As it is quite unexpected to have make targets operate on directories such
as ../../, let's remove those.

Fix Ubuntu build instructions accordingly (runc binary package is
available in those distros).

[NO NEW TESTS NEEDED]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 10:49:04 -08:00
Kir Kolyshkin 5adb14cbfe build: rm exclude_graphdriver_devicemapper tag
Since commit c7937cd1d it is no longer necessary to have it.

[NO NEW TESTS NEEDED]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 10:49:04 -08:00
Kir Kolyshkin 967fb5ec12 Makefile: rm unused var
This is no longer used since commit 3a122aa3c.

[NO NEW TESTS NEEDED]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 10:49:04 -08:00
Nalin Dahyabhai f4d4bb240f Finish updating to go 1.22
Update references to specific versions of golang in the Makefile and the
Cirrus CI configuration to match go.mod, and add a check in the 'vendor'
target that CI runs that the image it's run inside is a close-enough
match to the version listed in go.mod.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-11-11 11:03:11 -05:00
openshift-merge-bot[bot] 596bbedbd4
Merge pull request #5833 from edsantiago/bump-again
CI VMs: bump again
2024-11-11 12:42:27 +00:00
openshift-merge-bot[bot] dbf14dcb9f
Merge pull request #5830 from TomSweeneyRedHat/dev/tsweeney/Buildah_v1.38
Bump to c/common v0.61.0, c/image v5.33.0, c/storage v1.56.0, Buildah to v1.38.0
2024-11-11 12:39:07 +00:00
Ed Santiago 6832420b6d CI VMs: bump again
Images built in https://github.com/containers/automation_images/pull/393

Very minor and safe. Purpose is to stabilize those VM images,
which were needed for podman. They include a 6.11.6 kernel
which fixes one bug, and newer pasta in f39 which fixes
another bug.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-11-08 18:44:06 -07:00
tomsweeneyredhat 147765b45c Bump to Buidah v1.39.0-dev
Bump top of tree back to the next dev version.

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-11-08 16:25:44 -05:00
tomsweeneyredhat 7aa3b5ee04 Bump to Buildah v1.38.0
Bump to Buildah v1.38.0 in preparation of Podman v5.3.0

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-11-08 16:25:44 -05:00
tomsweeneyredhat e911fe4a28 Bump to c/common v0.61.0, c/image v5.33.0, c/storage v1.56.0
Bump c/common to v0.61.0, c/image to v5.33.0, and c/storage to v1.56.0
in preparation for Buildah v1.38.0 and Podman v5.3.0

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-11-08 16:25:30 -05:00
openshift-merge-bot[bot] b51c12c6e7
Merge pull request #5825 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.29.0
2024-11-08 18:32:41 +00:00
renovate[bot] 356e4d41e3
fix(deps): update module golang.org/x/crypto to v0.29.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-08 16:22:57 +00:00
openshift-merge-bot[bot] 7db27d2bff
Merge pull request #5824 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.17.1
2024-11-08 16:17:52 +00:00
openshift-merge-bot[bot] 6e1a389a77
Merge pull request #5823 from containers/renovate/github.com-containers-storage-1.x
fix(deps): update module github.com/containers/storage to v1.56.0
2024-11-08 16:09:36 +00:00
renovate[bot] 6b1e4a58cb
fix(deps): update module github.com/moby/buildkit to v0.17.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-08 01:52:41 +00:00
openshift-merge-bot[bot] 663798799b
Merge pull request #5820 from edsantiago/f41
CI VMs: bump f40 -> f41
2024-11-07 21:46:52 +00:00
renovate[bot] 3a583bf04a
fix(deps): update module github.com/containers/storage to v1.56.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-07 21:13:29 +00:00
Ed Santiago e3950407f2 tests: skip two ulimit tests
They compare buildah-bud against podman-run, which breaks if
/usr/bin/podman changes its ulimits, as happened recently
in podman PR 24335.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-11-07 08:24:26 -07:00
Ed Santiago 4703b5b0cd CI VMs: bump f40 -> f41
Images built in https://github.com/containers/automation_images/pull/392

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-11-07 08:15:28 -07:00
openshift-merge-bot[bot] d655c589a7
Merge pull request #5821 from Luap99/lint
tests/tools: update golangci-lint to v1.61.0
2024-11-07 14:32:20 +00:00
openshift-merge-bot[bot] 0385666b30
Merge pull request #5809 from containers/renovate/github.com-opencontainers-runtime-tools-digest
fix(deps): update github.com/opencontainers/runtime-tools digest to 6c9570a
2024-11-07 13:04:16 +00:00
openshift-merge-bot[bot] 50d02415f0
Merge pull request #5812 from containers/renovate/github.com-opencontainers-runc-1.x
fix(deps): update module github.com/opencontainers/runc to v1.2.1
2024-11-07 13:01:31 +00:00
openshift-merge-bot[bot] 0f07c3db73
Merge pull request #5804 from edsantiago/para-prep-bud
tests: bud: make parallel-safe
2024-11-07 12:58:49 +00:00
Paul Holzinger 2cba66285e
tests/tools: rebuild tools when we change versions
As I used this locally and the binaires already existed make did not
rebuild. While we could list all go files here nobody should be
modifying files under vendor/ directly so just checking go.mod/sum seems
easiest.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-11-07 11:06:45 +01:00
Paul Holzinger 3cf2ec21bd
tests/tools: update golangci-lint to v1.61.0
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-11-07 11:01:48 +01:00
openshift-merge-bot[bot] 0dc5f95893
Merge pull request #5806 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.17.0
2024-11-04 21:30:57 +00:00
renovate[bot] a7c316ab75
fix(deps): update module github.com/moby/buildkit to v0.17.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-04 19:30:21 +00:00
openshift-merge-bot[bot] 0787ba6360
Merge pull request #5798 from nalind/mounts-implicit-workdir
Handle RUN --mount with relative targets and no configured workdir
2024-11-04 18:54:13 +00:00
Nalin Dahyabhai 701d6bbe91 Handle RUN --mount with relative targets and no configured workdir
When the target location of a RUN --mount is specified as a relative
path, we normally try to convert it to an absolute path by combining it
with the currently-configured working directory.  If there is no such
value, though, the result is still not an absolute path.  Work around
this by using "/" when the configured working directory is "".

Set this field in the `runMountInfo` struct on FreeBSD, as we already
did on Linux.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-11-04 09:51:20 -05:00
Ed Santiago 9a5b88d3ee tests: bud: make parallel-safe
- all images pushed to a local registry must have a unique name.
  Bring in safename() helper from podman tests.

- all cache tests must use a private TMPDIR

- in force-compression test, use a custom-crafted image with
  no possibility of sharing layers with any other image that
  any other test might push to the registry.

- use a private crun tmpdir in seccomp test, because crun
  does some unexpected caching.

And, forgive me, a little refactoring of unpleasant duplication

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-11-04 06:02:46 -07:00
renovate[bot] 953fb32591
fix(deps): update module github.com/opencontainers/runc to v1.2.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-02 01:20:00 +00:00
openshift-merge-bot[bot] 1752337176
Merge pull request #5810 from containers/renovate/golang.org-x-exp-digest
fix(deps): update golang.org/x/exp digest to f66d83c
2024-11-01 13:51:41 +00:00
openshift-merge-bot[bot] 92dca53dab
Merge pull request #5801 from edsantiago/para-prep-blobcache
tests: blobcache: use unique image name
2024-11-01 13:46:12 +00:00
renovate[bot] d8d117534e
fix(deps): update golang.org/x/exp digest to f66d83c
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-01 03:51:15 +00:00
renovate[bot] fddd1be386
fix(deps): update github.com/opencontainers/runtime-tools digest to 6c9570a
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-01 01:01:50 +00:00
Ed Santiago 3c4e552eb3 tests: blobcache: use unique image name
Prep work for parallelizing bats tests: when pushing images to
local registry, use a pseudorandom unique name to avoid
possibility of collisions/conflicts with other tests. This
is good practice regardless of whether we run serial or parallel.

Also slight refactor of some duplicate code.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-10-31 05:23:51 -06:00
openshift-merge-bot[bot] 3c43322419
Merge pull request #5803 from edsantiago/para-prep-sbom
tests: sbom: never write to cwd
2024-10-30 16:53:53 +00:00
openshift-merge-bot[bot] 046ce4203e
Merge pull request #5802 from edsantiago/para-prep-mkcw
tests: mkcw: bug fixes, refactor
2024-10-30 16:51:11 +00:00
Ed Santiago 1cd6346b3c tests: sbom: never write to cwd
Write output files only to $TEST_SCRATCH_DIR, never to cwd

Reformat overly-long lines for readability (whitespace only changes)

And, in the last test, the output files are plaintext, not json.
Fix filenames accordingly.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-10-29 10:32:49 -06:00
Ed Santiago 2797d22ab3 tests: mkcw: bug fixes, refactor
Bugs found during testing of parallel bats tests:

 - write randomfiles in $TEST_SCRATCH_DIR, not cwd!
 - remove unused & confusing & broken expectedEnv code

And, I couldn't help myself, improve & refactor one test

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-10-29 09:10:18 -06:00
openshift-merge-bot[bot] 9665efd712
Merge pull request #5796 from kolyshkin/runc120
deps: bump runc to v1.2.0
2024-10-23 16:12:07 +00:00
openshift-merge-bot[bot] 83b5dcf219
Merge pull request #5753 from nalind/newline-error
chroot: add newlines at the end of printed error messages
2024-10-23 13:55:54 +00:00
Kir Kolyshkin aa70771648 deps: bump runc to v1.2.0
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-10-22 17:34:56 -07:00
Kir Kolyshkin e213d65be6 deps: switch to moby/sys/userns
runc/libcontainer/userns package moved to a new home; the old package
will be made obsoleted. Switch to the new package.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-10-22 17:34:51 -07:00
openshift-merge-bot[bot] aeec2a18b4
Merge pull request #5783 from nalind/inet
Integration tests: run git daemon on a random-but-bind()able port
2024-10-22 10:22:57 +00:00
Nalin Dahyabhai 855ec0f0c5 tests/test_runner.sh: remove some redundancies
This wrapper doesn't need to load anything from helpers.bash, because
the various .bats files already do so on their own.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-10-21 14:39:55 -04:00
Nalin Dahyabhai 5abf038ddc Integration tests: run git daemon on a random-but-bind()able port
Use a listener helper to bind to an available-according-to-the-kernel
listening port and run a command with its stdio more or less tied to the
connection instead of trying to launch a git daemon directly using a
port number that we can only guess is available.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-10-21 14:39:55 -04:00
openshift-merge-bot[bot] e385eeb8e6
Merge pull request #5782 from containers/renovate/github.com-opencontainers-selinux-1.x
fix(deps): update module github.com/opencontainers/selinux to v1.11.1
2024-10-21 18:17:43 +00:00
openshift-merge-bot[bot] 2551c8f3d1
Merge pull request #5791 from Luap99/vendor-runtime-spec
go.mod: remove unnecessary replace
2024-10-18 14:49:37 +00:00
openshift-merge-bot[bot] bb9d622f49
Merge pull request #5784 from nalind/secret-flags
Document more buildah build --secret options
2024-10-18 14:24:50 +00:00
renovate[bot] 27324c2564
fix(deps): update module github.com/opencontainers/selinux to v1.11.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-18 14:02:50 +00:00
Paul Holzinger 8b7adfa2c8
go.mod: remove unnecessary replace
The replace line has the same version as the normal require line so
there is no need for it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-10-18 14:14:00 +02:00
Nalin Dahyabhai 6c85740bab Document more buildah build --secret options
Describe the "env" and "type" options in the buildah-build(1) man page.

When parsing the "--secret=" flag for the CLI, instead of ignoring an
option that we don't recognize, return an error.

Even though the set of meaningful "id" values for secrets is passed in
via the command line, don't directly use it to construct a file path.

Change the default mode for SSH agent sockets that we create from 0o620
to 0o600.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-10-17 12:02:29 -04:00
openshift-merge-bot[bot] 5518774574
Merge pull request #5733 from rhatdan/VENDOR
Add support for COPY --exclude and ADD --exclude options
2024-10-17 11:11:51 +00:00
Daniel J Walsh aeb6ffeece
Add support for COPY --exclude and ADD --exclude options
Fixes: https://github.com/containers/buildah/issues/5678

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-10-16 16:30:16 -04:00
openshift-merge-bot[bot] 9abec81a5c
Merge pull request #5760 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to e2530d6
2024-10-14 13:35:41 +00:00
openshift-merge-bot[bot] dee45256b9
Merge pull request #5776 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.4
2024-10-11 15:28:50 +00:00
openshift-merge-bot[bot] cb8fa86f69
Merge pull request #5779 from containers/renovate/major-ci-vm-image
chore(deps): update dependency containers/automation_images to v20241010
2024-10-11 15:26:05 +00:00
renovate[bot] 57bba34698
fix(deps): update github.com/containers/luksy digest to e2530d6
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-10 19:34:33 +00:00
renovate[bot] 9cf613a2b5
chore(deps): update dependency containers/automation_images to v20241010
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-10 19:33:24 +00:00
renovate[bot] 6349dc4a27
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.4
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-10 19:33:17 +00:00
openshift-merge-bot[bot] aa67e5d71e
Merge pull request #5778 from mheon/fix_cve_2024_9675
Properly validate cache IDs and sources
2024-10-10 19:07:14 +00:00
Matt Heon 873beddbab Properly validate cache IDs and sources
The `--mount type=cache` argument to the `RUN` instruction in
Dockerfiles was using `filepath.Join` on user input, allowing
crafted paths to be used to gain access to paths on the host,
when the command should normally be limited only to Buildah;s own
cache and context directories. Switch to `filepath.SecureJoin` to
resolve the issue.

Fixes CVE-2024-9675

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-10-10 11:02:55 -04:00
openshift-merge-bot[bot] 98382f02bb
Merge pull request #5774 from lsm5/packit-downstream-constraint
[skip-ci] Packit: constrain koji job to fedora package to avoid dupes
2024-10-08 11:12:22 +00:00
Lokesh Mandvekar 0d27af46f2
[skip-ci] Packit: constrain koji job to fedora package to avoid dupes
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2024-10-08 16:14:54 +05:30
openshift-merge-bot[bot] 1450bf8a0b
Merge pull request #5770 from baude/OWNERS.update
Audit and tidy OWNERS
2024-10-06 10:44:18 +00:00
openshift-merge-bot[bot] e1be44ced5
Merge pull request #5771 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.28.0
2024-10-04 19:56:58 +00:00
Brent Baude e0b7b10e6e Audit and tidy OWNERS
Clean ups on reviewers and approvers for the OWNERS file. Removed
duplications of reviewers (from approvers) and added Jan.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-10-04 13:44:29 -05:00
renovate[bot] 714a23c26f
fix(deps): update module golang.org/x/crypto to v0.28.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-04 17:56:58 +00:00
openshift-merge-bot[bot] bd0de14c46
Merge pull request #5755 from k9withabone/manifest-push-all
Make `buildah manifest push --all` true by default
2024-10-03 21:17:32 +00:00
openshift-merge-bot[bot] 322425b757
Merge pull request #5763 from Luap99/vendor-common
vendor: update c/common to latest
2024-10-02 17:03:43 +00:00
openshift-merge-bot[bot] c68e17b4ff
Merge pull request #5754 from kolyshkin/cap
Don't set ambient caps; switch to moby/sys/capability
2024-10-02 15:27:19 +00:00
openshift-merge-bot[bot] b93b1df702
Merge pull request #5765 from Luap99/test-names
tests: add quotes to names
2024-10-02 15:00:43 +00:00
Paul Holzinger c7dd90dd7b
tests: add quotes to names
In podman we also run the bud tests, there I noticed a issue with the
podman skip logic as it was unable to fine the build-add-https-retry-ca
test name as it always expects quotes[1]

In general names should be human readable so add quotes and use spaces
over a dash as word separator.

[1] https://github.com/containers/podman/pull/24135

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-10-02 14:57:38 +02:00
Paul Holzinger a018ec2b0c
vendor: update c/common to latest
Contains a fix for CVE-2024-9341

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-10-02 10:48:45 +02:00
openshift-merge-bot[bot] a518f88139
Merge pull request #5761 from nalind/validate-bind-propagation
CVE-2024-9407: validate "bind-propagation" flag settings
2024-10-01 17:59:56 +00:00
Nalin Dahyabhai 732f770648 CVE-2024-9407: validate "bind-propagation" flag settings
CVE-2024-9407: validate that the value for the "bind-propagation" flag
when handling "bind" and "cache" mounts in `buildah run` or in RUN
instructions is one of the values that we would accept without the
"bind-propagation=" prefix.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-10-01 11:01:45 -04:00
openshift-merge-bot[bot] 4aeddcc80d
Merge pull request #5759 from mtrmac/chunked-encryption
Document that zstd:chunked is downgraded to zstd when encrypting
2024-10-01 10:28:29 +00:00
openshift-merge-bot[bot] e56ba01e1b
Merge pull request #5758 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.3
2024-10-01 10:25:39 +00:00
Kir Kolyshkin 95f2e1020f vendor: switch to moby/sys/capability
github.com/moby/sys/capability is a fork of the (no longer maintained)
github.com/syndtr/gocapability package.

For the list of changes since the fork took place, see
https://github.com/moby/sys/blob/main/capability/CHANGELOG.md

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-09-30 13:19:03 -07:00
Kir Kolyshkin 37a6bde534 Don't set ambient capabilities
Ambient capabilities can't be raised without inheritable ones, and since we
don't raise inheritable, we should not raise ambient either.

This went unnoticed because of a bug in syndtr/gocapability which is
only fixed in its fork (see the next commit).

Amends commit e7e55c988.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-09-30 13:19:03 -07:00
Miloslav Trmač 5193f21b0a Document that zstd:chunked is downgraded to zstd when encrypting
A part of https://github.com/containers/common/issues/2117 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-09-30 21:09:38 +02:00
renovate[bot] 271093d511
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.3
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 15:27:52 +00:00
openshift-merge-bot[bot] a7dd29cafa
Merge pull request #5757 from siretart/patch-2
buildah-manifest-create.1: Fix manpage section
2024-09-29 15:41:36 +00:00
openshift-merge-bot[bot] b03740fc2f
Merge pull request #5756 from containers/renovate/ubuntu-24.x
chore(deps): update dependency ubuntu to v24
2024-09-29 13:37:51 +00:00
Reinhard Tartler 03ca93fb01
buildah-manifest-create.1: Fix manpage section
Signed-off-by: Reinhard Tartler <siretart@gmail.com>
2024-09-29 09:22:10 -04:00
renovate[bot] fea5c3d498
chore(deps): update dependency ubuntu to v24
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-26 19:03:11 +00:00
Paul Nettleton d0819591d9 Make `buildah manifest push --all` true by default
Changed the `--all` option of `buildah manifest push` to be true by
default. This matches the behavior of the equivalent Podman option
(`podman manifest push --all`), making it easier to switch between
Podman and Buildah.

Updated buildah.manifest.push.1 docs to reflect this change.

Added test "manifest-push-all-default-true" to `tests/lists.bats`.

Closes: #5547
Signed-off-by: Paul Nettleton <k9@k9withabone.dev>
2024-09-25 18:11:14 -05:00
Nalin Dahyabhai 2ff91b8b08 chroot: add newlines at the end of printed error messages
If we print an error message to stderr, end it with a newline.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-24 17:11:16 -04:00
openshift-merge-bot[bot] 509de30ca8
Merge pull request #5734 from rhatdan/man
[CI:DOCS] Document how entrypoint is configured in buildah config
2024-09-24 11:44:49 +00:00
openshift-merge-bot[bot] 27b92881b4
Merge pull request #5745 from cuishuang/main
fix: remove duplicate conditions
2024-09-20 13:37:28 +00:00
openshift-merge-bot[bot] d8a9a87218
Merge pull request #5741 from mheon/fix_podman_18543
Do not error on trying to write IMA xattr as rootless
2024-09-19 17:43:54 +00:00
Matt Heon 5e82f27fb6 Do not error on trying to write IMA xattr as rootless
Rootless users cannot set the `security.ima` xattr on files
(presumably for security reasons, they get an EPERM on trying to
do so). We will normally try and preserve that xattr, so when
trying to add a file with an IMA xattr to a build on a Buildah
without this patch, you get an error. With this patch, the error
is downgraded to a warning, as it's better to successfully build
with a missing xattr than blocking all builds which want to
include the offending file.

The urgency on this has become somewhat higher as it seems like
F41/Rawhide are installing rpm-plugin-ima by default, which is
setting IMA xattrs on some files that Podman relies on - for
example, the catatonit binary we use for pid pause images.
Without this patch, building the pause image as rootless will
always fail on a system with rpm-plugin-ima installed.

Fixes: https://github.com/containers/podman/issues/18543

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-09-19 11:45:03 -04:00
cuishuang c07ae2b4cf fix: remove duplicate conditions
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-19 15:30:30 +08:00
openshift-merge-bot[bot] 64ffb74d2b
Merge pull request #5383 from containers/renovate/github.com-moby-buildkit-0.x
fix(deps): update module github.com/moby/buildkit to v0.16.0
2024-09-16 15:30:35 +00:00
openshift-merge-bot[bot] 35d43d3521
Merge pull request #5736 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.2
2024-09-16 15:27:21 +00:00
renovate[bot] 4bc98d54d6
fix(deps): update module github.com/moby/buildkit to v0.16.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-13 19:14:19 +00:00
openshift-merge-bot[bot] b4d5c2f62b
Merge pull request #5732 from nalind/binfmt-container
In a container, try to register binfmt_misc
2024-09-13 13:42:24 +00:00
renovate[bot] 1281172249
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-13 12:44:57 +00:00
openshift-merge-bot[bot] bd12ae1bb0
Merge pull request #5729 from nalind/compat-volumes-layers
imagebuildah.StageExecutor: clean up volumes/volumeCache
2024-09-13 10:32:40 +00:00
openshift-merge-bot[bot] 7527799220
Merge pull request #5687 from containers/renovate/github.com-fsouza-go-dockerclient-1.x
fix(deps): update module github.com/fsouza/go-dockerclient to v1.12.0
2024-09-13 09:29:22 +00:00
openshift-merge-bot[bot] 3f97ba1092
Merge pull request #5730 from lsm5/packit-sidetag
[skip-ci] Packit: Enable sidetags for bodhi updates
2024-09-13 09:26:37 +00:00
Daniel J Walsh 1f02b65c63
Document how entrypoint is configured in buildah config
Fixes: https://github.com/containers/buildah/issues/5598

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-09-12 16:30:35 -04:00
Nalin Dahyabhai baf91f2b00 In a container, try to register binfmt_misc
If we're running a command in a working container whose platform doesn't
match our own, attempt to register any emulators for which we find
configurations of the type included in Fedora's qemu-user-static
packages.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-12 11:55:33 -04:00
Nalin Dahyabhai 81d1256bd7 imagebuildah.StageExecutor: clean up volumes/volumeCache
Clean up the distinctions between the volumes slice and the volumeCache
and volumeCacheInfo maps so that --compat-volumes will work correctly
when we're building with multiple layers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-12 09:02:22 -04:00
openshift-merge-bot[bot] 18d09f02e2
Merge pull request #5731 from nalind/one-target-platform
build: fall back to parsing a TARGETPLATFORM build-arg
2024-09-12 09:58:58 +00:00
Nalin Dahyabhai 80e15584c5 build: fall back to parsing a TARGETPLATFORM build-arg
If we're not given an explicit platform or arch or os to target for a
build, but someone defined TARGETPLATFORM as a build argument, parse it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-11 14:46:56 -04:00
openshift-merge-bot[bot] 49406e1834
Merge pull request #5728 from nalind/multiple-artifacts
`manifest add --artifact`: handle multiple values
2024-09-11 18:43:24 +00:00
Nalin Dahyabhai edc43c4e6d `manifest add --artifact`: handle multiple values
Don't error out when `manifest add --artifact` is given multiple files,
and add a test which should have checked that.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-11 10:00:10 -04:00
Lokesh Mandvekar b2defd39e7
Packit: split out ELN jobs and reuse fedora downstream targets
ELN is kind of a midway between Fedora and RHEL, so it's best to mention
ELN jobs separately. This will also allow reusing fedora targets using
YAML anchors for TMT tests.

This commit also mentions fedora-40 targets separately for copr_build
jobs so that once fedora-41 is released, fedora-40 jobs continue to
trigger.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2024-09-11 17:50:36 +05:30
Lokesh Mandvekar 0494df68b0
Packit: Enable sidetags for bodhi updates
Packit now has sidetag support for adding multiple builds into a single
bodhi update.

Since we release c/ccommon, skopeo, buildah and podman often
almoost simultaneously, we should release them to Fedora in a single
bodhi update using sidetags so all builds can be tested together.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2024-09-11 17:48:03 +05:30
openshift-merge-bot[bot] 19e7088edb
Merge pull request #5438 from danishprakash/add-git-ref
add: add support for git sources
2024-09-09 21:35:55 +00:00
openshift-merge-bot[bot] 4565497fe5
Merge pull request #5726 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.2.1+incompatible
2024-09-09 20:54:41 +00:00
openshift-merge-bot[bot] 599520fe63
Merge pull request #5724 from Luap99/pasta-map-guest-addr
make use of new pasta option from c/common
2024-09-09 14:28:59 +00:00
renovate[bot] 81b357e369
fix(deps): update module github.com/docker/docker to v27.2.1+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-09 11:45:03 +00:00
danishprakash 71fc845d0b
tests/bud.bats: add git source
Signed-off-by: Danish Prakash <contact@danishpraka.sh>
2024-09-09 12:45:15 +05:30
danishprakash 47297b3d5c
add: add support for git source
Signed-off-by: Danish Prakash <contact@danishpraka.sh>
2024-09-09 12:45:15 +05:30
openshift-merge-bot[bot] 695a29d9b9
Merge pull request #5719 from containers/renovate/golang.org-x-term-0.x
fix(deps): update module golang.org/x/term to v0.24.0
2024-09-06 15:18:07 +00:00
Paul Holzinger 5184bf1612
Add support for the new c/common pasta options
We always map 169.254.1.2 with pasta to the host now so ensure the
host.containers.internal entry is set correctly.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-06 17:05:52 +02:00
Paul Holzinger 7bf7da57ad
vendor latest c/common
Includes my pasta changes

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-06 14:58:48 +02:00
renovate[bot] 8d72867620
fix(deps): update module golang.org/x/term to v0.24.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-05 19:48:41 +00:00
renovate[bot] e084370009
fix(deps): update module github.com/fsouza/go-dockerclient to v1.12.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-05 19:46:51 +00:00
openshift-merge-bot[bot] 101d5eaf78
Merge pull request #5715 from Luap99/go-1.22
Update to go 1.22
2024-09-04 12:54:54 +00:00
openshift-merge-bot[bot] f56150a1f9
Merge pull request #5710 from Honny1/vendro-c-common
Vendor `c/common:9d025e4cb348`
2024-09-03 17:42:09 +00:00
openshift-merge-bot[bot] fb40f69e94
Merge pull request #5688 from nalind/copyglob
copier: handle globbing with "**" path components
2024-09-03 17:39:23 +00:00
Paul Holzinger a353800596
packit: update fedora and epel targets
Fedora 39 and epel 9 contains go 1.21 which we no longer build on,
fedora 39 will likely never be updated but epel 9 should get a golang
update at some point.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-03 18:00:41 +02:00
Paul Holzinger 909cca8b1b
cirrus: disable f39 testing
The golang version is not new enough, this needs to be turned back on
when we upgrade VMs to f41/40 so it is only commented out.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-03 17:54:21 +02:00
Paul Holzinger db2a666ddb
cirrus: fix fedora names
The fedora version where wrong in the name causing the task names to
show the wrong distro versions.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-03 17:50:33 +02:00
Paul Holzinger 3f047d49b8
update to go 1.22
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-03 17:49:17 +02:00
Jan Rodák ed881abfeb
Vendor c/common:9d025e4cb348
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-09-03 17:47:42 +02:00
Nalin Dahyabhai 9e374f9fd4 copier: handle globbing with "**" path components
Handle glob patterns with "**" path components by expanding "**" to the
set of subdirectories and calling filepath.Glob() on the results.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-03 11:46:24 -04:00
openshift-merge-bot[bot] e58ee285c3
Merge pull request #5712 from containers/renovate/golang.org-x-exp-digest
fix(deps): update golang.org/x/exp digest to 9b4947d
2024-09-03 14:37:23 +00:00
openshift-merge-bot[bot] ed761e0120
Merge pull request #5711 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to 2e7307c
2024-09-03 14:31:21 +00:00
renovate[bot] cee3c13110
fix(deps): update golang.org/x/exp digest to 9b4947d
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-01 06:54:09 +00:00
renovate[bot] 9ab093138a
fix(deps): update github.com/containers/luksy digest to 2e7307c
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-01 04:06:25 +00:00
openshift-merge-bot[bot] 69259725a0
Merge pull request #5690 from nalind/compat-scratch-config
imagebuildah: make scratch config handling toggleable
2024-08-28 18:33:49 +00:00
Nalin Dahyabhai f88579d1fe imagebuildah: make scratch config handling toggleable
The default configuration that `docker build` applies to images built
using "scratch" has changed from classic builds to BuildKit.  Add a
toggle for selecting which behavior to mimic.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-28 10:21:16 -04:00
openshift-merge-bot[bot] ef563e1e5c
Merge pull request #5708 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.2.0+incompatible
2024-08-28 13:59:00 +00:00
renovate[bot] 01a58991cd
fix(deps): update module github.com/docker/docker to v27.2.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-27 21:04:13 +00:00
openshift-merge-bot[bot] 45198f3489
Merge pull request #5704 from nalind/check-sources
Add a validation script for Makefile $(SOURCES)
2024-08-25 11:20:06 +00:00
Nalin Dahyabhai 09c231f830 Add a validation script for Makefile $(SOURCES)
Add a validation script that checks that we haven't forgotten to add any
new packages to the SOURCES definition in the top-level Makefile.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-22 17:29:26 -04:00
openshift-merge-bot[bot] 63a31fc903
Merge pull request #5700 from containers/renovate/github.com-openshift-imagebuilder-1.x
fix(deps): update module github.com/openshift/imagebuilder to v1.2.15
2024-08-22 15:02:44 +00:00
openshift-merge-bot[bot] 1314520d5e
Merge pull request #5703 from edsantiago/new-vms
New VMs
2024-08-22 13:20:30 +00:00
renovate[bot] 510dd75f68
fix(deps): update module github.com/openshift/imagebuilder to v1.2.15
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-22 13:04:57 +00:00
openshift-merge-bot[bot] c5085392c5
Merge pull request #5702 from nalind/update-some-godocs
[CI:DOCS] update some godocs, use 0o to prefix an octal in a comment
2024-08-22 10:12:07 +00:00
Ed Santiago 3443669351 New VMs
Built: https://github.com/containers/automation_images/pull/383

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-08-21 13:58:59 -06:00
Nalin Dahyabhai e8e83bb8bd Update some godocs, use 0o to prefix an octal in a comment
Update some godocs, and update an octal value in a godoc to start with
0o instead of just 0, to match the literal on the next line.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-21 14:22:27 -04:00
openshift-merge-bot[bot] 965be0bf38
Merge pull request #5701 from nalind/layer-label
[CI:DOCS] buildah-build.1.md: expand the --layer-label description
2024-08-21 18:15:07 +00:00
openshift-merge-bot[bot] 1b95a575b9
Merge pull request #5697 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.60.2
2024-08-21 18:04:08 +00:00
Nalin Dahyabhai a2629f5287 buildah-build.1.md: expand the --layer-label description
Expand on the description of what --layer-label does.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-21 13:39:59 -04:00
renovate[bot] b695098b0d
fix(deps): update module github.com/containers/common to v0.60.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-20 22:00:00 +00:00
flouthoc d0988936b4
stage_executor: set avoidLookingCache only if mounting stage
set `avoidLookingCache` to `true` if `--mount` is using a freshly built
stage and not for `additional-build-context`.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2024-08-20 08:27:48 -07:00
flouthoc f1cd5ae4a8
imagebuildah: additionalContext is not a local built stage
This line looks like a typo in past commit as `additionalContext` which
is found is not a local built stage so set `IsStage` to `false`.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2024-08-20 08:27:28 -07:00
openshift-merge-bot[bot] 577b6ac39c
Merge pull request #5694 from dfr/freebsd-network-host
run: fix a nil pointer dereference on FreeBSD
2024-08-20 12:18:25 +00:00
Doug Rabson 0ade010484 run: fix a nil pointer dereference on FreeBSD
Attempting to use 'buildah run --network=host' caused a nil pointer
dereference while setting up the container's resolv.conf file -
(*Builder).addResolvConfEntries expects a non-nil value for its specs
parameter.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2024-08-20 08:20:40 +01:00
openshift-merge-bot[bot] 899b05ed72
Merge pull request #5689 from nalind/linters
CI: enable the gofumpt and whitespace linters
2024-08-16 11:37:08 +00:00
openshift-merge-bot[bot] 688affa5b7
Merge pull request #5686 from nalind/retry-reuse
Commit(): retry committing to local storage on storage.LayerUnknown
2024-08-16 11:31:37 +00:00
Nalin Dahyabhai ca3b80eb0f CI: enable the whitespace linter
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 16:09:25 -04:00
Nalin Dahyabhai 0ad0ffaad9 Fix some govet linter warnings
govet warned about some places where we were passing something other
than a literal string to a function that took format specifiers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 16:09:24 -04:00
Nalin Dahyabhai 662abee0bf Commit(): retry committing to local storage on storage.LayerUnknown
If we get a storage.LayerUnknown error while committing to local
storage, guess that we tried to reuse a layer in an image that got
deleted in the brief window between when the commit logic decided that
it could reuse the layer, and when it actually tried to create the image
record.

It's tempting to try to resolve this in the image library, but at the
point where this error crops up, it may already have skipped pulling the
relevant layer blob, so the entire copy operation would have to be
restarted from the beginning anyway, and that's the retry package's job.

It's tempting to bake this into the common library's retry package, but
that would require it to "know" about containers/storage, and while in
practice most of its callers already depend on the storage library, that
may a bit much.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 13:26:30 -04:00
Nalin Dahyabhai 8ae99121c1 CI: enable the gofumpt linter
Turn on the gofumpt linter.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 13:17:44 -04:00
openshift-merge-bot[bot] bb3ab31e79
Merge pull request #5684 from nalind/go-get-friendliness
conformance: move weirdly-named files out of the repository
2024-08-15 16:47:15 +00:00
Nalin Dahyabhai d07c3dfb0e conformance: move weirdly-named files out of the repository
Remove certain weirdly-named files being used by a conformance test out
of the repository and create them at test-time.  Github refused to
generate archives of the repository when they were present in the commit
being requested.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-14 14:59:08 -04:00
openshift-merge-bot[bot] b5765b1e5e
Merge pull request #5683 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.1.2+incompatible
2024-08-14 14:28:43 +00:00
renovate[bot] a60788c56a
fix(deps): update module github.com/docker/docker to v27.1.2+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-13 17:42:38 +00:00
openshift-merge-bot[bot] a36a5cc1e4
Merge pull request #5682 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.60.1
2024-08-13 14:27:41 +00:00
renovate[bot] ec87847c97
fix(deps): update module github.com/containers/common to v0.60.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-12 20:15:33 +00:00
openshift-merge-bot[bot] a47263d9fa
Merge pull request #5680 from kolyshkin/gofmt
gofix, gofmt the code, add gofmt linter
2024-08-12 16:02:10 +00:00
openshift-merge-bot[bot] b926eb02c8
Merge pull request #5679 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.32.1
2024-08-12 15:59:27 +00:00
Kir Kolyshkin fd3aba9917 *: use gofmt -s, add gofmt linter
1. Use gofmt to format the code:

	git ls-files \*.go | grep -Ev '/?vendor/' | xargs gofmt -w -s

2. Add gofmt to golangci-lint (it's not enabled by default).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-09 17:05:58 -07:00
Kir Kolyshkin 24da18800e *: fix build tags
This change is generated by `go1.23rc2 fix ./...`.

Had to use go1.23rc2, since all released go versions have a bug
preventing it from working with `go 1.22.0` in go.mod (opened
https://github.com/golang/go/issues/68825,
https://github.com/golang/go/issues/68824 for awareness).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-09 17:05:30 -07:00
renovate[bot] 57d820d376
fix(deps): update module github.com/containers/image/v5 to v5.32.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-09 22:45:29 +00:00
openshift-merge-bot[bot] 94aa41b84b
Merge pull request #5672 from nalind/unit-tests-mirrors
unit tests: use test-specific policy.json and registries.conf
2024-08-09 11:19:08 +00:00
openshift-merge-bot[bot] f2156795f4
Merge pull request #5676 from nalind/escape-globs
Add(): re-escape any globbed items that included escapes
2024-08-09 10:54:31 +00:00
openshift-merge-bot[bot] 8f862607f4
Merge pull request #5673 from nalind/conformance-mirror
conformance tests: use mirror.gcr.io for most images
2024-08-09 10:48:51 +00:00
openshift-merge-bot[bot] fc16a8128b
Merge pull request #5677 from containers/renovate/golang.org-x-sys-0.x
fix(deps): update module golang.org/x/sys to v0.24.0
2024-08-08 21:47:06 +00:00
Nalin Dahyabhai 3ea43566ac Add(): re-escape any globbed items that included escapes
When collecting items we matched using the passed-in globs during Add(),
be sure that globbing performed by Get() will match the items exactly,
by escaping special matching characters.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-08 16:46:47 -04:00
Nalin Dahyabhai 05da9a7450 conformance tests: use mirror.gcr.io for most images
Use busybox and alpine images from mirror.gcr.io, where possible, to
avoid tripping pull limits in CI.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-08 15:59:06 -04:00
Nalin Dahyabhai c39f622d0a unit tests: use test-specific policy.json and registries.conf
In unit tests that create a SystemContext, point that SystemContext at
the testing signature policy and registries configuration.  This should
cause us to pay attention to mirroring settings for images used by this
set of tests.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-08 15:56:17 -04:00
openshift-merge-bot[bot] d7390578d9
Merge pull request #5666 from nalind/update-containerd
Update containerd
2024-08-08 19:41:12 +00:00
renovate[bot] a1ce1c1ee0
fix(deps): update module golang.org/x/sys to v0.24.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-08 19:35:50 +00:00
Nalin Dahyabhai c7b7f12727 Update to spun-out "github.com/containerd/platforms"
In 1.7.19, containerd spun out its platforms package into its own
repository.  Update to use the new repository.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-08 09:30:10 -04:00
Nalin Dahyabhai 832ff6cb81 Bump github.com/containerd/containerd
Bump containerd from v1.7.18 to v1.7.20

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-08 09:30:09 -04:00
openshift-merge-bot[bot] f113537d71
Merge pull request #5665 from nalind/fixup-tutorial
[CI:DOCS] Update tutorials to keep up with API changes in storage
2024-08-07 22:55:17 +00:00
openshift-merge-bot[bot] 54f8d1df15
Merge pull request #5668 from nalind/redundant-e2e
Drop the e2e test suite
2024-08-07 22:42:13 +00:00
Nalin Dahyabhai ed6dd4227d test/tools/Makefile: duplicate the vendor-in-container target
Add a copy of the vendor-in-container target that the top-level Makefile
has.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:11:51 -04:00
Nalin Dahyabhai f52158f0e1 linters: unchecked error
Check a previously-unchecked error.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai abea603df3 linters: don't end loop iterations with "else" when "then" would
Don't end a loop iteration with an "else" block if the "then" block
would cause the loop iteration to finish, due to a "break", "continue",
or known-to-not-return function call.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai fdf1c75cd3 linters: unused arguments shouldn't have names
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai 6224e9a44e linters: rename checkIdsGreaterThan5() to checkIDsGreaterThan5()
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai ae0d9d002e linters: don't name variables "cap"
Rename some variables so that we don't use a keyword as a variable name.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai 282cc38c39 `make lint`: use --timeout instead of --deadline
Updated linters use `--timeout` instead of `--deadline`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai d01e4ede36 Drop the e2e test suite
They largely duplicate other integration tests.  Add an integration test
to cover the "output from inspect is valid JSON" case.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:33 -04:00
openshift-merge-bot[bot] 0b722a48e9
Merge pull request #5670 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.26.0
2024-08-07 14:01:41 +00:00
openshift-merge-bot[bot] 930dc5225a
Merge pull request #5541 from jelmer/installation-apt-extra
install: On Debian/Ubuntu, add installation of libbtrfs-dev and libdevmapper-dev
2024-08-06 21:02:18 +00:00
openshift-merge-bot[bot] dce9b748d1
Merge pull request #5667 from nalind/use-my-go-cache
`make vendor-in-container`: use the caller's Go cache if it exists
2024-08-06 19:09:42 +00:00
renovate[bot] c65328683c
fix(deps): update module golang.org/x/crypto to v0.26.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-06 17:07:10 +00:00
openshift-merge-bot[bot] 72104e3c93
Merge pull request #5650 from containers/renovate/github.com-onsi-gomega-1.x
fix(deps): update module github.com/onsi/gomega to v1.34.1
2024-08-06 17:05:42 +00:00
openshift-merge-bot[bot] cbe97da5a5
Merge pull request #5659 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to 1f482a9
2024-08-06 14:56:27 +00:00
openshift-merge-bot[bot] 10dc8bcb48
Merge pull request #5658 from containers/renovate/github.com-fsouza-go-dockerclient-1.x
fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.2
2024-08-06 14:50:58 +00:00
Daniel J Walsh 1f1e8ba49c
Merge pull request #5663 from containers/renovate/golang.org-x-sys-0.x
fix(deps): update module golang.org/x/sys to v0.23.0
2024-08-06 10:03:44 -04:00
renovate[bot] 23f241e6fb
fix(deps): update module github.com/onsi/gomega to v1.34.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-06 13:53:45 +00:00
openshift-merge-bot[bot] a5c7f6c51c
Merge pull request #5455 from Asutorufa/main
fix(deps): fix test/tools ginkgo typo
2024-08-06 13:53:13 +00:00
Nalin Dahyabhai 277d40a2e4 `make vendor-in-container`: use the caller's Go cache if it exists
If the $(go env GOCACHE) directory exists and is writeable, bind-mount
it into the container that we're running to do the vendoring.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-06 09:46:38 -04:00
openshift-merge-bot[bot] b6fe4f5779
Merge pull request #5652 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.1
2024-08-06 12:55:27 +00:00
Asutorufa aac50f6618 fix(deps): fix test/tools ginkgo typo
Signed-off-by: Asutorufa <16442314+Asutorufa@users.noreply.github.com>
2024-08-06 09:49:30 +08:00
openshift-merge-bot[bot] 7c091d129d
Merge pull request #5654 from jnovy/epoch
Use Epoch: 2 and respect the epoch in dependencies.
2024-08-05 21:38:49 +00:00
Daniel J Walsh 96d8b14f11
Merge branch 'main' into fixup-tutorial 2024-08-05 16:51:22 -04:00
openshift-merge-bot[bot] 33892e8ebe
Merge pull request #5660 from containers/renovate/golang.org-x-exp-digest
fix(deps): update golang.org/x/exp digest to 8a7402a
2024-08-05 20:13:44 +00:00
renovate[bot] dd87159769
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 19:48:18 +00:00
Nalin Dahyabhai 34a7ce99b1 Update to keep up with API changes in storage
* Call storage.DefaultStoreOptions() instead of
  storage.DefaultStoreOptionsAutoDetectUID() in the tutorial.
* Mention installing passt when installing build-time dependencies.
* Include the registry part of examples that use node:12-alpine.
* Use registry.fedoraproject.org for Fedora images.
* Mention Fedora 40 instead of 35 in examples.
* Mount an emptyDir volume in the OpenShift example, so that it can use
  overlay for storage
* Use a more recent buildah image as the base in the OpenShift example.
* Use a ReplicationController instead of a DeploymentConfig in the
  OpenShift example, because DeploymentConfigs are deprecated.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-05 14:56:38 -04:00
renovate[bot] 00d67a48f1
fix(deps): update github.com/containers/luksy digest to 1f482a9
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 13:04:03 +00:00
Jelmer Vernooij 987e63a2d5
install: On Debian/Ubuntu, add installation of libbtrfs-dev
Signed-off-by: Jelmer Vernooij <jvernooij@evroc.com>
2024-08-05 12:35:35 +01:00
renovate[bot] e3c1953f79
fix(deps): update module golang.org/x/sys to v0.23.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-04 22:05:25 +00:00
renovate[bot] 5f96e03923
fix(deps): update golang.org/x/exp digest to 8a7402a
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-01 03:13:39 +00:00
renovate[bot] 9254e5ca88
fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-31 18:53:49 +00:00
Jindrich Novy edc1b77522 Use Epoch: 2 and respect the epoch in dependencies.
Signed-off-by: Jindrich Novy <jnovy@redhat.com>
2024-07-29 08:45:29 +02:00
openshift-merge-bot[bot] 4ee64aca64
Merge pull request #5647 from nalind/linked-layers
Add PrependedLinkedLayers/AppendedLinkedLayers to CommitOptions
2024-07-28 13:56:07 +00:00
openshift-merge-bot[bot] 30fa40d03f
Merge pull request #5646 from nalind/add-https-retry-ca
AddAndCopyOptions: add CertPath, InsecureSkipTLSVerify, Retry fields
2024-07-28 10:46:29 +00:00
openshift-merge-bot[bot] 2a88c22e0a
Merge pull request #5651 from TomSweeneyRedHat/dev/tsweeney/v1.37.0
Bump to Buildah v1.37.0
2024-07-26 17:28:36 +00:00
tomsweeneyredhat 4e78b5723c Bump to Buildah v1.38.0-dev
Bump Buildah's main branch to the next dev release.

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-07-26 09:48:25 -04:00
tomsweeneyredhat f9de1bbd1f Buildah v1.37.0
Bump Buildah to v1.37.0 in preparation for Podman v5.2

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-07-26 09:47:33 -04:00
tomsweeneyredhat 7de5d5d6e0 Bump c/storage, c/image, c/common for v1.37.0
Bump c/storage to v1.55.0, c/image to v5.32.0, and c/common to v0.60.0
in preparation of the Buildah v1.37.0 and the Podman v5.2 releases

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-07-26 09:38:38 -04:00
Nalin Dahyabhai 5f18ba259a AddAndCopyOptions: add CertPath, InsecureSkipTLSVerify, Retry fields
Add CertPath and InsecureSkipTLSVerify flags to AddAndCopyOptions, and
connect the CLI flag values passed to `buildah add` and `buildah build`
so that Builder.Add() gets those.

Add MaxRetries and RetryDelay fields to AddAndCopyOptions, and connect
them to the values passed on the command line to `buildah add` and
`buildah build`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-25 17:39:08 -04:00
Nalin Dahyabhai c467bd139a Add PrependedLinkedLayers/AppendedLinkedLayers to CommitOptions
Add API for adding arbitrary layers at commit-time via CommitOptions,
and via methods of the Builder type.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-25 15:49:17 -04:00
Nalin Dahyabhai 8aa9a1c225 integration tests: teach starthttpd() about TLS and pid files
Add optional third and fourth arguments to starthttpd() which can
specify a location to store a generated self-signed TLS certificate and
key which will be used to start the helper HTTP server with TLS, and an
optional fifth argument to which it will write its PID.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-25 13:54:35 -04:00
openshift-merge-bot[bot] b4b19f40ee
Merge pull request #5641 from nalind/update-imagebuilder-v1.2.12
Update github.com/openshift/imagebuilder to v1.2.14
2024-07-24 17:32:27 +00:00
Nalin Dahyabhai 6373be5a1d "build with basename resolving user arg" tests: correct ARG use
Don't expect to be able to resolve an ARG in the FROM instruction for
the second stage if the ARG was only declared in the first stage.  Only
ARGs introduced in the header are available for FROM instructions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-24 11:05:34 -04:00
Nalin Dahyabhai dcf3ea5fd5 bud-multiple-platform-no-run test: correct ARG use
Don't expect to be able to resolve an ARG in the FROM instruction for
the second stage if the ARG was only declared in the first stage.  Only
ARGs introduced in the header are available for FROM instructions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-24 11:05:34 -04:00
Nalin Dahyabhai 3e38e5e138 imagebuildah: always have default values for $TARGET... args ready
Always have values for $TARGET... build args ready to be used.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-24 11:05:34 -04:00
Nalin Dahyabhai 7f1fe46fc7 bump github.com/openshift/imagebuilder to v1.2.14
Bump github.com/openshift/imagebuilder from v1.2.11 to v1.2.14,
introducing a BuiltinArgDefaults field in a Builder that holds defaults
for built-in BUILD... and TARGET... arguments.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-24 11:05:27 -04:00
openshift-merge-bot[bot] 59316508c3
Merge pull request #5644 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.1.1+incompatible
2024-07-24 01:34:32 +00:00
renovate[bot] f6f2da76d7
fix(deps): update module github.com/docker/docker to v27.1.1+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-23 22:20:38 +00:00
openshift-merge-bot[bot] 2833a6b0f6
Merge pull request #5643 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.1
2024-07-23 16:16:15 +00:00
openshift-merge-bot[bot] eb689652f8
Merge pull request #5639 from containers/renovate/github.com-docker-docker-27.x
fix(deps): update module github.com/docker/docker to v27.1.0+incompatible
2024-07-23 15:04:52 +00:00
renovate[bot] 5e20b928c7
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-23 11:31:35 +00:00
renovate[bot] 54d84483a5
fix(deps): update module github.com/docker/docker to v27.1.0+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-22 12:00:24 +00:00
openshift-merge-bot[bot] 16bd9a3105
Merge pull request #5584 from edsantiago/ci-vms-with-local-registry
CI: use local registry
2024-07-19 01:15:20 +00:00
Ed Santiago 3ad0fd1ed1 CI: use local registry, part 2 of 2
Make tests pass when using a local cache registry (as triggered
by $CI_USE_REGISTRY_CACHE being non-empty).

Mostly just change images: consolidate to a smaller set, like,
replace the few instances of debian with ubuntu, use $SAFEIMAGE
where we can.

The most significant change was with some s1 (schema 1?) images.
Those exist on quay, but cannot be mirrored locally: the local
registry forbids schema 1 images. I choose to skip these tests
when running against a local registry.

Second most significant change is running containerized tests
with --net=host. We need this to access the registry running
on a localhost port. (One alternative would be to bind the
registry on all interfaces, cringe, then perform sed magic
on the registries-cache.conf file changing 127.0.0.1 to
host.containers.internal, more cringe).

Also, some cleanup.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-07-17 12:26:49 -06:00
Ed Santiago 52df6e0e0f CI: use local registry, part 1 of 2
As of https://github.com/containers/automation_images/pull/357
our CI VMs include a local registry preloaded with all(*)
images used in tests.

 * where "all" means "most".

This commit defines a new registries-cached.conf, used in tests,
that redirects docker and quay to the new local registry. The
hope is that this will reduce CI flakes.

Since tests change over time, and new tests may require new
images, this commit also adds a mechanism for pulling in
remote images at test run time. Obviously this negates
the purpose of the cache, since it introduces a flake
pain point. The idea is: DO NOT DO THIS UNLESS ABSOLUTELY
NECESSARY, and then, if we have to do this, hurry up and
spin new CI VMs that include the new image(s).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-07-17 12:09:54 -06:00
openshift-merge-bot[bot] 8f59436d55
Merge pull request #5634 from containers/renovate/github.com-fsouza-go-dockerclient-1.x
fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.1
2024-07-17 17:58:27 +00:00
renovate[bot] 2a99f9bcda
fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-17 06:39:03 +00:00
openshift-merge-bot[bot] ec5b8feb76
Merge pull request #5629 from nalind/but-we-needed-that
Revert #5627
2024-07-16 19:09:56 +00:00
openshift-merge-bot[bot] 750598d153
Merge pull request #5628 from nalind/lookup-func-aliases
Replace libimage.LookupReferenceFunc with the manifests version
2024-07-16 15:05:15 +00:00
Nalin Dahyabhai b756a3d00c Revert "fix(deps): update github.com/containers/image/v5 to v5.31.1"
This reverts commit 5940e721ca.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 18:12:08 -04:00
Nalin Dahyabhai b1dff416b9 Replace libimage.LookupReferenceFunc with the manifests version
Change fields of the
github.com/containers/common/libimage.LookupReferenceFunc type to be of
the github.com/containers/common/libimage/manifests.LookupReferenceFunc
type. The two types are aliases for each other, but the libimage package
refuses to build when podman is using us as a dependency of its remote
client.

Note that the CachePullSourceLookupReferenceFunc,
CachePullDestinationLookupReferenceFunc,
CachePushSourceLookupReferenceFunc, and
CachePushDestinationLookupReferenceFunc callbacks in define.BuildOptions
aren't currently proxied for podman remote clients.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 16:30:22 -04:00
openshift-merge-bot[bot] 67d5eca276
Merge pull request #5627 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.31.1
2024-07-15 20:00:35 +00:00
openshift-merge-bot[bot] 1cb75cac54
Merge pull request #5604 from nalind/compat-volumes
imagebuildah: make traditional volume handling not the default
2024-07-15 15:43:41 +00:00
Nalin Dahyabhai 9bb25a6daf conformance tests: enable testing CompatVolumes
Add flags for specifying which value of CompatVolumes we set, testing
both with and without it set.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 09:38:28 -04:00
Nalin Dahyabhai 1861c13207 conformance tests: add a test that tries to chown a volume
Add a conformance test that attempts to "chown" a volume declared in a
base image, which produces different results depending on whether we're
using the BuildKit-based builder or the V1 "classic" builder.  For now,
don't try to change our behavior, and continue imitating the behavior of
the classic builder.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 09:38:28 -04:00
Nalin Dahyabhai a7098c776a imagebuildah: make traditional volume handling not the default
Make the traditional handling of volumes (where they're "frozen" and can
only be modified by ADD or COPY, which requires that we cache their
contents and save/restore them before/after RUN instructions) an option
that is not enabled by default.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 09:38:28 -04:00
Nalin Dahyabhai b5eafdf55b StageExecutor.prepare(): mark base image volumes for preservation
While the imagebuilder library will tell us to preserve the contents of
volumes set up by VOLUME instructions during a build, it doesn't do that
for volumes declared in base images, and we weren't previously doing
that ourselves, either.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-07-15 09:38:28 -04:00
renovate[bot] 5940e721ca
fix(deps): update module github.com/containers/image/v5 to v5.31.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-15 11:44:51 +00:00
openshift-merge-bot[bot] 4a82e0a3f3
Merge pull request #5585 from rhatdan/VENDOR
Vendor in latest containers/(common, image, storage)
2024-07-15 11:43:30 +00:00
Daniel J Walsh e2f080554e
Vendor in latest containers/(common, storage, image)
Testing latest changes in common, storage and image ASAP.

Needed to get buildah vendor into Podman to work correctly.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-07-12 09:49:48 -04:00
openshift-merge-bot[bot] 7f38bf9950
Merge pull request #5583 from rhatdan/pull
Change default for podman build to --pull missing
2024-07-12 13:45:59 +00:00
openshift-merge-bot[bot] 16d23f4afb
Merge pull request #5619 from containers/renovate/golang.org-x-term-0.x
fix(deps): update module golang.org/x/term to v0.22.0
2024-07-10 14:29:10 +00:00
renovate[bot] 5d8b53910b
fix(deps): update module golang.org/x/term to v0.22.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-10 10:29:59 +00:00
openshift-merge-bot[bot] e59e5e2868
Merge pull request #5618 from containers/renovate/golang.org-x-sys-0.x
fix(deps): update module golang.org/x/sys to v0.22.0
2024-07-08 14:02:32 +00:00
renovate[bot] b08c9cf1ce
fix(deps): update module golang.org/x/sys to v0.22.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-04 19:53:15 +00:00
openshift-merge-bot[bot] 34bbe47b20
Merge pull request #5612 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to a8846e2
2024-07-01 13:54:20 +00:00
openshift-merge-bot[bot] e646e6cd47
Merge pull request #5613 from containers/renovate/golang.org-x-exp-digest
fix(deps): update golang.org/x/exp digest to 7f521ea
2024-07-01 11:05:20 +00:00
renovate[bot] 2d172d50e9
fix(deps): update golang.org/x/exp digest to 7f521ea
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-01 03:59:18 +00:00
renovate[bot] aa6f75225a
fix(deps): update github.com/containers/luksy digest to a8846e2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-01 01:19:06 +00:00
openshift-merge-bot[bot] dde8d7e96a
Merge pull request #5609 from nalind/extensions
Bump github.com/openshift/imagebuilder from v1.2.10 to v1.2.11
2024-06-26 18:43:37 +00:00
Nalin Dahyabhai d6771f81af imagebuildah.StageExecutor.Copy(): reject new flags for now
Reject the new ADD --keep-git-dir, COPY --parents, and ADD/COPY --link
and ADD/COPY --exclude flags.  The behavior they ask for isn't
implemented (yet), and rejecting the flags outright is far preferable to
quietly ignoring them.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-26 11:30:44 -04:00
Nalin Dahyabhai a63fbba3f8 bump github.com/openshift/imagebuilder to v1.2.11
Bump github.com/openshift/imagebuilder from v1.2.10 to v1.2.11

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-26 11:30:44 -04:00
openshift-merge-bot[bot] 7a950c5718
Merge pull request #5605 from nalind/pull-policy-parsing
Rework parsing of --pull flags
2024-06-24 21:40:53 +00:00
Nalin Dahyabhai 21fb5ea4f2 Rework parsing of --pull flags
Rework parsing of --pull flags to add "newer" as an alias for "ifnewer",
and to reject unrecognized values instead of treating them as synonymous
with "ifmissing".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-24 11:02:12 -04:00
openshift-merge-bot[bot] 9086bc009e
Merge pull request #5601 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.31.1
2024-06-24 14:59:32 +00:00
renovate[bot] feb17a95cd
fix(deps): update module github.com/containers/image/v5 to v5.31.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-21 21:17:21 +00:00
openshift-merge-bot[bot] d50616dce4
Merge pull request #5475 from containers/renovate/github.com-containernetworking-cni-1.x
fix(deps): update module github.com/containernetworking/cni to v1.2.0
2024-06-21 08:37:28 +00:00
openshift-merge-bot[bot] 0094fd4346
Merge pull request #5599 from nalind/log-platform
imagebuildah.StageExecutor.prepare(): log the --platform flag
2024-06-20 21:21:02 +00:00
openshift-merge-bot[bot] 3ab48aa55a
Merge pull request #5596 from nalind/compat-setparent
commit: set "parent" for docker format only when requested
2024-06-20 21:18:15 +00:00
openshift-merge-bot[bot] 7fbd12d642
Merge pull request #5594 from nalind/debug-ensure
Update godoc for Builder.EnsureContainerPathAs
2024-06-20 21:15:30 +00:00
openshift-merge-bot[bot] 41d879323e
Merge pull request #5595 from nalind/from-comment-first
containerImageRef.NewImageSource(): move the FROM comment to first
2024-06-20 21:12:45 +00:00
openshift-merge-bot[bot] 361835da21
Merge pull request #5597 from nalind/preserve
buildah copy: preserve owner info with --from= a container or image
2024-06-20 19:42:00 +00:00
openshift-merge-bot[bot] 93118e2dff
Merge pull request #5591 from containers/renovate/github.com-spf13-cobra-1.x
fix(deps): update module github.com/spf13/cobra to v1.8.1
2024-06-20 19:39:16 +00:00
openshift-merge-bot[bot] 7ac793169a
Merge pull request #5600 from edsantiago/bump-vms
CI VMs: bump
2024-06-20 19:33:45 +00:00
Nalin Dahyabhai d79a36faee imagebuildah.StageExecutor.prepare(): log the --platform flag
If FROM was used with a --platform flag, then the imagebuilder.Builder
will have its Platform field set, and we should include it when logging
the instruction.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-20 13:46:32 -04:00
Ed Santiago 3a35d2fd60 CI VMs: bump
Built in https://github.com/containers/automation_images/pull/361

New docker (26.1.3 -> .4). Seems low-risk aside from that.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-06-20 10:59:56 -06:00
Nalin Dahyabhai 14f19e980b buildah copy: preserve owner info with --from= a container or image
When `buildah copy` is invoked with a `--from` flag, default to
preserving ownerships that were set in the source container or image.
Retain the "set it to 0:0 by default" behavior when `--from` is not
being used.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-18 11:22:21 -04:00
Nalin Dahyabhai bfa84dfcbb conformance tests: enable testing CompatSetParent
Add flags for specifying not just that we use BuildKit, but specifically
which docker builder we request, and which value of CompatSetParent we
set at the same time.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-18 10:15:00 -04:00
Nalin Dahyabhai bfaee577d5 containerImageRef.NewImageSource(): move the FROM comment to first
If we're prepending history entries before the one for "this" commit,
make sure the "FROM $baseimage" comment gets set on the first history
entry that we add, not just the one goes with this (maybe) layer diff.
In layers=false mode, the output was so, so confusing otherwise.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-18 10:03:37 -04:00
Nalin Dahyabhai 66957cc05e commit: set "parent" for docker format only when requested
Make setting the Parent field in the config blob of a docker format
image optional (yes, we're bringing it back!), since it no longer
appears to be set by newer versions of docker build.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-18 09:55:38 -04:00
Nalin Dahyabhai a7224d1674 Update godoc for Builder.EnsureContainerPathAs
Also log a debug message when the method is called.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-18 09:33:31 -04:00
renovate[bot] 75ae17c0fa
fix(deps): update module github.com/spf13/cobra to v1.8.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-14 23:21:57 +00:00
openshift-merge-bot[bot] 4c781b59b4
Merge pull request #5589 from containers/renovate/github.com-opencontainers-runc-1.x
fix(deps): update module github.com/opencontainers/runc to v1.1.13
2024-06-14 15:13:25 +00:00
renovate[bot] a4cdb7879f
fix(deps): update module github.com/containernetworking/cni to v1.2.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-13 20:56:40 +00:00
renovate[bot] 6bef4b71c1
fix(deps): update module github.com/opencontainers/runc to v1.1.13
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-13 19:32:19 +00:00
Daniel J Walsh fe2fd86201
Change default for podman build to --pull missing
This is causing the buildah build --help line to output a strange string

--pull string[="true"] Should be

--pull string[="missing"]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-06-11 15:06:17 -04:00
openshift-merge-bot[bot] 3b02cc0ac8
Merge pull request #5567 from containers/renovate/github.com-containers-common-0.x
fix(deps): update module github.com/containers/common to v0.59.1
2024-06-11 18:51:28 +00:00
renovate[bot] b9c43961a0
fix(deps): update module github.com/containers/common to v0.59.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-11 13:52:46 +00:00
openshift-merge-bot[bot] 9989113144
Merge pull request #5559 from coypoop/netbsd-patches
Add some NetBSD support
2024-06-11 13:51:41 +00:00
openshift-merge-bot[bot] 44ef3a8d08
Merge pull request #5580 from dfr/freebsd-resolv-conf
buildah: fix a nil pointer reference on FreeBSD
2024-06-11 10:34:38 +00:00
openshift-merge-bot[bot] a7bc7b5bc2
Merge pull request #5574 from nalind/common-0.59.1
tests: set _CONTAINERS_USERNS_CONFIGURED=done for libnetwork
2024-06-11 10:31:54 +00:00
openshift-merge-bot[bot] b8148f0543
Merge pull request #5407 from rhatdan/pull
Clarify definition of --pull options
2024-06-11 10:29:10 +00:00
openshift-merge-bot[bot] dd6be38d07
Merge pull request #5566 from nalind/conformance-fixups
Re-enable two conformance tests
2024-06-10 21:22:12 +00:00
Daniel J Walsh 5afd52fd9d
Clarify definition of --pull options
buildah from and buildah build will now default to --pull=missing
as opposed to --pull=always, which they did before. This better
matches to the defaults in docker and podman.

No longer document --pull=true|false

Fixes: https://github.com/containers/buildah/issues/5406

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-06-10 15:58:37 -04:00
Doug Rabson 1480f147fa buildah: fix a nil pointer reference on FreeBSD
When setting up resolv.conf on Linux we need to reference the Linux
namespaces from spec.Linux. This is not needed for FreeBSD and this
change moves the dereference of spec.Linux to addResolvConfEntries and
makes it conditional.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2024-06-09 12:00:05 +01:00
Nalin Dahyabhai 8b0ecd7870 Use /var/tmp for $TMPDIR for vfs conformance jobs
The conformance tests use the default temporary directory for storing
content when running, and the vfs driver easily needs more than the size
of the tmpfs we have on /tmp when we're running conformance tests.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
Nalin Dahyabhai 0569f3728a Cirrus: run `df` during job setup
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
Nalin Dahyabhai 5891afffea conformance: use quay.io/libpod/centos:7 instead of centos:8
Renovate updated references "FROM centos:7" to "FROM centos:8", but we
changed various others references to it to quay.io/libpod/centos:7 some
time ago.  Update these stragglers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
Nalin Dahyabhai 56fb08092e Stop setting "parent" in docker format
Newer docker build doesn't set it, so we need to stop.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
Nalin Dahyabhai ba0947a3d5 conformance: check if workdir trims path separator suffixes
Check "WORKDIR" both with and without path separators at the end of the
instruction argument (e.g. "/foo" and "/foo/").

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
Nalin Dahyabhai 9565585a61 push integration test: pass password to docker login via stdin
Pass the test registry password to `docker login` using stdin instead of
passing it on the command line.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
Nalin Dahyabhai afe1a5dd55 Re-enable the "copy with chown" conformance test
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-07 11:32:12 -04:00
openshift-merge-bot[bot] 41e9f5165c
Merge pull request #5472 from flouthoc/add-start-interval
healthcheck: Add support for `--start-interval` and bump `imagebuilder` to `v1.2.8`
2024-06-07 09:02:31 +00:00
flouthoc f552bd57f4
healthcheck: Add support for `--start-interval`
Docker now supports `--start-interval`, start interval
is the time between health checks during the start period.

Ref: https://docs.docker.com/reference/dockerfile/#healthcheck

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2024-06-06 16:02:25 -07:00
openshift-merge-bot[bot] 79b3acaf53
Merge pull request #5572 from cevich/cross_on_fedora
Cross-build on Fedora
2024-06-06 19:16:58 +00:00
openshift-merge-bot[bot] 18328aad82
Merge pull request #5573 from containers/renovate/github.com-docker-docker-26.x
fix(deps): update module github.com/docker/docker to v26.1.4+incompatible
2024-06-06 18:37:06 +00:00
openshift-merge-bot[bot] aae381cec2
Merge pull request #5571 from containers/renovate/github.com-containerd-containerd-1.x
fix(deps): update module github.com/containerd/containerd to v1.7.18
2024-06-06 18:34:20 +00:00
renovate[bot] 420beb248d
fix(deps): update module github.com/docker/docker to v26.1.4+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-06 16:02:45 +00:00
renovate[bot] a4f32a1422
fix(deps): update module github.com/containerd/containerd to v1.7.18
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-06 16:02:28 +00:00
Nalin Dahyabhai 04e5423aed tests: set _CONTAINERS_USERNS_CONFIGURED=done for libnetwork
Starting in common 0.59.1, github.com/containers/common's libnetwork no
longer attempts to detect when it's running in a user namespace to
decide where a lock file that it uses will be.  Since this test is doing
user namespace setup on its own as part of the test, we need to
explicitly tell it to not use the one that belongs to the node's root
user.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-06 09:38:38 -04:00
openshift-merge-bot[bot] ccc6ecba6c
Merge pull request #5570 from nalind/clone
Drop copyStringSlice() and copyStringStringMap()
2024-06-05 20:30:13 +00:00
Chris Evich a9e5a1496d
Cross-build on Fedora
Executing a golang cross-compile on an expensive resource such as a Mac
has questionable overall value.  Switch to running on a default Fedora
VM instead.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-06-05 15:05:33 -04:00
Nalin Dahyabhai a42019d614 Drop copyStringSlice() and copyStringStringMap()
Use slices.Clone() and maps.Clone() instead of our own non-generic
functions.  We have to be more careful in a couple of places where we
set items in maps which aren't unconditionally initialized.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-06-05 11:01:07 -04:00
openshift-merge-bot[bot] 509b4b5b51
Merge pull request #5568 from containers/renovate/golang.org-x-crypto-0.x
fix(deps): update module golang.org/x/crypto to v0.24.0
2024-06-05 14:41:29 +00:00
renovate[bot] b8c3530cbb
fix(deps): update module golang.org/x/crypto to v0.24.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-04 20:26:43 +00:00
openshift-merge-bot[bot] 63ded6f31b
Merge pull request #5563 from containers/renovate/github.com-openshift-imagebuilder-1.x
fix(deps): update module github.com/openshift/imagebuilder to v1.2.10
2024-06-04 17:07:24 +00:00
renovate[bot] cb302075b5
fix(deps): update module github.com/openshift/imagebuilder to v1.2.10
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-03 22:30:26 +00:00
openshift-merge-bot[bot] 8b4ec1bc08
Merge pull request #5550 from edsantiago/debian-modernize
CI VMs: bump, to debian with cgroups v2
2024-06-03 18:13:18 +00:00
openshift-merge-bot[bot] 08d0c86f78
Merge pull request #5558 from containers/renovate/golang.org-x-exp-digest
fix(deps): update golang.org/x/exp digest to fd00a4e
2024-06-03 14:06:00 +00:00
openshift-merge-bot[bot] e795e68370
Merge pull request #5514 from lsm5/packit-c10s
[skip-ci] Packit: enable c10s downstream sync
2024-06-03 13:24:23 +00:00
Maya Rashish e591844e9c Provide an uptime_netbsd.go
No CLOCK_UPTIME on netbsd, we have to use a sysctl.

Signed-off-by: Maya Rashish <maya@NetBSD.org>
2024-06-01 22:30:36 -04:00
Maya Rashish 30c2e31d8e Spell unix as "!windows"
If it's linux, darwin, and a BSD, it might be easier to write it this
way.

Intended to add support for NetBSD.

Signed-off-by: Maya Rashish <maya@NetBSD.org>
2024-06-01 22:25:47 -04:00
Maya Rashish e47ffc831c Add netbsd to lists-of-OSes
Signed-off-by: Maya Rashish <maya@NetBSD.org>
2024-06-01 22:25:08 -04:00
renovate[bot] 159425c45c
fix(deps): update golang.org/x/exp digest to fd00a4e
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-01 03:38:15 +00:00
Lokesh Mandvekar bf33b9291e
[skip-ci] Packit: enable c10s downstream sync
This commit will enable downstream syncing to CentOS Stream 10. The
centos maintainer will need to manually run `packit propose-downstream`
and `centpkg build` until better centos integration is in place.

This commit also builds both rhel9 and centos9 copr rpms so we can check
for things like differences in golang compiler.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2024-05-31 10:16:55 -04:00
Ed Santiago 7602e9e1d6 CI VMs: bump, to debian with cgroups v2
Per consent in 2024-03-20 Planning, remove support for cgroups v1.
And, per discovery on 2024-05-28, systemd 256 no longer even
boots on a cgroups v1 system.

This commit switches to VMs built in:

  https://github.com/containers/automation_images/pull/338

...in which Debian is now cgroups v2 with crun.

Requires disabling two conformance tests which fail when run
against docker 26.1; see #5526 for context on those.

Also requires disabling two bats tests on debian because
something changed there in ulimits. I'll look into them
later but right now this gives us breathing space.

And, latest git on f40 refuses to serve non-root files when
run as root ("dubious ownership"); so, in start_git_daemon(),
chown the extracted files.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-05-29 10:04:49 -06:00
openshift-merge-bot[bot] 0d7eb12dbe
Merge pull request #5546 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.0
2024-05-28 17:49:10 +00:00
openshift-merge-bot[bot] 9f0f6d783b
Merge pull request #5532 from aaronlehmann/source-dest-lookup-reference-funcs
imagebuildah: Support custom image reference lookup for cache push/pull
2024-05-28 13:32:46 +00:00
openshift-merge-bot[bot] 4877088193
Merge pull request #5538 from cevich/name_conformance_ci_vm
CI: Clarify Debian use for conformance tests
2024-05-28 12:54:13 +00:00
Aaron Lehmann 9521672fdb Document when BlobDirectory is overridden
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2024-05-27 10:50:27 -07:00
openshift-merge-bot[bot] 6ad7efbad3
Merge pull request #5544 from jonahbull/fix-up-env-var-secret-mounts-for-chroot-isolation
fix secret mounts for env vars when using chroot isolation
2024-05-27 12:38:09 +00:00
Jonah Bull 939a58b967
fix secret mounts for env vars when using chroot isolation
Before #5083, when running with chroot isolation ro mounts like secrets
from env vars would explicitly have the unix.MS_NOEXEC, unix.MS_NOSUID
and unix.MS_NODEV flags set when they were remounted. Now when running
with chroot isolation ro mounts like secrets from env vars are not
getting those same flags set and so the remount operation fails.
Specifically it looks like we are missing the unix.MS_NOSUID and
unix.MS_NODEV flags.

This change adds special handling for read-only mounts when we need to do
a remount to try to get the desired flags to stick. If we've requested
a read-only mount (unix.ST_RDONLY is set in requestFlags), then we add any
possibleImportantFlags that are set in fs.Flags to remountFlags so the remount
operation doesn't fail because they are missing. I've also added a test to
bud.bats that covers this case.

Signed-off-by: Jonah Bull <jonah.bull@elastic.co>
2024-05-25 15:49:51 -05:00
Aaron Lehmann 7ff83d5055 Change to take a types.ImageReference arg
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2024-05-24 14:27:09 -07:00
Aaron Lehmann e6c7949aa7 imagebuildah: Support custom image reference lookup for cache push/pull
This allows callers to provide custom SourceLookupReferenceFunc and
DestinationLookupReferenceFunc for cache pull/push. These can be used to
implement custom blob caches, and to wrap the reference being
pushed/pulled to influence the copy behavior.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2024-05-24 14:27:01 -07:00
renovate[bot] a33fda67a8
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-24 15:05:44 +00:00
openshift-merge-bot[bot] bb4c8b0479
Merge pull request #5545 from TomSweeneyRedHat/bump-1.36.0
Bump to Buildah v1.36.0
2024-05-23 23:27:37 +00:00
tomsweeneyredhat f39d5fba25 Bump to v1.37.0-dev
As the title says.  Setting to v1.37.0-dev after
creatings Buildah v1.36.0 for release with Podman v5.1

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-05-23 16:31:33 -04:00
tomsweeneyredhat 6ceba8838d Bump to v1.36.0
[NO TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-05-23 16:31:28 -04:00
openshift-merge-bot[bot] 9b6b2f1db7
Merge pull request #5543 from nalind/5478-redux
build: be more selective about specifying the default OS
2024-05-23 19:03:23 +00:00
openshift-merge-bot[bot] 747ff64086
Merge pull request #5542 from TomSweeneyRedHat/dev/tsweeney/bumpvers
Bump to c/common v0.59.0
2024-05-23 17:02:23 +00:00
Nalin Dahyabhai c09e08b53b build: be more selective about specifying the default OS
Only add the default OS to a build target platform struct if the
architecture was specified without one, so that the pull logic doesn't
override our pull policy when it doesn't need to.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-23 11:46:52 -04:00
tomsweeneyredhat 3fa5531ca5 Bump to c/common v0.59.0
Bump c/common to v0.59.0 to prep for Podman v5.1

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-05-23 10:03:50 -04:00
openshift-merge-bot[bot] fb316cd64d
Merge pull request #5539 from containers/renovate/github.com-containers-image-v5-5.x
fix(deps): update module github.com/containers/image/v5 to v5.31.0
2024-05-22 17:10:15 +00:00
openshift-merge-bot[bot] d5718be7fc
Merge pull request #5534 from naskya/fix/buildah-prune-help-example
Fix buildah prune --help examples
2024-05-22 16:50:58 +00:00
openshift-merge-bot[bot] 1c8ec0bd23
Merge pull request #5537 from edsantiago/fix-broken-podman-tests
bud tests: fix breakage when vendoring into podman
2024-05-22 15:01:02 +00:00
naskya 4d1690bc3a
Fix buildah prune --help showing the same example twice
Signed-off-by: naskya <m@naskya.net>
2024-05-22 23:49:00 +09:00
openshift-merge-bot[bot] 4cb117b886
Merge pull request #5540 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.18.0
2024-05-22 14:39:00 +00:00
renovate[bot] 208b7111e0
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.18.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 11:11:45 +00:00
renovate[bot] c7937cd1d2
fix(deps): update module github.com/containers/image/v5 to v5.31.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-21 23:33:52 +00:00
Chris Evich 671f298701
CI: Clarify Debian use for conformance tests
For many other CI tasks, the platform is included in the name.  For
whatever reason this was never done for the conformance tests and can be
confusing for maintainers.  Make it clear that they are running on
Debian.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-05-21 14:35:13 -04:00
Ed Santiago 183582f030 bud tests: fix breakage when vendoring into podman
1. Difference in error messages, podman does not emit "building
    system context". I think it's OK to just check for the
    "--platform may not be used with" portion.

 2. Very weird: $TESTSDIR (the plural one) was eliminated in April 2022
    but one instance snuck in, probably a PR that was not rebased
    onto main. This is blowing up in podman tests because of course
    there is no $TESTSDIR. But I have **NO IDEA** how this is passing
    in buildah, nor how it passed in podman for two years.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-05-21 06:33:39 -06:00
openshift-merge-bot[bot] 465dbfcdf0
Merge pull request #5495 from nalind/replace-nixery-dev-shell
Integration tests: fake up a replacement for nixery.dev/shell
2024-05-21 10:58:07 +00:00
Nalin Dahyabhai de8510c9db Integration tests: fake up a replacement for nixery.dev/shell
Build a fake layers-but-no-history image that should work more or less
as well for the tests that we were previously using nixery.dev/shell for.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-20 16:48:53 -04:00
openshift-merge-bot[bot] 7f0a322ee5
Merge pull request #5473 from nalind/heredoc-quoting
Don't expand RUN heredocs ourselves, let the shell do it
2024-05-20 20:48:01 +00:00
Nalin Dahyabhai d9191e17cd copierWithSubprocess(): try to capture stderr on io.ErrClosedPipe
When we get a tried-to-write-to-closed-pipe error while encoding
something for a coprocess, try to capture error output from the
coprocess and add it to the error message, to hopefully catch a flake
we're seeing in CI.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-20 09:35:48 -04:00
Nalin Dahyabhai 97382f9288 Don't expand RUN heredocs ourselves, let the shell do it
When handling RUN instructions that use heredoc syntax, don't bother
interpolating environment variables and argument values, and let the
command that's running handle it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-20 09:35:48 -04:00
openshift-merge-bot[bot] b77e43588c
Merge pull request #5527 from rhatdan/build
Don't leak temp files on failures
2024-05-17 09:15:09 +00:00
openshift-merge-bot[bot] f83d2666fb
Merge pull request #5463 from der-eismann/add-release-note-template
Add release note template to split dependency chores
2024-05-16 21:46:23 +00:00
Daniel J Walsh 864a40cbdc
Don't leak temp files on failures
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-05-16 14:11:37 -04:00
openshift-merge-bot[bot] 41710862bf
Merge pull request #5528 from jnovy/specfix
fix CentOS/RHEL build - no BATS there
2024-05-15 20:15:14 +00:00
Philipp Trulson 97d44ab9c4 Add release note template to split dependency chores
Signed-off-by: Philipp Trulson <der-eismann@users.noreply.github.com>
2024-05-15 21:25:35 +02:00
Jindrich Novy 4a524737f5 fix CentOS/RHEL build - no BATS there
Signed-off-by: Jindrich Novy <jnovy@redhat.com>
2024-05-15 14:10:51 +02:00
openshift-merge-bot[bot] b25597170a
Merge pull request #5478 from rhatdan/arch
Setting --arch should set the TARGETARCH build arg
2024-05-15 11:55:28 +00:00
Daniel J Walsh 296e8fbbe7
Merge pull request #5518 from containers/renovate/github.com-containers-luksy-0.x
fix(deps): update module github.com/containers/luksy to v0.0.0-20240506205542-84b50f50f3ee
2024-05-13 11:16:43 -04:00
renovate[bot] 420949a5ae
fix(deps): update module github.com/containers/luksy to v0.0.0-20240506205542-84b50f50f3ee
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-13 14:30:04 +00:00
openshift-merge-bot[bot] 77f239ae12
Merge pull request #5523 from TomSweeneyRedHat/dev/tsweeney/cve-2024-3727-main-try2
Address CVE-2024-3727
2024-05-10 15:02:58 +00:00
tomsweeneyredhat bbab575ff3 Address CVE-2024-3727
Second try Vendor top of tree of c/image and c/common to address CVE-2024-1759

Replaces #5522

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-05-09 19:57:31 -04:00
openshift-merge-bot[bot] 608a375786
Merge pull request #5363 from containers/renovate/github.com-opencontainers-runtime-spec-1.x
chore(deps): update module github.com/opencontainers/runtime-spec to v1.2.0
2024-05-08 14:40:46 +00:00
openshift-merge-bot[bot] 453d2fc109
Merge pull request #5494 from nalind/cdi-dirs
Builder.cdiSetupDevicesInSpecdefConfig(): use configured CDI dirs
2024-05-07 15:23:07 +00:00
renovate[bot] 6a48ae700a
chore(deps): update module github.com/opencontainers/runtime-spec to v1.2.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-07 15:04:16 +00:00
Nalin Dahyabhai d5b2e3c41a Builder.cdiSetupDevicesInSpecdefConfig(): use configured CDI dirs
Use the directories configured in containers.conf, now that
containers/common can tell us what they are, and now that it provides a
place to configure defaults for container tools, always override the
library's default set, even if it's empty, which means we do nothing.

Switch to the default CDI registry instead of the recenty-deprecated
non-global one.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-07 09:19:16 -04:00
Daniel J Walsh da4e2d7ad9 Setting --arch should set the TARGETARCH build arg
Also fix a long standing FIXME in the test framework.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-05-06 19:49:09 -04:00
openshift-merge-bot[bot] fdf2948263
Merge pull request #5516 from containers/renovate/golang.org-x-exp-0.x
fix(deps): update module golang.org/x/exp to v0.0.0-20240416160154-fe59bbe5cc7f
2024-05-06 21:03:55 +00:00
openshift-merge-bot[bot] 1ff9a43f18
Merge pull request #5470 from edsantiago/ci-vm-tmp
CI VMs: bump to new versions with tmpfs /tmp
2024-05-04 12:54:03 +00:00
renovate[bot] 6f1f687c3e
fix(deps): update module golang.org/x/exp to v0.0.0-20240416160154-fe59bbe5cc7f
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-04 12:52:49 +00:00
openshift-merge-bot[bot] 87019bdc44
Merge pull request #5513 from nalind/gotoolchain-renovate
Don't set GOTOOLCHAIN=local
2024-05-04 12:51:19 +00:00
Daniel J Walsh 6ca6116a8d
Merge pull request #5515 from TomSweeneyRedHat/dev/tsweeney/imagelink
Add link to Buildah image page to README.md
2024-05-04 08:49:28 -04:00
tomsweeneyredhat cd19607250 [CI:DOCS] Add link to Buildah image page to README.md
Add a link to the README.md for the Buildah Container Image
that is found in quay.io to the README.md page.

Addresses: #5500

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-05-03 18:04:44 -04:00
openshift-merge-bot[bot] 7921120b72
Merge pull request #5511 from containers/renovate/github.com-cyphar-filepath-securejoin-0.x
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.2.5
2024-05-03 16:55:27 +00:00
Nalin Dahyabhai f6d49125a7 Don't set GOTOOLCHAIN=local
We can't set it all of the time because the renovate bot doesn't allow
us to set this in its configuration unless we're hosting the bot
ourselves, and I don't think that we are.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-03 10:45:56 -04:00
openshift-merge-bot[bot] c917f8dabc
Merge pull request #5497 from nalind/commit-error-reporting
containerImageRef.NewImageSource: merge the tar filters
2024-05-03 11:33:06 +00:00
openshift-merge-bot[bot] 46e2cf4636
Merge pull request #5498 from nalind/gotoolchain
Makefile: set GOTOOLCHAIN=local
2024-05-03 09:34:46 +00:00
renovate[bot] a04741d9f3
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.2.5
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-03 09:32:10 +00:00
Daniel J Walsh 8cce223d05
Merge pull request #5499 from nalind/integration-base-images
Integration tests: switch some base images
2024-05-03 05:31:05 -04:00
Daniel J Walsh 19ea251059
Merge pull request #5505 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.2
2024-05-03 05:30:42 -04:00
Nalin Dahyabhai 53f2dc231b Makefile: set GOTOOLCHAIN=local
Set GOTOOLCHAIN=local for all make targets, and for renovate.

Have the "vendor" target (and by extension, "vendor-in-container", which
our validation in CI uses) clear any "toolchain" directive that might
have been added to go.mod through manual invocations of the compiler.

At this point, we probably don't need to be checking for Go module
support, so switch to assuming it's available.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-02 17:41:25 -04:00
Nalin Dahyabhai e0077e8c67 Integration tests: switch some base images
Replace some of the base images we've been using (particularly centos:8,
which will EOL soon) with other images hosted on quay.io.

We already use registries.conf at test-time to redirect some image
references there, so this will slightly reduce the number of registries
which we need to be able to reach while running these tests.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-02 17:33:41 -04:00
Nalin Dahyabhai fdfd2237d2 containerImageRef.NewImageSource: merge the tar filters
Merge the two tar filters, if we need two, that we use when committing
an image.  Try to improve passing of error information from the writing
end of a pipe to the reader, so that it can be reported better.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-02 17:27:38 -04:00
renovate[bot] f2825bf7b9
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.2
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-02 18:24:27 +00:00
openshift-merge-bot[bot] 0330d43dca
Merge pull request #5502 from containers/renovate/github.com-containers-luksy-0.x
fix(deps): update module github.com/containers/luksy to v0.0.0-20240408185936-afd8e7619947
2024-05-02 18:23:02 +00:00
renovate[bot] 2c1c731692
fix(deps): update module github.com/containers/luksy to v0.0.0-20240408185936-afd8e7619947
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-02 12:19:31 +00:00
openshift-merge-bot[bot] 2227a814d6
Merge pull request #5493 from nalind/disable-rhel-8-packit-builds
Disable packit builds for centos-stream+epel-next-8
2024-05-02 12:18:06 +00:00
Nalin Dahyabhai 7688d880d0 Disable packit builds for centos-stream+epel-next-8
It's no longer an active release for the rhcontainerbot/podman-next COPR
at https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/.

Add "adjustments to .packit.yaml" to the list of things we don't require
updated tests for.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-05-01 10:37:15 -04:00
openshift-merge-bot[bot] 983fa426d0
Merge pull request #5496 from nalind/missing-SOURCES
Makefile: add missing files to $(SOURCES)
2024-04-30 21:56:44 +00:00
Nalin Dahyabhai 7425f6f8f1 Makefile: add missing files to $(SOURCES)
Some source files were not included in $(SOURCES); add them.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-30 15:59:14 -04:00
openshift-merge-bot[bot] 5e46f9c55f
Merge pull request #5437 from cevich/add_golang121_warning
[CI:DOCS] Add golang 1.21 update warning
2024-04-30 19:31:01 +00:00
Ed Santiago fbd2b7db47 CI VMs: bump to new versions with tmpfs /tmp
For the last long time, Fedora CI VMs have had a disk /tmp.
Real-world setups typically have tmpfs /tmp. This switches
to CI VMs that reflect the real world.

See https://github.com/containers/automation_images/pull/340

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-04-30 05:32:42 -06:00
openshift-merge-bot[bot] 3763681506
Merge pull request #5485 from containers/renovate/go-golang.org/x/net-vulnerability
chore(deps): update module golang.org/x/net to v0.23.0 [security]
2024-04-25 17:00:57 +00:00
renovate[bot] 89ee4f4b0c
chore(deps): update module golang.org/x/net to v0.23.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-25 13:08:15 +00:00
openshift-merge-bot[bot] fc18157da3
Merge pull request #5487 from nalind/fedora-minimal-name
integration test: handle new labels in "bud and test --unsetlabel"
2024-04-25 01:24:36 +00:00
Nalin Dahyabhai c01061e472 integration test: handle new labels in "bud and test --unsetlabel"
Instead of assuming which labels are set in our base image, and using
the --unsetlabel flag to suppress them in a derived image, query the
base image and unset all of them, except for our own version label.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-24 17:49:09 -04:00
openshift-merge-bot[bot] dd5c55e0ed
Merge pull request #5484 from nalind/packit-switch-targets
Switch packit configuration to use epel-9-$arch instead of centos-stream+epel-next-9-$arch
2024-04-23 14:36:35 +00:00
Nalin Dahyabhai f86c2748e0 Switch packit configuration to use epel-9-$arch ...
instead of centos-stream+epel-next-9-$arch, mirroring a change which was
just made in https://github.com/containers/podman/pull/22432

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-22 09:35:31 -04:00
openshift-merge-bot[bot] 292afc59ab
Merge pull request #5480 from nalind/prefetch
Integration tests: fixup use of _prefetch
2024-04-22 09:15:23 +00:00
Nalin Dahyabhai 14d964d92f Give unit tests a bit more time
We seem to be running up against the timeout when running the unit tests
in CI.  Give them 90 minutes to complete instead of 60.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-18 13:16:25 -04:00
Nalin Dahyabhai 8bb87aefa0 Integration tests: remove a couple of duplicated tests
Remove a couple of tests which were duplicated as tests which were added
later.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-18 11:27:03 -04:00
Nalin Dahyabhai 3e756d507d Integration tests: whitespace tweaks
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-18 11:27:03 -04:00
Nalin Dahyabhai 8ee7bebd7e Integration tests: don't remove images at start or end of test
Don't bother removing specific images at the beginning or the end of
tests, since we don't carry over the storage used between tests anyway.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-18 11:27:03 -04:00
Nalin Dahyabhai c7f0881422 Integration tests: use cached images more
Attempt to make more thorough use of cached copies of images during
integration tests, except in tests which need to pull a new image while
they're running, either because they test pulling directly, or because
they expect to pull a given image for a non-default platform or for
multiple platforms.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-18 11:27:02 -04:00
Nalin Dahyabhai b213c5e7a1 Integration tests _prefetch: use registry configs
When fetching images in the _prefetch() function, use the same registry
configuration (shortname configuration, registry aliases) that we're
already telling buildah to use when we call it, so that we prefetch from
the locations that buildah would subsequently use if we didn't prefetch.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-17 17:14:04 -04:00
openshift-merge-bot[bot] e393e57728
Merge pull request #5469 from giuseppe/use-faccessat
use containers/storage/pkg/fileutils/(Exists,Lexists)
2024-04-12 11:28:38 +00:00
Giuseppe Scrivano 8bdd6a66d4
internal: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-12 09:58:14 +02:00
Giuseppe Scrivano 441bdc9274
pkg/parse: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-12 09:58:14 +02:00
Giuseppe Scrivano 7053383792
buildah: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-12 09:58:14 +02:00
Giuseppe Scrivano 9dcd1cc9a6
chroot: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-12 09:58:13 +02:00
Giuseppe Scrivano 358814f694
vendor: update containers/(common|storage)
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-12 09:58:13 +02:00
openshift-merge-bot[bot] 392c64a8be
Merge pull request #5466 from cevich/fix_res_inacs_by_int
[skip-ci] Fix issue/pr lock workflow
2024-04-10 09:57:11 +00:00
Chris Evich be74b733fc
Fix issue/pr lock workflow
Followup to https://github.com/containers/podman/pull/22304

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-04-09 16:25:01 -04:00
openshift-merge-bot[bot] dd7c1d5ce8
Merge pull request #5459 from flouthoc/fix-heredoc-copy
heredoc: honor inline `COPY` irrespective of `.containerignore` file
2024-04-09 18:08:21 +00:00
Chris Evich a99fe15134 [CI:DOCS] Add golang 1.21 update warning
This is needed on the off-chance that some tool or a human suggests
updating the minimum version to 1.21 or later. Since doing so would
cause Fedora and Debian to start behaving differently WRT builds.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-04-05 19:44:16 -04:00
flouthoc 77400c4fc2
heredoc: honor inline COPY irrespective of ignorefiles
If we are copying heredoc files, we need to temporary place
them in the context dir and then move to container via copier
there are cases where .containerignore can have a patterns like
which can match our heredoc files so let's not set any excludes
or IgnoreFile for this copy.

Closes: https://github.com/containers/buildah/issues/5391

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2024-04-05 07:55:47 -07:00
Daniel J Walsh 062e6f62ab
Merge pull request #5457 from onlykzy/patch-1
Update install.md
2024-04-04 11:22:14 -04:00
openshift-merge-bot[bot] dc99fbe888
Merge pull request #5454 from flouthoc/digestfile-source
source-push: add support for `--digestfile`
2024-04-03 17:23:19 +00:00
onlykzy ff13a08c9d
Update install.md
Signed-off-by: onlykzy <38772072+onlykzy@users.noreply.github.com>
2024-04-03 20:45:30 +08:00
openshift-merge-bot[bot] 45bbc1fd04
Merge pull request #5445 from aaronlehmann/mount-stage-cache-from
Fix caching when mounting a cached stage with COPY/ADD
2024-04-03 11:58:47 +00:00
flouthoc 5b414ad08f
source-push: add support for --digestfile
Allow writing digest of the pushed source to the specified `digestfile`

Closes: https://github.com/containers/buildah/issues/5399

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2024-04-02 15:13:52 -07:00
Aaron Lehmann d9129b463d Fix caching when mounting a cached stage with COPY/ADD
A comment states that avoidLookingCache is set when a previous stage
that executed as part of the build is referenced by --mount, to avoid
reusing content from an older build of the stage:

    // Only attempt to find cache if its needed, this part
    // so that if a step is using RUN --mount and mounts
    // previous stages then it uses the freshly built stage
    // of re-using the older stage from the store.

However, stages consisting of COPY/ADD seem to be flagged with
didExecute even if they were fetched from cache instead. I believe
this is an oversight, and these stages should not prevent subsequent
caching.

Also, avoidLookingCache would prevent a cache push, but I think it
should only prevent cache lookups, since populating the cache is still
useful in these caess.

It's very possible I'm misunderstanding something, but I believe the
RUN step in test case I've added wrongly skips cache, and I'd appreciate
some pointers in the right direction if what I've proposed here isn't
the right solution.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2024-04-02 12:57:58 -07:00
openshift-merge-bot[bot] cb2e044848
Merge pull request #5446 from rahilarious/softcode-strip
Makefile: softcode `strip`, use it from env var
2024-04-01 15:55:32 +00:00
openshift-merge-bot[bot] 1ad7511d26
Merge pull request #5430 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.1
2024-04-01 15:41:47 +00:00
openshift-merge-bot[bot] f9a84a2454
Merge pull request #5447 from containers/renovate/github.com-containers-luksy-digest
fix(deps): update github.com/containers/luksy digest to 3d2cf0e
2024-04-01 15:39:03 +00:00
openshift-merge-bot[bot] f8cdb7dc2f
Merge pull request #5443 from nalind/cdi
Add support for passing CDI specs to --device
2024-04-01 15:36:19 +00:00
renovate[bot] 58579ba656
fix(deps): update github.com/containers/luksy digest to 3d2cf0e
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-01 04:48:39 +00:00
Rahil Bhimjiani 2cd31a0698
Makefile: softcode `strip`, use it from env var
Signed-off-by: Rahil Bhimjiani <me@rahil.rocks>
2024-04-01 09:25:21 +05:30
Nalin Dahyabhai f812c89496 Man page updates
Describe --device in `buildah from` and `buildah run`, where it's new.
Update the description of --device in `buildah build` to note that the
device nodes are only there while RUN instructions are being run, and
not to imply that they end up in the finished image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-29 16:57:11 -04:00
Nalin Dahyabhai 5198af7d7c Add support for passing CDI specs to --device
Add support for using CDI to resolve `--device` devices for RUN
instructions during `buildah build`, `buildah from`, and `buildah run`,
as `podman run` does.

This generally requires that we stop resolving device specifications
(arguments passed to --device) earlier and deferring that until it's
time to run a process, because CDI wants to pick over those values,
modify a runtime spec to set up the ones that it knows about, and then
hand back the list of values that it doesn't know about.

We don't want to do a dry run of this during CLI processing because that
would create a window where the underlying hardware state could change,
and that could produce some hard-to-diagnose errors.

Being able to test this is going to require that we add the `--device`
flag to `buildah run` (`--security-opt` affects how we build the
container's layer, so it has to be done at `buildah from`).

The default configured devices list is pulled in by CLI flag processing
during `buildah from` and `buildah build`, so it doesn't also need to be
explicitly passed to `buildah run` or the internal Run() method.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-29 16:57:10 -04:00
Nalin Dahyabhai 14bf3db27a Update comments on some API objects
Avoid generically referring to "the container" where it can be ambiguous
that we're actually talking about the environment we set up for running
a command for a RUN instruction or Run() call.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-28 17:24:38 -04:00
Nalin Dahyabhai 2a7ff9905e pkg/parse.DeviceFromPath(): dereference src symlinks
When the passed-in source location is a symbolic link, dereference it,
because the documentation says that's what we do.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-28 17:24:38 -04:00
openshift-merge-bot[bot] 39ea15cedd
Merge pull request #5436 from rahilarious/main
Makefile - instead of calling `as` directly, use it from env var
2024-03-27 21:17:16 +00:00
Rahil Bhimjiani c1b43b57bb
Makefile - instead of calling `as` directly, use it from env var
Signed-off-by: Rahil Bhimjiani <me@rahil.rocks>
2024-03-27 14:33:52 +05:30
renovate[bot] 23b8d9767a
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-24 15:19:34 +00:00
openshift-merge-bot[bot] e3c8c0e649
Merge pull request #5426 from edsantiago/new-vms
CI: bump VMs
2024-03-21 07:13:43 +00:00
Ed Santiago c1119f8865 CI: bump VMs
* pasta 2024-03-20 on all Fedoras
* crun 1.14.4 everywhere

See https://github.com/containers/automation_images/pull/337#issuecomment-2010128930

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-03-20 14:03:03 -06:00
openshift-merge-bot[bot] 8afe75dd5c
Merge pull request #5418 from containers/renovate/github.com-docker-docker-25.x
fix(deps): update module github.com/docker/docker to v25.0.5+incompatible
2024-03-20 05:32:38 +00:00
openshift-merge-bot[bot] dffd83424a
Merge pull request #5412 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.0
2024-03-20 05:30:04 +00:00
renovate[bot] 2c47fdccd7
fix(deps): update module github.com/docker/docker to v25.0.5+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-19 22:11:24 +00:00
openshift-merge-bot[bot] cab0e936bd
Merge pull request #5415 from TomSweeneyRedHat/dev/tsweeney/addcomment1
Change RUN to comment in bud.bats
2024-03-19 09:17:13 +00:00
openshift-merge-bot[bot] 07fb7d7c18
Merge pull request #5414 from cevich/slow_down_renovate
[CI:DOCS] Stop rebasing renovate PRs automatically
2024-03-18 21:43:52 +00:00
renovate[bot] f95b7a1884
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-18 19:27:58 +00:00
tomsweeneyredhat 9cf83d8f8d Change RUN to comment in bud.bats
Just before merging #5411, a comment was made
about changing a RUN command to a comment.  This
completes that.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-18 15:27:27 -04:00
Daniel J Walsh e64e6cc09d
Merge pull request #5411 from TomSweeneyRedHat/dev/tsweeney/cve-main
CVE-2024-1753 container escape fix
2024-03-18 15:24:59 -04:00
Chris Evich 5808b96033
Stop rebasing renovate PRs automatically
Whenever a PR's target branch moves, Renovate was reconfigured to rebase
all of it's PRs and re-run CI.  This is annoying for developers, stop
it.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-03-18 15:24:49 -04:00
Chris Evich 37994356f8
Update renovate validation image
The one from github's container registry won't hit docker rate-limits.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-03-18 15:23:35 -04:00
tomsweeneyredhat 4304d618f3 CVE-2024-1753 container escape fix
Addresses CVE-2024-1753 which allowed a user to write files to the
`/` directory of the host machine if selinux was not enabled.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-18 15:21:53 -04:00
openshift-merge-bot[bot] e51411590d
Merge pull request #5409 from Luap99/pasta-result
fix /etc/hosts and resolv.conf setup with network configs
2024-03-18 19:20:55 +00:00
openshift-merge-bot[bot] ccde5d569f
Merge pull request #5402 from Pvlerick/build-doc-link-fix
fix links to containerignore doc
2024-03-18 13:42:39 +00:00
Paul Holzinger 516f9e9a24
correctly configure /etc/hosts and resolv.conf when using network
Previously buildah may have created a incorrect hosts/resolv.conf file,
when netavark, slirp4netns or pasta are used we have to actually
consider their special setup and use the correct nameservers.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-18 14:38:01 +01:00
Paul Holzinger 9db5a16f7d
buildah: refactor resolv/hosts setup.
We should never configure the files before we setup the network as we
are missing a lot of information. This is part 1 of the refactor where
we split the functions between create/add entries part. See the
following commit to actualy see how me make use of this.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-18 14:37:32 +01:00
Paul Holzinger 8c1fee7e75
rename the hostFile var to reflect the value better
I got confused a bit there so make it clearer to readers that both are
different.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-18 14:37:32 +01:00
Paul Holzinger f8a7841cc0
vendor latest c/common
Includes new pasta functionality.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-18 14:37:19 +01:00
openshift-merge-bot[bot] 0b11148f27
Merge pull request #5410 from lsm5/vendored-provides
[skip-ci] rpm: use go-rpm-macros supported vendoring
2024-03-18 13:20:39 +00:00
Lokesh Mandvekar 26da74d54e
[skip-ci] rpm: use go-rpm-macros supported vendoring
This removes the need for any `Provides: bundled()` we needed in spec
files.

The updated Provides will be visible in the build logs and can also be
verified with `rpm -q --provides $RPM_FILE`.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2024-03-18 17:24:55 +05:30
Philippe Vlérick 547d9bf0e5
Update docs/buildah-add.1.md
Co-authored-by: Tom Sweeney <tsweeney@redhat.com>
Signed-off-by: Philippe Vlérick <pvlerick@gmail.com>
2024-03-18 08:23:50 +01:00
openshift-merge-bot[bot] 1acd44390f
Merge pull request #5377 from containers/renovate/github.com-onsi-ginkgo-v2-2.x
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.16.0
2024-03-17 12:38:14 +00:00
renovate[bot] 80f9f7cb08
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.16.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-16 14:51:41 +00:00
Daniel J Walsh 6bac78ff65
Merge pull request #5396 from containers/renovate/go-gopkg.in/go-jose/go-jose.v2-vulnerability
chore(deps): update module gopkg.in/go-jose/go-jose.v2 to v2.6.3 [security]
2024-03-16 10:46:39 -04:00
Daniel J Walsh eb03dd439e
Merge pull request #5397 from containers/renovate/github.com-containers-ocicrypt-1.x
fix(deps): update module github.com/containers/ocicrypt to v1.1.10
2024-03-16 10:46:22 -04:00
Daniel J Walsh ca01f9f234
Merge pull request #5387 from containers/renovate/github.com-docker-docker-25.x
fix(deps): update module github.com/docker/docker to v25.0.4+incompatible
2024-03-16 10:45:58 -04:00
renovate[bot] 5cf05ac082
fix(deps): update module github.com/docker/docker to v25.0.4+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-16 11:44:50 +00:00
renovate[bot] c355679d36
fix(deps): update module github.com/containers/ocicrypt to v1.1.10
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-16 11:44:30 +00:00
renovate[bot] 5501399166
chore(deps): update module gopkg.in/go-jose/go-jose.v2 to v2.6.3 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-16 11:43:42 +00:00
openshift-merge-bot[bot] 3f2d5fc013
Merge pull request #5388 from lsm5/makefile-rpm-update
[skip-ci] Makefile: update rpm target
2024-03-16 11:42:13 +00:00
openshift-merge-bot[bot] 0b1bd5f30b
Merge pull request #5395 from containers/renovate/go-github.com/go-jose/go-jose/v3-vulnerability
chore(deps): update module github.com/go-jose/go-jose/v3 to v3.0.3 [security]
2024-03-16 11:36:43 +00:00
renovate[bot] 1a6d3513fb
chore(deps): update module github.com/go-jose/go-jose/v3 to v3.0.3 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-15 22:26:52 +00:00
openshift-merge-bot[bot] 80b7ac6fa1
Merge pull request #5404 from TomSweeneyRedHat/dev/tsweeney/protobuff_133
Bump google.golang.org/protobuf to v1.33.0
2024-03-15 22:24:44 +00:00
openshift-merge-bot[bot] 0bcfaa14b3
Merge pull request #5374 from edsantiago/no-tests-via-label
pr-should-include-tests: use GitHub label, not commit text
2024-03-15 22:22:10 +00:00
tomsweeneyredhat bf3263ec11 Bump google.golang.org/protobuf to v1.33.0
Bump as noted.  This addresses CVE-2024-24786

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-15 12:02:14 -04:00
Philippe Vlérick e635558d2a fix links to containerignore doc
Signed-off-by: Philippe Vlérick <pvlerick@gmail.com>
2024-03-14 11:07:47 +01:00
Lokesh Mandvekar e53e50f7a1
[skip-ci] Makefile: update rpm target
rpkg is now deprecated. This commit makes the rpm target consistent with
the one in Podman.

Using skip-ci as we don't need to run cirrus tests for this change.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2024-03-13 19:36:45 +05:30
openshift-merge-bot[bot] 77ce7545aa
Merge pull request #5381 from Luap99/pasta
tests: enable pasta tests
2024-03-13 10:15:57 +00:00
Ed Santiago 87ef84d3a4 pr-should-include-tests: use GitHub label, not commit text
...to allow bypassing the check. Just like on podman.

Also, bring up to code:
  - grep -F, not fgrep
  - fix regression test script (was using wrong branch envariable)
  - add new test case

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-03-12 17:23:03 -04:00
Paul Holzinger d50122aeb2
tests: enable pasta tests
This should have been done a long time ago and this would have made
clear that it did not work properly. However now that pasta is the
default and we fixed all the remaining problems we can easily enable
them.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-12 11:53:06 +01:00
openshift-merge-bot[bot] 1e8e9351e5
Merge pull request #5384 from cevich/move_buildahimage
[CI:DOCS] Migrate buildah container image
2024-03-11 18:04:15 +00:00
Chris Evich 1bc5dd6921
[CI:DOCS] Migrate buildah container image
Moved to: https://github.com/containers/image_build

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-03-11 09:53:42 -04:00
openshift-merge-bot[bot] 5599d34fa7
Merge pull request #5389 from mtrmac/gitignore-entrypoint
Update .gitignore
2024-03-07 16:59:55 +00:00
Miloslav Trmač 7c88bb3728 Update .gitignore
... to match the changes in 3b795dd4bc .

Compare the discussion in https://github.com/containers/buildah/pull/5385 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-07 14:01:19 +01:00
openshift-merge-bot[bot] 1589b0a6ae
Merge pull request #5385 from TomSweeneyRedHat/dev/tsweeney/v1.35.0
Bump c/* projects, Buildah to v1.35.0 and then to v1.36.0-dev
2024-03-07 12:31:47 +00:00
tomsweeneyredhat da81d2e2b4 Bump to v1.36.0-dev
As the title says.  Bumping back to the next dev
version.

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-06 23:47:45 -05:00
6634 changed files with 189155 additions and 1173468 deletions

View File

@ -9,6 +9,7 @@ env:
DEST_BRANCH: "main"
GOPATH: "/var/tmp/go"
GOSRC: "${GOPATH}/src/github.com/containers/buildah"
GOCACHE: "/tmp/go-build"
# Overrides default location (/tmp/cirrus) for repo clone
CIRRUS_WORKING_DIR: "${GOSRC}"
# Shell used to execute all script commands
@ -21,18 +22,20 @@ env:
IN_PODMAN: 'false'
# root or rootless
PRIV_NAME: root
# default "mention the $BUILDAH_RUNTIME in the task alias, with initial whitespace" value
RUNTIME_N: ""
####
#### Cache-image names to test with
####
# GCE project where images live
IMAGE_PROJECT: "libpod-218412"
FEDORA_NAME: "fedora-39"
PRIOR_FEDORA_NAME: "fedora-38"
FEDORA_NAME: "fedora-42"
PRIOR_FEDORA_NAME: "fedora-41"
DEBIAN_NAME: "debian-13"
# Image identifiers
IMAGE_SUFFIX: "c20240222t143004z-f39f38d13"
IMAGE_SUFFIX: "c20250422t130822z-f42f41d13"
FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}"
PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}"
DEBIAN_CACHE_IMAGE_NAME: "debian-${IMAGE_SUFFIX}"
@ -49,14 +52,14 @@ env:
gcp_credentials: ENCRYPTED[ae0bf7370f0b6e446bc61d0865a2c55d3e166b3fab9466eb0393e38e1c66a31ca4c71ddc7e0139d47d075c36dd6d3fd7]
# Default timeout for each task
timeout_in: 120m
timeout_in: 30m
# Default VM to use unless set or modified by task
gce_instance: &standardvm
image_project: "${IMAGE_PROJECT}"
zone: "us-central1-c" # Required by Cirrus for the time being
cpu: 2
memory: "4Gb"
memory: "4G"
disk: 200 # Gigabytes, do not set less than 200 per obscure GCE docs re: I/O performance
image_name: "${FEDORA_CACHE_IMAGE_NAME}"
@ -69,7 +72,7 @@ meta_task:
container:
image: "quay.io/libpod/imgts:latest"
cpu: 1
memory: 1
memory: "1G"
env:
# Space-separated list of images used by this repository state
@ -93,12 +96,13 @@ smoke_task:
name: "Smoke Test"
gce_instance:
memory: "12Gb"
memory: "12G"
cpu: 8
# Don't bother running on branches (including cron), or for tags.
only_if: $CIRRUS_PR != ''
skip: $CIRRUS_PR == ''
timeout_in: 30m
timeout_in: 10m
setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
build_script: '${SCRIPT_BASE}/build.sh |& ${_TIMESTAMP}'
@ -120,13 +124,14 @@ vendor_task:
# Runs within Cirrus's "community cluster"
container:
image: docker.io/library/golang:latest
image: docker.io/library/golang:1.23.3
cpu: 1
memory: 1
timeout_in: 5m
vendor_script:
- './hack/check_vendor_toolchain.sh Try updating the image used by the vendor_task in .cirrus.yml.'
- 'make vendor'
- './hack/tree_status.sh'
@ -134,37 +139,32 @@ vendor_task:
# Confirm cross-compile ALL architectures on a Mac OS-X VM.
cross_build_task:
name: "Cross Compile"
gce_instance:
cpu: 8
memory: "24G"
alias: cross_build
only_if: >-
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
osx_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
skip: >-
$CIRRUS_CHANGE_TITLE =~ '.*CI:DOCS.*'
env:
HOME: /root
script:
- brew update
- brew install go
- brew install go-md2man
- brew install gpgme
- go version
- make cross CGO_ENABLED=0
- make -j cross CGO_ENABLED=0
binary_artifacts:
path: ./bin/*
unit_task:
name: 'Unit tests w/ $STORAGE_DRIVER'
gce_instance:
cpu: 4
alias: unit
only_if: &not_build_docs >-
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*'
depends_on: &smoke_vendor_cross
skip: &not_build_docs >-
$CIRRUS_CHANGE_TITLE =~ '.*CI:DOCS.*' ||
$CIRRUS_CHANGE_TITLE =~ '.*CI:BUILD.*'
depends_on: &smoke_vendor
- smoke
- vendor
- cross_build
timeout_in: 1h
matrix:
- env:
@ -173,27 +173,23 @@ unit_task:
STORAGE_DRIVER: 'overlay'
setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
build_script: '${SCRIPT_BASE}/build.sh |& ${_TIMESTAMP}'
unit_test_script: '${SCRIPT_BASE}/test.sh unit |& ${_TIMESTAMP}'
binary_artifacts:
path: ./bin/*
conformance_task:
name: 'Build Conformance w/ $STORAGE_DRIVER'
name: 'Debian Conformance w/ $STORAGE_DRIVER'
alias: conformance
only_if: *not_build_docs
depends_on: *smoke_vendor_cross
skip: *not_build_docs
depends_on: *smoke_vendor
gce_instance:
cpu: 4
image_name: "${DEBIAN_CACHE_IMAGE_NAME}"
timeout_in: 65m
matrix:
- env:
STORAGE_DRIVER: 'vfs'
TMPDIR: '/var/tmp'
- env:
STORAGE_DRIVER: 'overlay'
@ -202,10 +198,10 @@ conformance_task:
integration_task:
name: "Integration $DISTRO_NV w/ $STORAGE_DRIVER"
name: "Integration $DISTRO_NV$RUNTIME_N w/ $STORAGE_DRIVER"
alias: integration
only_if: *not_build_docs
depends_on: *smoke_vendor_cross
skip: *not_build_docs
depends_on: *smoke_vendor
matrix:
# VFS
@ -213,32 +209,64 @@ integration_task:
DISTRO_NV: "${FEDORA_NAME}"
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'vfs'
BUILDAH_RUNTIME: crun
RUNTIME_N: " using crun"
- env:
DISTRO_NV: "${FEDORA_NAME}"
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'vfs'
BUILDAH_RUNTIME: runc
RUNTIME_N: " using runc"
- env:
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'vfs'
BUILDAH_RUNTIME: crun
RUNTIME_N: " using crun"
- env:
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'vfs'
BUILDAH_RUNTIME: runc
RUNTIME_N: " using runc"
- env:
DISTRO_NV: "${DEBIAN_NAME}"
IMAGE_NAME: "${DEBIAN_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'vfs'
CI_DESIRED_RUNTIME: runc
# OVERLAY
- env:
DISTRO_NV: "${FEDORA_NAME}"
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
BUILDAH_RUNTIME: crun
RUNTIME_N: " using crun"
- env:
DISTRO_NV: "${FEDORA_NAME}"
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
BUILDAH_RUNTIME: runc
RUNTIME_N: " using runc"
- env:
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
BUILDAH_RUNTIME: crun
RUNTIME_N: " using crun"
- env:
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
BUILDAH_RUNTIME: runc
RUNTIME_N: " using runc"
- env:
DISTRO_NV: "${DEBIAN_NAME}"
IMAGE_NAME: "${DEBIAN_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
CI_DESIRED_RUNTIME: runc
gce_instance:
image_name: "$IMAGE_NAME"
cpu: 8
memory: "8G"
# Separate scripts for separate outputs, makes debugging easier.
setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
@ -259,10 +287,10 @@ integration_task:
golang_version_script: '$GOSRC/$SCRIPT_BASE/logcollector.sh golang'
integration_rootless_task:
name: "Integration rootless $DISTRO_NV w/ $STORAGE_DRIVER"
name: "Integration rootless $DISTRO_NV$RUNTIME_N w/ $STORAGE_DRIVER"
alias: integration_rootless
only_if: *not_build_docs
depends_on: *smoke_vendor_cross
skip: *not_build_docs
depends_on: *smoke_vendor
matrix:
# Running rootless tests on overlay
@ -272,11 +300,29 @@ integration_rootless_task:
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
PRIV_NAME: rootless
BUILDAH_RUNTIME: runc
RUNTIME_N: " using runc"
- env:
DISTRO_NV: "${FEDORA_NAME}"
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
PRIV_NAME: rootless
BUILDAH_RUNTIME: crun
RUNTIME_N: " using crun"
- env:
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
PRIV_NAME: rootless
BUILDAH_RUNTIME: runc
RUNTIME_N: " using runc"
- env:
DISTRO_NV: "${PRIOR_FEDORA_NAME}"
IMAGE_NAME: "${PRIOR_FEDORA_CACHE_IMAGE_NAME}"
STORAGE_DRIVER: 'overlay'
PRIV_NAME: rootless
BUILDAH_RUNTIME: crun
RUNTIME_N: " using crun"
- env:
DISTRO_NV: "${DEBIAN_NAME}"
IMAGE_NAME: "${DEBIAN_CACHE_IMAGE_NAME}"
@ -285,6 +331,8 @@ integration_rootless_task:
gce_instance:
image_name: "$IMAGE_NAME"
cpu: 8
memory: "8G"
# Separate scripts for separate outputs, makes debugging easier.
setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
@ -300,8 +348,12 @@ integration_rootless_task:
in_podman_task:
name: "Containerized Integration"
alias: in_podman
only_if: *not_build_docs
depends_on: *smoke_vendor_cross
skip: *not_build_docs
depends_on: *smoke_vendor
gce_instance:
cpu: 8
memory: "8G"
env:
# This is key, cause the scripts to re-execute themselves inside a container.
@ -338,6 +390,7 @@ success_task:
- vendor
- cross_build
- integration
- integration_rootless
- in_podman
container:

3
.codespellrc Normal file
View File

@ -0,0 +1,3 @@
[codespell]
skip = ./vendor,./.git,./go.sum,./docs/*.1,./docker/AUTHORS,./CHANGELOG.md,./changelog.txt,./tests/tools/vendor,./tests/tools/go.mod,./tests/tools/go.sum
ignore-words-list = fo,passt,secon,erro

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

View File

@ -1,71 +0,0 @@
<!--
If you are reporting a new issue, make sure that we do not have any duplicates
already open. You can ensure this by searching the issue list for this
repository. If there is a duplicate, please close your issue and add a comment
to the existing issue instead.
If you suspect your issue is a bug, please edit your issue description to
include the BUG REPORT INFORMATION shown below. If you fail to provide this
information within 7 days, we cannot debug your issue and will close it. We
will, however, reopen it if you later provide the information.
---------------------------------------------------
BUG REPORT INFORMATION
---------------------------------------------------
Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->
**Description**
<!--
Briefly describe the problem you are having in a few paragraphs.
-->
**Steps to reproduce the issue:**
1.
2.
3.
**Describe the results you received:**
**Describe the results you expected:**
**Output of `rpm -q buildah` or `apt list buildah`:**
```
(paste your output here)
```
**Output of `buildah version`:**
```
(paste your output here)
```
**Output of `podman version` if reporting a `podman build` issue:**
```
(paste your output here)
```
**Output of `cat /etc/*release`:**
```
(paste your output here)
```
**Output of `uname -a`:**
```
(paste your output here)
```
**Output of `cat /etc/containers/storage.conf`:**
```
(paste your output here)
```

View File

@ -0,0 +1,99 @@
---
name: Buildah Bug Report
description: File a Buildah bug report
labels: ["kind/bug", "triage-needed"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
**NOTE** A large number of issues reported against Buildah are often found to already be fixed in more current versions of the project.
Before reporting an issue, please verify the version you are running with `buildah version` and compare it to the latest released version under
[releases](https://github.com/containers/buildah/releases).
If they differ, please update your version of Buildah to the latest possible and retry your command before creating an issue.
Commands you might need to run to create the issue
$ `buildah version`
$ `buildah info`
$ `rpm -q buildah` or `apt list buildah`
- type: textarea
id: description
attributes:
label: Issue Description
description: Please explain your issue
value: "Describe your issue"
validations:
required: true
- type: textarea
id: reproducer
attributes:
label: Steps to reproduce the issue
description: Please explain the steps to reproduce the issue
value: "Steps to reproduce the issue\n1.\n2.\n3.\n"
validations:
required: true
- type: textarea
id: received_results
attributes:
label: Describe the results you received
description: Please explain the results you are noticing
value: "Describe the results you received"
validations:
required: true
- type: textarea
id: expected_results
attributes:
label: Describe the results you expected
description: Please explain the results you are expecting
value: "Describe the results you expected"
validations:
required: true
- type: textarea
id: buildah_version
attributes:
label: buildah version output
description: Please copy and paste `buildah version` output.
value: If you are unable to run `buildah version` for any reason, please provide the output of `rpm -q buildah` or `apt list buildah`.
render: yaml
validations:
required: true
- type: textarea
id: buildah_info
attributes:
label: buildah info output
description: Please copy and paste `buildah info` output.
value: If you are unable to run `buildah info` for any reason, please provide the operating system and its version and the architecture you are running.
render: yaml
validations:
required: true
- type: textarea
id: storage_conf
attributes:
label: Provide your storage.conf
description: "Please provide the relevant [storage.conf file](https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md#files)"
render: toml
validations:
required: true
- type: dropdown
id: upstream_latest
attributes:
label: Upstream Latest Release
description: Have you tried running the [latest upstream release](https://github.com/containers/buildah/releases/latest)
options:
- "Yes"
- "No"
validations:
required: true
- type: textarea
id: additional_environment
attributes:
label: Additional environment details
description: Please describe any additional environment details like (AWS, VirtualBox,...)
value: "Additional environment details"
- type: textarea
id: additional_info
attributes:
label: Additional information
description: Please explain the additional information you deem important
value: "Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting"

11
.github/ISSUE_TEMPLATE/config.yaml vendored Normal file
View File

@ -0,0 +1,11 @@
---
blank_issues_enabled: true
contact_links:
- name: Ask a question
url: https://github.com/containers/buildah/discussions/new
about: Ask a question about Buildah
- name:
If your issue is a general Podman issue unrelated to `podman build`, please open an issue in the Podman repository.
If the issue is with the `podman build` command, please report it here.
url: https://github.com/containers/podman/issues
about: Please report issues with Podman here.

View File

@ -0,0 +1,133 @@
---
name: Podman Build Bug Report
description: File a Podman build bug report
labels: ["kind/bug", "triage-needed"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
**NOTE** A large number of issues reported against Buildah are often found to already be fixed in more current versions of the project.
Before reporting an issue, please verify the version you are running with `podman version` and compare it to the latest released version under
[releases](https://github.com/containers/podman/releases).
If they differ, please update your version of Podman to the latest possible and retry your command before creating an issue.
Commands you might need to run to create the issue
$ `podman version`
$ `podman info`
$ `rpm -q podman` or `apt list podman`
- type: textarea
id: description
attributes:
label: Issue Description
description: Please explain your issue
value: "Describe your issue"
validations:
required: true
- type: textarea
id: reproducer
attributes:
label: Steps to reproduce the issue
description: Please explain the steps to reproduce the issue
value: "Steps to reproduce the issue\n1.\n2.\n3.\n"
validations:
required: true
- type: textarea
id: received_results
attributes:
label: Describe the results you received
description: Please explain the results you are noticing
value: "Describe the results you received"
validations:
required: true
- type: textarea
id: expected_results
attributes:
label: Describe the results you expected
description: Please explain the results you are expecting
value: "Describe the results you expected"
validations:
required: true
- type: textarea
id: podman_version
attributes:
label: podman version output
description: Please copy and paste `podman version` output.
value: If you are unable to run `podman version` for any reason, please provide the output of `rpm -q podman` or `apt list podman`.
render: yaml
validations:
required: true
- type: textarea
id: podman_info
attributes:
label: podman info output
description: Please copy and paste `podman info` output.
value: If you are unable to run `podman info` for any reason, please provide the operating system and its version and the architecture you are running.
render: yaml
validations:
required: true
- type: textarea
id: storage_conf
attributes:
label: Provide your storage.conf
description: "Please provide the relevant [storage.conf file](https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md#files)"
render: toml
validations:
required: true
- type: dropdown
id: podman_in_a_container
attributes:
label: Podman in a container
description: Please select Yes if you are running Podman in a container
options:
- "No"
- "Yes"
validations:
required: true
- type: dropdown
id: privileged_rootless
attributes:
label: Privileged Or Rootless
description:
Are you running the containers as privileged or non-root user? Note that using `su` or `sudo` does not establish a proper login session required for running
Podman as a non-root user. Please refer to the [troubleshooting guide](https://github.com/containers/podman/blob/main/troubleshooting.md#solution-28) for alternatives.
options:
- Privileged
- Rootless
- type: dropdown
id: upstream_latest
attributes:
label: Upstream Latest Release
description: Have you tried running the [latest upstream release](https://github.com/containers/podman/releases/latest)
options:
- "Yes"
- "No"
validations:
required: true
- type: dropdown
id: installation_source
attributes:
label: Installation Source
description: What installion type did you use?
multiple: false
options:
- Distribution package (DNF, apt, yay)
- Brew
- Offical Podman Installer (Mac)
- Podman Desktop
default: 0
validations:
required: true
- type: textarea
id: additional_environment
attributes:
label: Additional environment details
description: Please describe any additional environment details like (AWS, VirtualBox,...)
value: "Additional environment details"
- type: textarea
id: additional_info
attributes:
label: Additional information
description: Please explain the additional information you deem important
value: "Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting"

13
.github/release.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
changelog:
categories:
- title: Notable changes
labels:
- '*'
exclude:
labels:
- dependencies
- title: Dependency updates
labels:
- dependencies

View File

@ -12,7 +12,7 @@
podman run -it \
-v ./.github/renovate.json5:/usr/src/app/renovate.json5:z \
docker.io/renovate/renovate:latest \
ghcr.io/renovatebot/renovate:latest \
renovate-config-validator
3. Commit.
@ -42,10 +42,6 @@
"github>containers/automation//renovate/defaults.json5"
],
// Permit automatic rebasing when base-branch changes by more than
// one commit.
"rebaseWhen": "behind-base-branch",
/*************************************************
*** Repository-specific configuration options ***
*************************************************/
@ -58,6 +54,5 @@
"**/docs/**",
"**/examples/**",
"**/tests/**"
],
]
}

View File

@ -17,4 +17,9 @@ jobs:
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
call_cron_failures:
uses: containers/podman/.github/workflows/check_cirrus_cron.yml@main
secrets: inherit
secrets:
SECRET_CIRRUS_API_KEY: ${{secrets.SECRET_CIRRUS_API_KEY}}
ACTION_MAIL_SERVER: ${{secrets.ACTION_MAIL_SERVER}}
ACTION_MAIL_USERNAME: ${{secrets.ACTION_MAIL_USERNAME}}
ACTION_MAIL_PASSWORD: ${{secrets.ACTION_MAIL_PASSWORD}}
ACTION_MAIL_SENDER: ${{secrets.ACTION_MAIL_SENDER}}

View File

@ -1,20 +0,0 @@
---
# See also:
# https://github.com/containers/podman/blob/main/.github/workflows/discussion_lock.yml
on:
schedule:
- cron: '0 0 * * *'
# Debug: Allow triggering job manually in github-actions WebUI
workflow_dispatch: {}
jobs:
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
closed_issue_discussion_lock:
uses: containers/podman/.github/workflows/discussion_lock.yml@main
secrets: inherit
permissions:
contents: read
issues: write
pull-requests: write

20
.github/workflows/issue_pr_lock.yml vendored Normal file
View File

@ -0,0 +1,20 @@
---
# See also:
# https://github.com/containers/podman/blob/main/.github/workflows/issue_pr_lock.yml
on:
schedule:
- cron: '0 0 * * *'
# Debug: Allow triggering job manually in github-actions WebUI
workflow_dispatch: {}
jobs:
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
closed_issue_discussion_lock:
uses: containers/podman/.github/workflows/issue_pr_lock.yml@main
secrets: inherit
permissions:
contents: read
issues: write
pull-requests: write

View File

@ -4,7 +4,7 @@ on:
jobs:
commit:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
# Only check commits on pull requests.
if: github.event_name == 'pull_request'
steps:

View File

@ -1,19 +0,0 @@
---
# See also: https://github.com/containers/podman/blob/main/.github/workflows/rerun_cirrus_cron.yml
on:
# Note: This only applies to the default branch.
schedule:
# N/B: This should correspond to a period slightly after
# the last job finishes running. See job defs. at:
# https://cirrus-ci.com/settings/repository/6706677464432640
- cron: '01 01 * * 1-5'
# Debug: Allow triggering job manually in github-actions WebUI
workflow_dispatch: {}
jobs:
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
call_cron_rerun:
uses: containers/podman/.github/workflows/rerun_cirrus_cron.yml@main
secrets: inherit

4
.gitignore vendored
View File

@ -10,5 +10,5 @@ Dockerfile*
!/tests/conformance/**/Dockerfile*
*.swp
/result/
internal/mkcw/embed/entrypoint.o
internal/mkcw/embed/entrypoint
internal/mkcw/embed/entrypoint_amd64.o
internal/mkcw/embed/entrypoint_amd64

View File

@ -1,13 +1,29 @@
---
version: "2"
run:
build-tags:
- apparmor
- seccomp
- selinux
# Don't exceed number of threads available when running under CI
concurrency: 4
formatters:
enable:
- gofumpt
linters:
enable:
- nolintlint
- revive
- unconvert
- unparam
- unused
- whitespace
exclusions:
presets:
- comments
- std-error-handling
settings:
staticcheck:
checks:
- all
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.

View File

@ -2,53 +2,148 @@
# See the documentation for more information:
# https://packit.dev/docs/configuration/
specfile_path: rpm/buildah.spec
downstream_package_name: buildah
upstream_tag_template: v{version}
# These files get synced from upstream to downstream (Fedora / CentOS Stream) on every
# propose-downstream job. This is done so tests maintained upstream can be run
# downstream in Zuul CI and Bodhi.
# Ref: https://packit.dev/docs/configuration#files_to_sync
files_to_sync:
- src: rpm/gating.yaml
dest: gating.yaml
delete: true
- src: plans/
dest: plans/
delete: true
mkpath: true
- src: tests/tmt/
dest: tests/tmt/
delete: true
mkpath: true
- src: .fmf/
dest: .fmf/
delete: true
- .packit.yaml
packages:
buildah-fedora:
pkg_tool: fedpkg
specfile_path: rpm/buildah.spec
buildah-centos:
pkg_tool: centpkg
specfile_path: rpm/buildah.spec
buildah-eln:
specfile_path: rpm/buildah.spec
srpm_build_deps:
- make
jobs:
- job: copr_build
trigger: pull_request
notifications:
packages: [buildah-fedora]
notifications: &copr_build_failure_notification
failure_comment:
message: "Ephemeral COPR build failed. @containers/packit-build please check."
enable_net: true
targets:
# Fedora aliases documentation: https://packit.dev/docs/configuration#aliases
# python3-fedora-distro-aliases provides `resolve-fedora-aliases` command
targets: &fedora_copr_targets
- fedora-all-x86_64
- fedora-all-aarch64
- fedora-eln-x86_64
- fedora-eln-aarch64
- centos-stream+epel-next-8-x86_64
- centos-stream+epel-next-8-aarch64
- centos-stream+epel-next-9-x86_64
- centos-stream+epel-next-9-aarch64
additional_repos:
- "copr://rhcontainerbot/podman-next"
enable_net: true
# Disable osh diff scan until Go support is available
# Ref: https://github.com/openscanhub/known-false-positives/pull/30#issuecomment-2858698495
osh_diff_scan_after_copr_build: false
# Ignore until golang is updated in distro buildroot to 1.23.3+
- job: copr_build
trigger: ignore
packages: [buildah-eln]
notifications: *copr_build_failure_notification
targets:
fedora-eln-x86_64:
additional_repos:
- "https://kojipkgs.fedoraproject.org/repos/eln-build/latest/x86_64/"
fedora-eln-aarch64:
additional_repos:
- "https://kojipkgs.fedoraproject.org/repos/eln-build/latest/aarch64/"
enable_net: true
# Ignore until golang is updated in distro buildroot to 1.23.3+
- job: copr_build
trigger: ignore
packages: [buildah-centos]
notifications: *copr_build_failure_notification
targets: &centos_copr_targets
- centos-stream-9-x86_64
- centos-stream-9-aarch64
- centos-stream-10-x86_64
- centos-stream-10-aarch64
enable_net: true
# Run on commit to main branch
- job: copr_build
trigger: commit
packages: [buildah-fedora]
notifications:
failure_comment:
message: "podman-next COPR build failed. @containers/packit-build please check."
branch: main
owner: rhcontainerbot
project: podman-next
enable_net: true
# Tests on Fedora for main branch PRs
- job: tests
trigger: pull_request
packages: [buildah-fedora]
targets:
- fedora-all-x86_64
tf_extra_params:
environments:
- artifacts:
- type: repository-file
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
# Ignore until golang is updated in distro buildroot to 1.23.3+
# Tests on CentOS Stream for main branch PRs
- job: tests
trigger: ignore
packages: [buildah-centos]
targets:
- centos-stream-9-x86_64
- centos-stream-10-x86_64
tf_extra_params:
environments:
- artifacts:
- type: repository-file
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
# Sync to Fedora
- job: propose_downstream
trigger: release
packages: [buildah-fedora]
update_release: false
dist_git_branches: &fedora_targets
- fedora-all
# Sync to CentOS Stream
- job: propose_downstream
trigger: release
packages: [buildah-centos]
update_release: false
dist_git_branches:
- fedora-all
- c10s
# Fedora Koji build
- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all
- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-branched # rawhide updates are created automatically
packages: [buildah-fedora]
sidetag_group: podman-releases
# Dependents are not rpm dependencies, but the package whose bodhi update
# should include this package.
# Ref: https://packit.dev/docs/fedora-releases-guide/releasing-multiple-packages
dependents:
- podman
dist_git_branches: *fedora_targets

View File

@ -2,6 +2,478 @@
# Changelog
## v1.40.0 (2025-04-17)
Bump c/storage to v1.58.0, c/image v5.35.0, c/common v0.63.0
fix(deps): update module github.com/docker/docker to v28.1.0+incompatible
fix(deps): update module github.com/containers/storage to v1.58.0
cirrus: make Total Success wait for rootless integration
chroot: use symbolic names when complaining about mount() errors
cli: hide the `completion` command instead of disabling it outright
Document rw and src options for --mount flag in buildah-run(1)
fix(deps): update module github.com/moby/buildkit to v0.21.0
build: add support for inherit-labels
chore(deps): update dependency golangci/golangci-lint to v2.1.0
.github: check_cirrus_cron work around github bug
stage_executor,getCreatedBy: expand buildArgs for sources correctly
Add a link to project governance and MAINTAINERS file
fix(deps): update github.com/containers/storage digest to b1d1b45
generateHostname: simplify
Use maps.Copy
Use slices.Concat
Use slices.Clone
Use slices.Contains
Use for range over integers
tests/testreport: don't copy os.Environ
Use any instead of interface{}
ci: add golangci-lint run with --tests=false
ci: add nolintlint, fix found issues
copier: rm nolint:unparam annotation
.golangci.yml: add unused linter
chroot: fix unused warnings
copier: fix unused warnings
tests/conformance: fix unused warning
ci: switch to golangci-lint v2
internal/mkcw: disable ST1003 warnings
tests/conformance: do not double import (fix ST1019)
cmd/buildah: don't double import (fix ST1019)
Do not capitalize error strings
cmd/buildah: do not capitalize error strings
tests/conformance: fix QF1012 warnings
tests/serve: fix QF1012 warning
Use strings.ReplaceAll to fix QF1004 warnings
Use switch to fix QF1003 warnings
Apply De Morgan's law to fix QF1001 warnings
Fix QF1007 staticcheck warnings
imagebuildah: fix revive warning
Rename max variable
tests/tools: install lint from binary, use renovate
fix(deps): update module github.com/containernetworking/cni to v1.3.0
Update Buildah issue template to new version and support podman build
fix(deps): update module golang.org/x/crypto to v0.37.0
stage_executor: reset platform in systemcontext for stages
fix(deps): update github.com/opencontainers/runtime-tools digest to 260e151
cmd/buildah: rm unused containerOutputUsingTemplate
cmd/buildah: rm unused getDateAndDigestAndSize
build: return ExecErrorCodeGeneric when git operation fails
add: report error while creating dir for URL source.
createPlatformContainer: drop MS_REMOUNT|MS_BIND
fix(deps): update module github.com/docker/docker to v28.0.3+incompatible
fix: bats won't fail on ! without cleverness
feat: use HistoryTimestamp, if set, for oci-archive entries
Allow extendedGlob to work with Windows paths
fix(deps): update module github.com/moby/buildkit to v0.20.2
fix(deps): update github.com/openshift/imagebuilder digest to e87e4e1
fix(deps): update module github.com/docker/docker to v28.0.2+incompatible
fix(deps): update module tags.cncf.io/container-device-interface to v1.0.1
chore(deps): update dependency containers/automation_images to v20250324
vendor: update github.com/opencontainers/selinux to v1.12.0
replace deprecated selinux/label calls
vendor: bump c/common to dbeb17e40c80
Use builtin arg defaults from imagebuilder
linux: accept unmask paths as glob values
vendor: update containers/common
Add --parents option for COPY in Dockerfiles
fix(deps): update module github.com/opencontainers/runc to v1.2.6
update go.sum from the previous commit
fix(deps): update module tags.cncf.io/container-device-interface to v1
chore(deps): update module golang.org/x/net to v0.36.0 [security]
packit: remove f40 from copr builds
cirrus: update to go 1.23 image
vendor bump to golang.org/x/crypto v0.36.0
cirrus: update PRIOR_FEDORA comment
github: remove cirrus rerun action
fix(deps): update module github.com/containers/common to v0.62.2
fix(deps): update module github.com/containers/image/v5 to v5.34.2
fix: close files properly when BuildDockerfiles exits
fix(deps): update module github.com/containers/storage to v1.57.2
stage_executor: history should include heredoc summary correctly
fix(deps): update module github.com/containers/common to v0.62.1
github: disable cron rerun action
fix(deps): update module github.com/moby/buildkit to v0.20.1
internal/mkcw.Archive(): use github.com/containers/storage/pkg/ioutils
[skip-ci] TMT: system tests
buildah-build.1.md: secret examples
fix(deps): update github.com/containers/luksy digest to 40bd943
fix(deps): update module github.com/opencontainers/image-spec to v1.1.1
fix(deps): update module github.com/containers/image/v5 to v5.34.1
Use UnparsedInstance.Manifest instead of ImageSource.GetManifest
fix(deps): update module github.com/opencontainers/runtime-spec to v1.2.1
tests/conformance/testdata/Dockerfile.add: update some URLs
Vendor imagebuilder
Fix source of OS, architecture and variant
chore(deps): update module github.com/go-jose/go-jose/v4 to v4.0.5 [security]
fix(deps): update module tags.cncf.io/container-device-interface to v0.8.1
fix(deps): update module github.com/moby/buildkit to v0.20.0
chroot createPlatformContainer: use MS_REMOUNT
conformance: make TestCommit and TestConformance parallel
cirrus: reduce task timeout
mkcw: mkcw_check_image use bats run_with_log
test: use /tmp as TMPDIR
heredoc: create temp subdirs for each build
test: heredoc remove python dependency from test
Support the containers.conf container_name_as_hostname option
fix(deps): update module github.com/opencontainers/runc to v1.2.5
fix(deps): update module github.com/spf13/cobra to v1.9.0
.cirrus: use more cores for smoke
Switch to the CNCF Code of Conduct
.cirrus: bump ci resources
fix(deps): update module golang.org/x/crypto to v0.33.0
Distinguish --mount=type=cache locations by ownership, too
fix(deps): update module golang.org/x/term to v0.29.0
.cirrus: run -race only on non-PR branch
unit: deparallize some tests
.cirrus: use multiple cpu for unit tests
Makefile: use -parallel for go test
unit_test: use Parallel test where possible
Update module golang.org/x/sys to v0.30.0
Update module golang.org/x/sync to v0.11.0
Update dependency containers/automation_images to v20250131
Bump to Buildah v1.40.0-dev
## v1.39.0 (2025-01-31)
Bump c/storage v1.57.1, c/image 5.34.0, c/common v0.62.0
Update module github.com/containers/storage to v1.57.0
CI, .cirrus: parallelize containerized integration
ed's comment: cleanup
use seperate blobinfocache for flaky test
bump CI VMs to 4 CPUs (was: 2) for integration tests
cleanup, debug, and disable parallel in blobcache tests
bats tests - parallelize
pkg/overlay: cleanups
RPM: include check section to silence rpmlint
RPM: use default gobuild macro on RHEL
tests: remove masked /sys/dev/block check
vendor to latest c/{common,image,storage}
build, run: record hash or digest in image history
Accept image names as sources for cache mounts
Run(): always clean up options.ExternalImageMounts
refactor: replace golang.org/x/exp with stdlib
Update to c/image @main
fix broken doc link
run_freebsd.go: only import runtime-spec once
fix(deps): update module github.com/docker/docker to v27.5.1+incompatible
bump github.com/vbatts/tar-split
Add more checks to the --mount flag parsing logic
chroot mount flags integration test: copy binaries
fix(deps): update module github.com/moby/buildkit to v0.19.0
relabel(): correct a misleading parameter name
Fix TOCTOU error when bind and cache mounts use "src" values
define.TempDirForURL(): always use an intermediate subdirectory
internal/volume.GetBindMount(): discard writes in bind mounts
pkg/overlay: add a MountLabel flag to Options
pkg/overlay: add a ForceMount flag to Options
Add internal/volumes.bindFromChroot()
Add an internal/open package
fix(deps): update module github.com/containers/common to v0.61.1
fix(deps): update module github.com/containers/image/v5 to v5.33.1
[CI:DOCS] Touch up changelogs
fix(deps): update module github.com/docker/docker to v27.5.0+incompatible
copy-preserving-extended-attributes: use a different base image
fix(deps): update github.com/containers/luksy digest to a3a812d
chore(deps): update module golang.org/x/net to v0.33.0 [security]
fix(deps): update module golang.org/x/crypto to v0.32.0
New VM Images
fix(deps): update module github.com/opencontainers/runc to v1.2.4
fix(deps): update module github.com/docker/docker to v27.4.1+incompatible
fix(deps): update module github.com/containers/ocicrypt to v1.2.1
Add support for --security-opt mask and unmask
Allow cache mounts to be stages or additional build contexts
[skip-ci] RPM: cleanup changelog conditionals
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.6
fix(deps): update module github.com/moby/buildkit to v0.18.2
Fix an error message in the chroot unit test
copier: use .PAXRecords instead of .Xattrs
chroot: on Linux, try to pivot_root before falling back to chroot
manifest add: add --artifact-annotation
Add context to an error message
Update module golang.org/x/crypto to v0.31.0
Update module github.com/opencontainers/runc to v1.2.3
Update module github.com/docker/docker to v27.4.0+incompatible
Update module github.com/cyphar/filepath-securejoin to v0.3.5
CI: don't build a binary in the unit tests task
CI: use /tmp for $GOCACHE
CI: remove dependencies on the cross-build task
CI: run cross-compile task with make -j
Update module github.com/docker/docker to v27.4.0-rc.4+incompatible
Update module github.com/moby/buildkit to v0.18.1
Update module golang.org/x/crypto to v0.30.0
Update golang.org/x/exp digest to 2d47ceb
Update github.com/opencontainers/runtime-tools digest to f7e3563
[skip-ci] Packit: remove rhel copr build jobs
[skip-ci] Packit: switch to fedora-all for copr
Update module github.com/stretchr/testify to v1.10.0
Update module github.com/moby/buildkit to v0.17.2
Makefile: use `find` to detect source files
Tests: make _prefetch() parallel-safe
Update module github.com/opencontainers/runc to v1.2.2
executor: allow to specify --no-pivot-root
Update module github.com/moby/sys/capability to v0.4.0
Makefile: mv codespell config to .codespellrc
Fix some codespell errors
Makefile,install.md: rm gopath stuff
Makefile: rm targets working on ..
build: rm exclude_graphdriver_devicemapper tag
Makefile: rm unused var
Finish updating to go 1.22
CI VMs: bump again
Bump to Buidah v1.39.0-dev
stage_executor: set avoidLookingCache only if mounting stage
imagebuildah: additionalContext is not a local built stage
## v1.38.0 (2024-11-08)
Bump to c/common v0.61.0, c/image v5.33.0, c/storage v1.56.0
fix(deps): update module golang.org/x/crypto to v0.29.0
fix(deps): update module github.com/moby/buildkit to v0.17.1
fix(deps): update module github.com/containers/storage to v1.56.0
tests: skip two ulimit tests
CI VMs: bump f40 -> f41
tests/tools: rebuild tools when we change versions
tests/tools: update golangci-lint to v1.61.0
fix(deps): update module github.com/moby/buildkit to v0.17.0
Handle RUN --mount with relative targets and no configured workdir
tests: bud: make parallel-safe
fix(deps): update module github.com/opencontainers/runc to v1.2.1
fix(deps): update golang.org/x/exp digest to f66d83c
fix(deps): update github.com/opencontainers/runtime-tools digest to 6c9570a
tests: blobcache: use unique image name
tests: sbom: never write to cwd
tests: mkcw: bug fixes, refactor
deps: bump runc to v1.2.0
deps: switch to moby/sys/userns
tests/test_runner.sh: remove some redundancies
Integration tests: run git daemon on a random-but-bind()able port
fix(deps): update module github.com/opencontainers/selinux to v1.11.1
go.mod: remove unnecessary replace
Document more buildah build --secret options
Add support for COPY --exclude and ADD --exclude options
fix(deps): update github.com/containers/luksy digest to e2530d6
chore(deps): update dependency containers/automation_images to v20241010
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.4
Properly validate cache IDs and sources
[skip-ci] Packit: constrain koji job to fedora package to avoid dupes
Audit and tidy OWNERS
fix(deps): update module golang.org/x/crypto to v0.28.0
tests: add quotes to names
vendor: update c/common to latest
CVE-2024-9407: validate "bind-propagation" flag settings
vendor: switch to moby/sys/capability
Don't set ambient capabilities
Document that zstd:chunked is downgraded to zstd when encrypting
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.3
buildah-manifest-create.1: Fix manpage section
chore(deps): update dependency ubuntu to v24
Make `buildah manifest push --all` true by default
chroot: add newlines at the end of printed error messages
Do not error on trying to write IMA xattr as rootless
fix: remove duplicate conditions
fix(deps): update module github.com/moby/buildkit to v0.16.0
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.2
Document how entrypoint is configured in buildah config
In a container, try to register binfmt_misc
imagebuildah.StageExecutor: clean up volumes/volumeCache
build: fall back to parsing a TARGETPLATFORM build-arg
`manifest add --artifact`: handle multiple values
Packit: split out ELN jobs and reuse fedora downstream targets
Packit: Enable sidetags for bodhi updates
fix(deps): update module github.com/docker/docker to v27.2.1+incompatible
tests/bud.bats: add git source
add: add support for git source
Add support for the new c/common pasta options
vendor latest c/common
fix(deps): update module golang.org/x/term to v0.24.0
fix(deps): update module github.com/fsouza/go-dockerclient to v1.12.0
packit: update fedora and epel targets
cirrus: disable f39 testing
cirrus: fix fedora names
update to go 1.22
Vendor c/common:9d025e4cb348
copier: handle globbing with "**" path components
fix(deps): update golang.org/x/exp digest to 9b4947d
fix(deps): update github.com/containers/luksy digest to 2e7307c
imagebuildah: make scratch config handling toggleable
fix(deps): update module github.com/docker/docker to v27.2.0+incompatible
Add a validation script for Makefile $(SOURCES)
fix(deps): update module github.com/openshift/imagebuilder to v1.2.15
New VMs
Update some godocs, use 0o to prefix an octal in a comment
buildah-build.1.md: expand the --layer-label description
fix(deps): update module github.com/containers/common to v0.60.2
run: fix a nil pointer dereference on FreeBSD
CI: enable the whitespace linter
Fix some govet linter warnings
Commit(): retry committing to local storage on storage.LayerUnknown
CI: enable the gofumpt linter
conformance: move weirdly-named files out of the repository
fix(deps): update module github.com/docker/docker to v27.1.2+incompatible
fix(deps): update module github.com/containers/common to v0.60.1
*: use gofmt -s, add gofmt linter
*: fix build tags
fix(deps): update module github.com/containers/image/v5 to v5.32.1
Add(): re-escape any globbed items that included escapes
conformance tests: use mirror.gcr.io for most images
unit tests: use test-specific policy.json and registries.conf
fix(deps): update module golang.org/x/sys to v0.24.0
Update to spun-out "github.com/containerd/platforms"
Bump github.com/containerd/containerd
test/tools/Makefile: duplicate the vendor-in-container target
linters: unchecked error
linters: don't end loop iterations with "else" when "then" would
linters: unused arguments shouldn't have names
linters: rename checkIdsGreaterThan5() to checkIDsGreaterThan5()
linters: don't name variables "cap"
`make lint`: use --timeout instead of --deadline
Drop the e2e test suite
fix(deps): update module golang.org/x/crypto to v0.26.0
fix(deps): update module github.com/onsi/gomega to v1.34.1
`make vendor-in-container`: use the caller's Go cache if it exists
fix(deps): fix test/tools ginkgo typo
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.1
Update to keep up with API changes in storage
fix(deps): update github.com/containers/luksy digest to 1f482a9
install: On Debian/Ubuntu, add installation of libbtrfs-dev
fix(deps): update module golang.org/x/sys to v0.23.0
fix(deps): update golang.org/x/exp digest to 8a7402a
fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.2
Use Epoch: 2 and respect the epoch in dependencies.
Bump to Buildah v1.38.0-dev
AddAndCopyOptions: add CertPath, InsecureSkipTLSVerify, Retry fields
Add PrependedLinkedLayers/AppendedLinkedLayers to CommitOptions
integration tests: teach starthttpd() about TLS and pid files
## v1.37.0 (2024-07-26)
Bump c/storage, c/image, c/common for v1.37.0
"build with basename resolving user arg" tests: correct ARG use
bud-multiple-platform-no-run test: correct ARG use
imagebuildah: always have default values for $TARGET... args ready
bump github.com/openshift/imagebuilder to v1.2.14
fix(deps): update module github.com/docker/docker to v27.1.1+incompatible
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.1
fix(deps): update module github.com/docker/docker to v27.1.0+incompatible
CI: use local registry, part 2 of 2
CI: use local registry, part 1 of 2
fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.1
Revert "fix(deps): update github.com/containers/image/v5 to v5.31.1"
Replace libimage.LookupReferenceFunc with the manifests version
conformance tests: enable testing CompatVolumes
conformance tests: add a test that tries to chown a volume
imagebuildah: make traditional volume handling not the default
StageExecutor.prepare(): mark base image volumes for preservation
fix(deps): update module github.com/containers/image/v5 to v5.31.1
Vendor in latest containers/(common, storage, image)
fix(deps): update module golang.org/x/term to v0.22.0
fix(deps): update module golang.org/x/sys to v0.22.0
fix(deps): update golang.org/x/exp digest to 7f521ea
fix(deps): update github.com/containers/luksy digest to a8846e2
imagebuildah.StageExecutor.Copy(): reject new flags for now
bump github.com/openshift/imagebuilder to v1.2.11
Rework parsing of --pull flags
fix(deps): update module github.com/containers/image/v5 to v5.31.1
imagebuildah.StageExecutor.prepare(): log the --platform flag
CI VMs: bump
buildah copy: preserve owner info with --from= a container or image
conformance tests: enable testing CompatSetParent
containerImageRef.NewImageSource(): move the FROM comment to first
commit: set "parent" for docker format only when requested
Update godoc for Builder.EnsureContainerPathAs
fix(deps): update module github.com/spf13/cobra to v1.8.1
fix(deps): update module github.com/containernetworking/cni to v1.2.0
fix(deps): update module github.com/opencontainers/runc to v1.1.13
Change default for podman build to --pull missing
fix(deps): update module github.com/containers/common to v0.59.1
Clarify definition of --pull options
buildah: fix a nil pointer reference on FreeBSD
Use /var/tmp for $TMPDIR for vfs conformance jobs
Cirrus: run `df` during job setup
conformance: use quay.io/libpod/centos:7 instead of centos:8
Stop setting "parent" in docker format
conformance: check if workdir trims path separator suffixes
push integration test: pass password to docker login via stdin
Re-enable the "copy with chown" conformance test
healthcheck: Add support for `--start-interval`
fix(deps): update module github.com/docker/docker to v26.1.4+incompatible
fix(deps): update module github.com/containerd/containerd to v1.7.18
tests: set _CONTAINERS_USERNS_CONFIGURED=done for libnetwork
Cross-build on Fedora
Drop copyStringSlice() and copyStringStringMap()
fix(deps): update module golang.org/x/crypto to v0.24.0
fix(deps): update module github.com/openshift/imagebuilder to v1.2.10
Provide an uptime_netbsd.go
Spell unix as "!windows"
Add netbsd to lists-of-OSes
fix(deps): update golang.org/x/exp digest to fd00a4e
[skip-ci] Packit: enable c10s downstream sync
CI VMs: bump, to debian with cgroups v2
Document when BlobDirectory is overridden
fix secret mounts for env vars when using chroot isolation
Change to take a types.ImageReference arg
imagebuildah: Support custom image reference lookup for cache push/pull
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.0
Bump to v1.37.0-dev
CI: Clarify Debian use for conformance tests
## v1.36.0 (2024-05-23)
build: be more selective about specifying the default OS
Bump to c/common v0.59.0
Fix buildah prune --help showing the same example twice
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.18.0
fix(deps): update module github.com/containers/image/v5 to v5.31.0
bud tests: fix breakage when vendoring into podman
Integration tests: fake up a replacement for nixery.dev/shell
copierWithSubprocess(): try to capture stderr on io.ErrClosedPipe
Don't expand RUN heredocs ourselves, let the shell do it
Don't leak temp files on failures
Add release note template to split dependency chores
fix CentOS/RHEL build - no BATS there
fix(deps): update module github.com/containers/luksy to v0.0.0-20240506205542-84b50f50f3ee
Address CVE-2024-3727
chore(deps): update module github.com/opencontainers/runtime-spec to v1.2.0
Builder.cdiSetupDevicesInSpecdefConfig(): use configured CDI dirs
Setting --arch should set the TARGETARCH build arg
fix(deps): update module golang.org/x/exp to v0.0.0-20240416160154-fe59bbe5cc7f
[CI:DOCS] Add link to Buildah image page to README.md
Don't set GOTOOLCHAIN=local
fix(deps): update module github.com/cyphar/filepath-securejoin to v0.2.5
Makefile: set GOTOOLCHAIN=local
Integration tests: switch some base images
containerImageRef.NewImageSource: merge the tar filters
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.2
fix(deps): update module github.com/containers/luksy to v0.0.0-20240408185936-afd8e7619947
Disable packit builds for centos-stream+epel-next-8
Makefile: add missing files to $(SOURCES)
CI VMs: bump to new versions with tmpfs /tmp
chore(deps): update module golang.org/x/net to v0.23.0 [security]
integration test: handle new labels in "bud and test --unsetlabel"
Switch packit configuration to use epel-9-$arch ...
Give unit tests a bit more time
Integration tests: remove a couple of duplicated tests
Integration tests: whitespace tweaks
Integration tests: don't remove images at start or end of test
Integration tests: use cached images more
Integration tests _prefetch: use registry configs
internal: use fileutils.(Le|E)xists
pkg/parse: use fileutils.(Le|E)xists
buildah: use fileutils.(Le|E)xists
chroot: use fileutils.(Le|E)xists
vendor: update containers/(common|storage)
Fix issue/pr lock workflow
[CI:DOCS] Add golang 1.21 update warning
heredoc: honor inline COPY irrespective of ignorefiles
Update install.md
source-push: add support for --digestfile
Fix caching when mounting a cached stage with COPY/ADD
fix(deps): update github.com/containers/luksy digest to 3d2cf0e
Makefile: softcode `strip`, use it from env var
Man page updates
Add support for passing CDI specs to --device
Update comments on some API objects
pkg/parse.DeviceFromPath(): dereference src symlinks
fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.1
## v1.35.0 (2024-03-06)
fix(deps): update module github.com/stretchr/testify to v1.9.0

View File

@ -1,3 +1,3 @@
## The Buildah Project Community Code of Conduct
The Buildah Project follows the [Containers Community Code of Conduct](https://github.com/containers/common/blob/main/CODE-OF-CONDUCT.md).
The Buildah Project, as part of Podman Container Tools, follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).

View File

@ -173,5 +173,5 @@ Normally, a maintainer will only be removed if they are considered to be
inactive for a long period of time or are viewed as disruptive to the community.
The current list of maintainers can be found in the
[MAINTAINERS](MAINTAINERS) file.
[MAINTAINERS](./MAINTAINERS.md) file.

12
GOVERNANCE.md Normal file
View File

@ -0,0 +1,12 @@
## The Buildah Project Community Governance
The Buildah project, as part of Podman Container Tools, follows the [Podman Project Governance](https://github.com/containers/podman/blob/main/GOVERNANCE.md)
except sections found in this document, which override those found in Podman's Governance.
---
# Maintainers File
The definitive source of truth for maintainers of this repository is the local [MAINTAINERS.md](./MAINTAINERS.md) file. The [MAINTAINERS.md](https://github.com/containers/podman/blob/main/MAINTAINERS.md) file in the main Podman repository is used for project-spanning roles, including Core Maintainer and Community Manager. Some repositories in the project will also have a local [OWNERS](./OWNERS) file, which the CI system uses to map users to roles. Any changes to the [OWNERS](./OWNERS) file must make a corresponding change to the [MAINTAINERS.md](./MAINTAINERS.md) file to ensure that the file remains up to date. Most changes to [MAINTAINERS.md](./MAINTAINERS.md) will require a change to the repositorys [OWNERS](.OWNERS) file (e.g., adding a Reviewer), but some will not (e.g., promoting a Maintainer to a Core Maintainer, which comes with no additional CI-related privileges).
Any Core Maintainers listed in Podmans [MAINTAINERS.md](https://github.com/containers/podman/blob/main/MAINTAINERS.md) file should also be added to the list of “approvers” in the local [OWNERS](./OWNERS) file and as a Core Maintainer in the list of “Maintainers” in the local [MAINTAINERS.md](./MAINTAINERS.md) file.

View File

@ -1,4 +0,0 @@
Dan Walsh <dwalsh@redhat.com> (@rhatdan)
Nalin Dahyabhai <nalin@redhat.com> (@nalind)
Tom Sweeney <tsweeney@redhat.com> (@tomsweeneyredhat)
Urvashi Mohnani <umohnani@redhat.com> (@umohnani8)

35
MAINTAINERS.md Normal file
View File

@ -0,0 +1,35 @@
# Buildah Maintainers
[GOVERNANCE.md](GOVERNANCE.md)
describes the project's governance and the Project Roles used below.
## Maintainers
| Maintainer | GitHub ID | Project Roles | Affiliation |
|-------------------|----------------------------------------------------------|----------------------------------|----------------------------------------------|
| Brent Baude | [baude](https://github.com/baude) | Core Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Nalin Dahyabhai | [nalind](https://github.com/nalind) | Core Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Matthew Heon | [mheon](https://github.com/mheon) | Core Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Paul Holzinger | [Luap99](https://github.com/Luap99) | Core Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Giuseppe Scrivano | [giuseppe](https://github.com/giuseppe) | Core Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Miloslav Trmač | [mtrmac](https://github.com/mtrmac) | Core Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Neil Smith | [actionmancan](https://github.com/actionmancan) | Community Manager | [Red Hat](https://github.com/RedHatOfficial) |
| Tom Sweeney | [TomSweeneyRedHat](https://github.com/TomSweeneyRedHat/) | Maintainer and Community Manager | [Red Hat](https://github.com/RedHatOfficial) |
| Lokesh Mandvekar | [lsm5](https://github.com/lsm5) | Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Aditya Rajan | [flouthoc](https://github.com/flouthoc) | Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Dan Walsh | [rhatdan](https://github.com/rhatdan) | Maintainer | [Red Hat](https://github.com/RedHatOfficial) |
| Ashley Cui | [ashley-cui](https://github.com/ashley-cui) | Reviewer | [Red Hat](https://github.com/RedHatOfficial) |
| Jan Rodák | [Honny1](https://github.com/Honny1) | Reviewer | [Red Hat](https://github.com/RedHatOfficial) |
| Valentin Rothberg | [vrothberg](https://github.com/vrothberg) | Reviewer | [Red Hat](https://github.com/RedHatOfficial) |
## Alumni
None at present
## Credits
The structure of this document was based off of the equivalent one in the [CRI-O Project](https://github.com/cri-o/cri-o/blob/main/MAINTAINERS.md).
## Note
If there is a discrepancy between the [MAINTAINERS.md](https://github.com/containers/podman/blob/main/MAINTAINERS.md) file in the main Podman repository and this file regarding Core Maintainers or Community Managers, the file in the Podman Repository is considered the source of truth.

137
Makefile
View File

@ -1,9 +1,9 @@
export GOPROXY=https://proxy.golang.org
APPARMORTAG := $(shell hack/apparmor_tag.sh)
STORAGETAGS := exclude_graphdriver_devicemapper $(shell ./btrfs_tag.sh) $(shell ./btrfs_installed_tag.sh) $(shell ./hack/libsubid_tag.sh)
STORAGETAGS := $(shell ./btrfs_installed_tag.sh) $(shell ./hack/libsubid_tag.sh)
SECURITYTAGS ?= seccomp $(APPARMORTAG)
TAGS ?= $(SECURITYTAGS) $(STORAGETAGS) $(shell ./hack/systemd_tag.sh)
TAGS ?= $(SECURITYTAGS) $(STORAGETAGS) $(shell ./hack/systemd_tag.sh) $(shell ./hack/sqlite_tag.sh)
ifeq ($(shell uname -s),FreeBSD)
# FreeBSD needs CNI until netavark is supported
TAGS += cni
@ -16,36 +16,35 @@ BUILDFLAGS := -tags "$(BUILDTAGS)"
BUILDAH := buildah
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
SELINUXTYPE=container_runtime_exec_t
AS ?= as
STRIP ?= strip
GO := go
GO_LDFLAGS := $(shell if $(GO) version|grep -q gccgo; then echo "-gccgoflags"; else echo "-ldflags"; fi)
GO_GCFLAGS := $(shell if $(GO) version|grep -q gccgo; then echo "-gccgoflags"; else echo "-gcflags"; fi)
# test for go module support
ifeq ($(shell $(GO) help mod >/dev/null 2>&1 && echo true), true)
export GO_BUILD=GO111MODULE=on $(GO) build -mod=vendor
export GO_TEST=GO111MODULE=on $(GO) test -mod=vendor
else
NPROCS := $(shell nproc)
export GO_BUILD=$(GO) build
export GO_TEST=$(GO) test
endif
RACEFLAGS := $(shell $(GO_TEST) -race ./pkg/dummy > /dev/null 2>&1 && echo -race)
export GO_TEST=$(GO) test -parallel=$(NPROCS)
RACEFLAGS ?= $(shell $(GO_TEST) -race ./pkg/dummy > /dev/null 2>&1 && echo -race)
COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
SOURCE_DATE_EPOCH ?= $(if $(shell date +%s),$(shell date +%s),$(error "date failed"))
STATIC_STORAGETAGS = "containers_image_openpgp $(STORAGE_TAGS)"
# we get GNU make 3.x in MacOS build envs, which wants # to be escaped in
# strings, while the 4.x we have on Linux doesn't. this is the documented
# workaround
COMMENT := \#
CNI_COMMIT := $(shell sed -n 's;^$(COMMENT) github.com/containernetworking/cni \([^ \n]*\).*$$;\1;p' vendor/modules.txt)
RUNC_COMMIT := $(shell sed -n 's;^$(COMMENT) github.com/opencontainers/runc \([^ \n]*\).*$$;\1;p' vendor/modules.txt)
LIBSECCOMP_COMMIT := release-2.3
EXTRA_LDFLAGS ?=
BUILDAH_LDFLAGS := $(GO_LDFLAGS) '-X main.GitCommit=$(GIT_COMMIT) -X main.buildInfo=$(SOURCE_DATE_EPOCH) -X main.cniVersion=$(CNI_COMMIT) $(EXTRA_LDFLAGS)'
SOURCES=*.go imagebuildah/*.go bind/*.go chroot/*.go copier/*.go define/*.go docker/*.go internal/config/*.go internal/mkcw/*.go internal/mkcw/types/*.go internal/parse/*.go internal/sbom/*.go internal/source/*.go internal/tmpdir/*.go internal/util/*.go internal/volumes/*.go manifests/*.go pkg/chrootuser/*.go pkg/cli/*.go pkg/completion/*.go pkg/formats/*.go pkg/overlay/*.go pkg/parse/*.go pkg/rusage/*.go pkg/sshagent/*.go pkg/umask/*.go pkg/util/*.go util/*.go
# This isn't what we actually build; it's a superset, used for target
# dependencies. Basically: all *.go and *.c files, except *_test.go,
# and except anything in a dot subdirectory. If any of these files is
# newer than our target (bin/buildah), a rebuild is triggered.
SOURCES=$(shell find . -path './.*' -prune -o \( \( -name '*.go' -o -name '*.c' \) -a ! -name '*_test.go' \) -print)
LINTFLAGS ?=
@ -53,40 +52,27 @@ ifeq ($(BUILDDEBUG), 1)
override GOGCFLAGS += -N -l
endif
# Managed by renovate.
export GOLANGCI_LINT_VERSION := 2.1.0
# make all BUILDDEBUG=1
# Note: Uses the -N -l go compiler options to disable compiler optimizations
# and inlining. Using these build options allows you to subsequently
# use source debugging tools like delve.
all: bin/buildah bin/imgtype bin/copy bin/tutorial docs
all: bin/buildah bin/imgtype bin/copy bin/inet bin/tutorial bin/dumpspec bin/passwd docs
# Update nix/nixpkgs.json its latest stable commit
.PHONY: nixpkgs
nixpkgs:
@nix run \
-f channel:nixos-20.09 nix-prefetch-git \
-c nix-prefetch-git \
--no-deepClone \
https://github.com/nixos/nixpkgs refs/heads/nixos-20.09 > nix/nixpkgs.json
# Build statically linked binary
.PHONY: static
static:
@nix build -f nix/
mkdir -p ./bin
cp -rfp ./result/bin/* ./bin/
bin/buildah: $(SOURCES) cmd/buildah/*.go internal/mkcw/embed/entrypoint_amd64.gz
bin/buildah: $(SOURCES) internal/mkcw/embed/entrypoint_amd64.gz
$(GO_BUILD) $(BUILDAH_LDFLAGS) $(GO_GCFLAGS) "$(GOGCFLAGS)" -o $@ $(BUILDFLAGS) ./cmd/buildah
test -z "${SELINUXOPT}" || chcon --verbose -t $(SELINUXTYPE) $@
ifneq ($(shell as --version | grep x86_64),)
ifneq ($(shell $(AS) --version | grep x86_64),)
internal/mkcw/embed/entrypoint_amd64.gz: internal/mkcw/embed/entrypoint_amd64
gzip -k9nf $^
internal/mkcw/embed/entrypoint_amd64: internal/mkcw/embed/entrypoint_amd64.s
$(AS) -o $(patsubst %.s,%.o,$^) $^
$(LD) -o $@ $(patsubst %.s,%.o,$^)
strip $@
$(STRIP) $@
endif
@ -101,36 +87,39 @@ FREEBSD_CROSS_TARGETS := $(filter bin/buildah.freebsd.%,$(ALL_CROSS_TARGETS))
.PHONY: cross
cross: $(LINUX_CROSS_TARGETS) $(DARWIN_CROSS_TARGETS) $(WINDOWS_CROSS_TARGETS) $(FREEBSD_CROSS_TARGETS)
bin/buildah.%:
bin/buildah.%: $(SOURCES)
mkdir -p ./bin
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ -tags "containers_image_openpgp" ./cmd/buildah
bin/imgtype: $(SOURCES) tests/imgtype/imgtype.go
bin/dumpspec: $(SOURCES)
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/dumpspec
bin/imgtype: $(SOURCES)
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/imgtype/imgtype.go
bin/copy: $(SOURCES) tests/copy/copy.go
bin/copy: $(SOURCES)
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/copy/copy.go
bin/tutorial: $(SOURCES) tests/tutorial/tutorial.go
bin/tutorial: $(SOURCES)
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/tutorial/tutorial.go
bin/inet: tests/inet/inet.go
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/inet/inet.go
bin/passwd: tests/passwd/passwd.go
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/passwd/passwd.go
.PHONY: clean
clean:
$(RM) -r bin tests/testreport/testreport
$(RM) -r bin tests/testreport/testreport tests/conformance/testdata/mount-targets/true
$(MAKE) -C docs clean
.PHONY: docs
docs: install.tools ## build the docs on the host
$(MAKE) -C docs
# For vendoring to work right, the checkout directory must be such that our top
# level is at $GOPATH/src/github.com/containers/buildah.
.PHONY: gopath
gopath:
test $(shell pwd) = $(shell cd ../../../../src/github.com/containers/buildah ; pwd)
codespell:
codespell -S Makefile,buildah.spec.rpkg,AUTHORS,bin,vendor,.git,go.mod,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L secon,passt,bu,uint,iff,od,erro -w
codespell -w
.PHONY: validate
validate: install.tools
@ -142,25 +131,6 @@ validate: install.tools
install.tools:
$(MAKE) -C tests/tools
.PHONY: runc
runc: gopath
rm -rf ../../opencontainers/runc
git clone https://github.com/opencontainers/runc ../../opencontainers/runc
cd ../../opencontainers/runc && git checkout $(RUNC_COMMIT) && $(GO) build -tags "$(STORAGETAGS) $(SECURITYTAGS)"
ln -sf ../../opencontainers/runc/runc
.PHONY: install.libseccomp.sudo
install.libseccomp.sudo: gopath
rm -rf ../../seccomp/libseccomp
git clone https://github.com/seccomp/libseccomp ../../seccomp/libseccomp
cd ../../seccomp/libseccomp && git checkout $(LIBSECCOMP_COMMIT) && ./autogen.sh && ./configure --prefix=/usr && make all && sudo make install
.PHONY: install.cni.sudo
install.cni.sudo: gopath
rm -rf ../../containernetworking/plugins
git clone https://github.com/containernetworking/plugins ../../containernetworking/plugins
cd ../../containernetworking/plugins && ./build_linux.sh && sudo install -D -v -m755 -t /opt/cni/bin/ bin/*
.PHONY: install
install:
install -d -m 755 $(DESTDIR)/$(BINDIR)
@ -178,22 +148,20 @@ install.completions:
install -m 755 -d $(DESTDIR)/$(BASHINSTALLDIR)
install -m 644 contrib/completions/bash/buildah $(DESTDIR)/$(BASHINSTALLDIR)/buildah
.PHONY: install.runc
install.runc:
install -m 755 ../../opencontainers/runc/runc $(DESTDIR)/$(BINDIR)/
.PHONY: test-conformance
test-conformance:
test-conformance: tests/conformance/testdata/mount-targets/true
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -timeout 60m ./tests/conformance
.PHONY: test-integration
test-integration: install.tools
./tests/tools/build/ginkgo $(BUILDFLAGS) -v tests/e2e/.
cd tests; ./test_runner.sh
tests/testreport/testreport: tests/testreport/testreport.go
$(GO_BUILD) $(GO_LDFLAGS) "-linkmode external -extldflags -static" -tags "$(STORAGETAGS) $(SECURITYTAGS)" -o tests/testreport/testreport ./tests/testreport/testreport.go
tests/conformance/testdata/mount-targets/true: tests/conformance/testdata/mount-targets/true.go
$(GO_BUILD) $(GO_LDFLAGS) "-linkmode external -extldflags -static" -o tests/conformance/testdata/mount-targets/true tests/conformance/testdata/mount-targets/true.go
.PHONY: test-unit
test-unit: tests/testreport/testreport
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover $(RACEFLAGS) $(shell $(GO) list ./... | grep -v vendor | grep -v tests | grep -v cmd | grep -v chroot | grep -v copier) -timeout 45m
@ -203,20 +171,35 @@ test-unit: tests/testreport/testreport
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover $(RACEFLAGS) ./cmd/buildah -args --root $$tmp/root --runroot $$tmp/runroot --storage-driver vfs --signature-policy $(shell pwd)/tests/policy.json --registries-conf $(shell pwd)/tests/registries.conf
vendor-in-container:
podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.21 make vendor
goversion=$(shell sed -e '/^go /!d' -e '/^go /s,.* ,,g' go.mod) ; \
if test -d `$(GO) env GOCACHE` && test -w `$(GO) env GOCACHE` ; then \
podman run --privileged --rm --env HOME=/root -v `$(GO) env GOCACHE`:/root/.cache/go-build --env GOCACHE=/root/.cache/go-build -v `pwd`:/src -w /src docker.io/library/golang:$$goversion make vendor ; \
else \
podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:$$goversion make vendor ; \
fi
.PHONY: vendor
vendor:
GO111MODULE=on $(GO) mod tidy
GO111MODULE=on $(GO) mod vendor
GO111MODULE=on $(GO) mod verify
$(GO) mod tidy
$(GO) mod vendor
$(GO) mod verify
if test -n "$(strip $(shell $(GO) env GOTOOLCHAIN))"; then go mod edit -toolchain none ; fi
.PHONY: lint
lint: install.tools
./tests/tools/build/golangci-lint run $(LINTFLAGS)
./tests/tools/build/golangci-lint run --tests=false $(LINTFLAGS)
# CAUTION: This is not a replacement for RPMs provided by your distro.
# Only intended to build and test the latest unreleased changes.
.PHONY: rpm
rpm:
rpkg local
rpm: ## Build rpm packages
$(MAKE) -C rpm
# Remember that rpms install exec to /usr/bin/buildah while a `make install`
# installs them to /usr/local/bin/buildah which is likely before. Always use
# a full path to test installed buildah or you risk to call another executable.
.PHONY: rpm-install
rpm-install: package ## Install rpm packages
$(call err_if_empty,PKG_MANAGER) -y install rpm/RPMS/*/*.rpm
/usr/bin/buildah version

23
OWNERS
View File

@ -1,28 +1,25 @@
approvers:
- TomSweeneyRedHat
- ashley-cui
- cevich
- baude
- flouthoc
- giuseppe
- lsm5
- Luap99
- mheon
- mtrmac
- nalind
- rhatdan
- umohnani8
- vrothberg
reviewers:
- QiWang19
- TomSweeneyRedHat
reviewers:
- ashley-cui
- baude
- cevich
- edsantiago
- flouthoc
- giuseppe
- haircommander
- jwhonce
- Honny1
- lsm5
- Luap99
- mheon
- mrunalp
- mtrmac
- nalind
- rhatdan
- umohnani8
- TomSweeneyRedHat
- vrothberg

View File

@ -4,6 +4,7 @@
# [Buildah](https://www.youtube.com/embed/YVk5NgSiUw8) - a tool that facilitates building [Open Container Initiative (OCI)](https://www.opencontainers.org/) container images
[![Go Report Card](https://goreportcard.com/badge/github.com/containers/buildah)](https://goreportcard.com/report/github.com/containers/buildah)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/10579/badge)](https://www.bestpractices.dev/projects/10579)
The Buildah package provides a command line tool that can be used to
@ -20,6 +21,8 @@ The Buildah package provides a command line tool that can be used to
For blogs, release announcements and more, please checkout the [buildah.io](https://buildah.io) website!
**[Buildah Container Images](https://github.com/containers/image_build/blob/main/buildah/README.md)**
**[Buildah Demos](demos)**
**[Changelog](CHANGELOG.md)**

48
ROADMAP.md Normal file
View File

@ -0,0 +1,48 @@
![buildah logo (light)](logos/buildah-logo_large.png#gh-light-mode-only)
![buildah logo (dark)](logos/buildah-logo_reverse_large.png#gh-dark-mode-only)
# Buildah Roadmap
The Buildah development team reviews feature requests from its various stakeholders for consideration
quarterly along with the Podman Development team. These features are then prioritized and the top
features are then assigned to one or more engineers.
## Future feature considerations
The following features are of general importantance to Buildah. While these features have no timeline
associated with them yet, they will likely be on future quarterly milestones.
* Ongoing work around partial pull support (zstd:chunked)
* Improved support for the BuildKit API.
* Performance and stability improvements.
* Reductions to the size of the Buildah binary.
## Milestones and commitments by quarter
This section is a historical account of what features were prioritized by quarter. Results of the prioritization will be added at start of each quarter (Jan, Apr, July, Oct).
### 2025 Q2 ####
#### Releases ####
- [ ] Buildah 1.40
#### Features ####
- [ ] Reduce binary size of Buildah
- [ ] Additional Containerfile command options
#### CNCF ####
- [ ] Add and adhere to Governance model
- [ ] Update Maintainers file
### 2025 Q1 ####
#### Releases ####
- [x] Buildah 1.39
#### Features ####
- [x] Artifact add --options
#### CNCF ####
- [x] Create Governance documentation
- [x] Create Maintainers file

383
add.go
View File

@ -2,6 +2,8 @@ package buildah
import (
"archive/tar"
"context"
"crypto/tls"
"errors"
"fmt"
"io"
@ -10,6 +12,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strconv"
"strings"
"sync"
@ -18,18 +21,26 @@ import (
"github.com/containers/buildah/copier"
"github.com/containers/buildah/define"
"github.com/containers/buildah/internal/tmpdir"
"github.com/containers/buildah/pkg/chrootuser"
"github.com/containers/common/pkg/retry"
"github.com/containers/image/v5/pkg/tlsclientconfig"
"github.com/containers/image/v5/types"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/regexp"
"github.com/docker/go-connections/tlsconfig"
"github.com/hashicorp/go-multierror"
"github.com/moby/sys/userns"
digest "github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
)
// AddAndCopyOptions holds options for add and copy commands.
type AddAndCopyOptions struct {
//Chmod sets the access permissions of the destination content.
// Chmod sets the access permissions of the destination content.
Chmod string
// Chown is a spec for the user who should be given ownership over the
// newly-added content, potentially overriding permissions which would
@ -72,20 +83,77 @@ type AddAndCopyOptions struct {
// Clear the sticky bit on items being copied. Has no effect on
// archives being extracted, where the bit is always preserved.
StripStickyBit bool
// If not "", a directory containing a CA certificate (ending with
// ".crt"), a client certificate (ending with ".cert") and a client
// certificate key (ending with ".key") used when downloading sources
// from locations protected with TLS.
CertPath string
// Allow downloading sources from HTTPS where TLS verification fails.
InsecureSkipTLSVerify types.OptionalBool
// MaxRetries is the maximum number of attempts we'll make to retrieve
// contents from a remote location.
MaxRetries int
// RetryDelay is how long to wait before retrying attempts to retrieve
// remote contents.
RetryDelay time.Duration
// Parents specifies that we should preserve either all of the parent
// directories of source locations, or the ones which follow "/./" in
// the source paths for source locations which include such a
// component.
Parents bool
// Timestamp is a timestamp to override on all content as it is being read.
Timestamp *time.Time
// Link, when set to true, creates an independent layer containing the copied content
// that sits on top of existing layers. This layer can be cached and reused
// separately, and is not affected by filesystem changes from previous instructions.
Link bool
// BuildMetadata is consulted only when Link is true. Contains metadata used by
// imagebuildah for cache evaluation of linked layers (inheritLabels, unsetAnnotations,
// inheritAnnotations, newAnnotations). This field is internally managed and should
// not be set by external API users.
BuildMetadata string
}
// sourceIsRemote returns true if "source" is a remote location.
// gitURLFragmentSuffix matches fragments to use as Git reference and build
// context from the Git repository e.g.
//
// github.com/containers/buildah.git
// github.com/containers/buildah.git#main
// github.com/containers/buildah.git#v1.35.0
var gitURLFragmentSuffix = regexp.Delayed(`\.git(?:#.+)?$`)
// sourceIsGit returns true if "source" is a git location.
func sourceIsGit(source string) bool {
return isURL(source) && gitURLFragmentSuffix.MatchString(source)
}
func isURL(url string) bool {
return strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://")
}
// sourceIsRemote returns true if "source" is a remote location
// and *not* a git repo. Certain github urls such as raw.github.* are allowed.
func sourceIsRemote(source string) bool {
return strings.HasPrefix(source, "http://") || strings.HasPrefix(source, "https://")
return isURL(source) && !gitURLFragmentSuffix.MatchString(source)
}
// getURL writes a tar archive containing the named content
func getURL(src string, chown *idtools.IDPair, mountpoint, renameTarget string, writer io.Writer, chmod *os.FileMode, srcDigest digest.Digest) error {
func getURL(src string, chown *idtools.IDPair, mountpoint, renameTarget string, writer io.Writer, chmod *os.FileMode, srcDigest digest.Digest, certPath string, insecureSkipTLSVerify types.OptionalBool, timestamp *time.Time) error {
url, err := url.Parse(src)
if err != nil {
return err
}
response, err := http.Get(src)
tlsClientConfig := &tls.Config{
CipherSuites: tlsconfig.DefaultServerAcceptedCiphers,
}
if err := tlsclientconfig.SetupCertificates(certPath, tlsClientConfig); err != nil {
return err
}
tlsClientConfig.InsecureSkipVerify = insecureSkipTLSVerify == types.OptionalBoolTrue
tr := &http.Transport{TLSClientConfig: tlsClientConfig}
httpClient := &http.Client{Transport: tr}
response, err := httpClient.Get(src)
if err != nil {
return err
}
@ -101,15 +169,19 @@ func getURL(src string, chown *idtools.IDPair, mountpoint, renameTarget string,
name = path.Base(url.Path)
}
// If there's a date on the content, use it. If not, use the Unix epoch
// for compatibility.
// or a specified value for compatibility.
date := time.Unix(0, 0).UTC()
lastModified := response.Header.Get("Last-Modified")
if lastModified != "" {
d, err := time.Parse(time.RFC1123, lastModified)
if err != nil {
return fmt.Errorf("parsing last-modified time: %w", err)
if timestamp != nil {
date = timestamp.UTC()
} else {
lastModified := response.Header.Get("Last-Modified")
if lastModified != "" {
d, err := time.Parse(time.RFC1123, lastModified)
if err != nil {
return fmt.Errorf("parsing last-modified time %q: %w", lastModified, err)
}
date = d.UTC()
}
date = d
}
// Figure out the size of the content.
size := response.ContentLength
@ -147,7 +219,7 @@ func getURL(src string, chown *idtools.IDPair, mountpoint, renameTarget string,
uid = chown.UID
gid = chown.GID
}
var mode int64 = 0600
var mode int64 = 0o600
if chmod != nil {
mode = int64(*chmod)
}
@ -201,6 +273,37 @@ func includeDirectoryAnyway(path string, pm *fileutils.PatternMatcher) bool {
return false
}
// globbedToGlobbable takes a pathname which might include the '[', *, or ?
// characters, and converts it into a glob pattern that matches itself by
// marking the '[' characters as _not_ the beginning of match ranges and
// escaping the * and ? characters.
func globbedToGlobbable(glob string) string {
result := glob
result = strings.ReplaceAll(result, "[", "[[]")
result = strings.ReplaceAll(result, "?", "\\?")
result = strings.ReplaceAll(result, "*", "\\*")
return result
}
// getParentsPrefixToRemoveAndParentsToSkip gets from the pattern the prefix before the "pivot point",
// the location in the source path marked by the path component named "."
// (i.e. where "/./" occurs in the path). And list of parents to skip.
// In case "/./" is not present is returned "/".
func getParentsPrefixToRemoveAndParentsToSkip(pattern string, contextDir string) (string, []string) {
prefix, _, found := strings.Cut(strings.TrimPrefix(pattern, contextDir), "/./")
if !found {
return string(filepath.Separator), []string{}
}
prefix = strings.TrimPrefix(filepath.Clean(string(filepath.Separator)+prefix), string(filepath.Separator))
out := []string{}
parentPath := prefix
for parentPath != "/" && parentPath != "." {
out = append(out, parentPath)
parentPath = filepath.Dir(parentPath)
}
return prefix, out
}
// Add copies the contents of the specified sources into the container's root
// filesystem, optionally extracting contents of local files that look like
// non-empty archives.
@ -233,18 +336,31 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
}
// Figure out what sorts of sources we have.
var localSources, remoteSources []string
var localSources, remoteSources, gitSources []string
for i, src := range sources {
if src == "" {
return errors.New("empty source location")
}
if sourceIsRemote(src) {
remoteSources = append(remoteSources, src)
continue
}
if sourceIsGit(src) {
gitSources = append(gitSources, src)
continue
}
if !filepath.IsAbs(src) && options.ContextDir == "" {
sources[i] = filepath.Join(currentDir, src)
}
localSources = append(localSources, sources[i])
}
// Treat git sources as a subset of remote sources
// differentiating only in how we fetch the two later on.
if len(gitSources) > 0 {
remoteSources = append(remoteSources, gitSources...)
}
// Check how many items our local source specs matched. Each spec
// should have matched at least one item, otherwise we consider it an
// error.
@ -276,7 +392,7 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
}
numLocalSourceItems += len(localSourceStat.Globbed)
}
if numLocalSourceItems+len(remoteSources) == 0 {
if numLocalSourceItems+len(remoteSources)+len(gitSources) == 0 {
return fmt.Errorf("no sources %v found: %w", sources, syscall.ENOENT)
}
@ -333,6 +449,9 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
destCanBeFile = true
}
}
if len(gitSources) > 0 {
destMustBeDirectory = true
}
}
// We care if the destination either doesn't exist, or exists and is a
@ -354,10 +473,7 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
}
// if the destination is a directory that doesn't yet exist, let's copy it.
newDestDirFound := false
if (len(destStats) == 1 || len(destStats[0].Globbed) == 0) && destMustBeDirectory && !destCanBeFile {
newDestDirFound = true
}
newDestDirFound := (len(destStats) == 1 || len(destStats[0].Globbed) == 0) && destMustBeDirectory && !destCanBeFile
if len(destStats) == 1 && len(destStats[0].Globbed) == 1 && destStats[0].Results[destStats[0].Globbed[0]].IsRegular {
if destMustBeDirectory {
@ -389,14 +505,73 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
}
destUIDMap, destGIDMap := convertRuntimeIDMaps(b.IDMappingOptions.UIDMap, b.IDMappingOptions.GIDMap)
// Create the target directory if it doesn't exist yet.
var putRoot, putDir, stagingDir string
var createdDirs []string
var latestTimestamp time.Time
mkdirOptions := copier.MkdirOptions{
UIDMap: destUIDMap,
GIDMap: destGIDMap,
ChownNew: chownDirs,
}
if err := copier.Mkdir(mountPoint, extractDirectory, mkdirOptions); err != nil {
return fmt.Errorf("ensuring target directory exists: %w", err)
// If --link is specified, we create a staging directory to hold the content
// that will then become an independent layer
if options.Link {
containerDir, err := b.store.ContainerDirectory(b.ContainerID)
if err != nil {
return fmt.Errorf("getting container directory for %q: %w", b.ContainerID, err)
}
stagingDir, err = os.MkdirTemp(containerDir, "link-stage-")
if err != nil {
return fmt.Errorf("creating staging directory for link %q: %w", b.ContainerID, err)
}
putRoot = stagingDir
cleanDest := filepath.Clean(destination)
if strings.Contains(cleanDest, "..") {
return fmt.Errorf("invalid destination path %q: contains path traversal", destination)
}
if renameTarget != "" {
putDir = filepath.Dir(filepath.Join(stagingDir, cleanDest))
} else {
putDir = filepath.Join(stagingDir, cleanDest)
}
putDirAbs, err := filepath.Abs(putDir)
if err != nil {
return fmt.Errorf("failed to resolve absolute path: %w", err)
}
stagingDirAbs, err := filepath.Abs(stagingDir)
if err != nil {
return fmt.Errorf("failed to resolve staging directory absolute path: %w", err)
}
if !strings.HasPrefix(putDirAbs, stagingDirAbs+string(os.PathSeparator)) && putDirAbs != stagingDirAbs {
return fmt.Errorf("destination path %q escapes staging directory", destination)
}
if err := copier.Mkdir(putRoot, putDirAbs, mkdirOptions); err != nil {
return fmt.Errorf("ensuring target directory exists: %w", err)
}
tempPath := putDir
for tempPath != stagingDir && tempPath != filepath.Dir(tempPath) {
if _, err := os.Stat(tempPath); err == nil {
createdDirs = append(createdDirs, tempPath)
}
tempPath = filepath.Dir(tempPath)
}
} else {
if err := copier.Mkdir(mountPoint, extractDirectory, mkdirOptions); err != nil {
return fmt.Errorf("ensuring target directory exists: %w", err)
}
putRoot = extractDirectory
putDir = extractDirectory
}
// Copy each source in turn.
@ -404,7 +579,7 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
var multiErr *multierror.Error
var getErr, closeErr, renameErr, putErr error
var wg sync.WaitGroup
if sourceIsRemote(src) {
if sourceIsRemote(src) || sourceIsGit(src) {
pipeReader, pipeWriter := io.Pipe()
var srcDigest digest.Digest
if options.Checksum != "" {
@ -413,12 +588,48 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
return fmt.Errorf("invalid checksum flag: %w", err)
}
}
wg.Add(1)
go func() {
getErr = getURL(src, chownFiles, mountPoint, renameTarget, pipeWriter, chmodDirsFiles, srcDigest)
pipeWriter.Close()
wg.Done()
}()
if sourceIsGit(src) {
go func() {
defer wg.Done()
defer pipeWriter.Close()
var cloneDir, subdir string
cloneDir, subdir, getErr = define.TempDirForURL(tmpdir.GetTempDir(), "", src)
if getErr != nil {
return
}
getOptions := copier.GetOptions{
UIDMap: srcUIDMap,
GIDMap: srcGIDMap,
Excludes: options.Excludes,
ExpandArchives: extract,
ChownDirs: chownDirs,
ChmodDirs: chmodDirsFiles,
ChownFiles: chownFiles,
ChmodFiles: chmodDirsFiles,
StripSetuidBit: options.StripSetuidBit,
StripSetgidBit: options.StripSetgidBit,
StripStickyBit: options.StripStickyBit,
Timestamp: options.Timestamp,
}
writer := io.WriteCloser(pipeWriter)
repositoryDir := filepath.Join(cloneDir, subdir)
getErr = copier.Get(repositoryDir, repositoryDir, getOptions, []string{"."}, writer)
}()
} else {
go func() {
getErr = retry.IfNecessary(context.TODO(), func() error {
return getURL(src, chownFiles, mountPoint, renameTarget, pipeWriter, chmodDirsFiles, srcDigest, options.CertPath, options.InsecureSkipTLSVerify, options.Timestamp)
}, &retry.Options{
MaxRetry: options.MaxRetries,
Delay: options.RetryDelay,
})
pipeWriter.Close()
wg.Done()
}()
}
wg.Add(1)
go func() {
b.ContentDigester.Start("")
@ -437,9 +648,9 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
ChmodDirs: nil,
ChownFiles: nil,
ChmodFiles: nil,
IgnoreDevices: runningInUserNS(),
IgnoreDevices: userns.RunningInUserNS(),
}
putErr = copier.Put(extractDirectory, extractDirectory, putOptions, io.TeeReader(pipeReader, hasher))
putErr = copier.Put(putRoot, putDir, putOptions, io.TeeReader(pipeReader, hasher))
}
hashCloser.Close()
pipeReader.Close()
@ -477,30 +688,29 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
if localSourceStat == nil {
continue
}
// Iterate through every item that matched the glob.
itemsCopied := 0
for _, glob := range localSourceStat.Globbed {
rel := glob
if filepath.IsAbs(glob) {
if rel, err = filepath.Rel(contextDir, glob); err != nil {
return fmt.Errorf("computing path of %q relative to %q: %w", glob, contextDir, err)
for _, globbed := range localSourceStat.Globbed {
rel := globbed
if filepath.IsAbs(globbed) {
if rel, err = filepath.Rel(contextDir, globbed); err != nil {
return fmt.Errorf("computing path of %q relative to %q: %w", globbed, contextDir, err)
}
}
if strings.HasPrefix(rel, ".."+string(os.PathSeparator)) {
return fmt.Errorf("possible escaping context directory error: %q is outside of %q", glob, contextDir)
return fmt.Errorf("possible escaping context directory error: %q is outside of %q", globbed, contextDir)
}
// Check for dockerignore-style exclusion of this item.
if rel != "." {
excluded, err := pm.Matches(filepath.ToSlash(rel)) // nolint:staticcheck
excluded, err := pm.Matches(filepath.ToSlash(rel)) //nolint:staticcheck
if err != nil {
return fmt.Errorf("checking if %q(%q) is excluded: %w", glob, rel, err)
return fmt.Errorf("checking if %q(%q) is excluded: %w", globbed, rel, err)
}
if excluded {
// non-directories that are excluded are excluded, no question, but
// directories can only be skipped if we don't have to allow for the
// possibility of finding things to include under them
globInfo := localSourceStat.Results[glob]
globInfo := localSourceStat.Results[globbed]
if !globInfo.IsDir || !includeDirectoryAnyway(rel, pm) {
continue
}
@ -517,7 +727,10 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
// due to potentially not having anything in the tarstream that we passed.
itemsCopied++
}
st := localSourceStat.Results[glob]
st := localSourceStat.Results[globbed]
if options.Link && st.ModTime.After(latestTimestamp) {
latestTimestamp = st.ModTime
}
pipeReader, pipeWriter := io.Pipe()
wg.Add(1)
go func() {
@ -530,7 +743,26 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
return false, false, nil
})
}
writer = newTarFilterer(writer, func(hdr *tar.Header) (bool, bool, io.Reader) {
if options.Parents {
parentsPrefixToRemove, parentsToSkip := getParentsPrefixToRemoveAndParentsToSkip(src, options.ContextDir)
writer = newTarFilterer(writer, func(hdr *tar.Header) (bool, bool, io.Reader) {
if slices.Contains(parentsToSkip, hdr.Name) && hdr.Typeflag == tar.TypeDir {
return true, false, nil
}
hdr.Name = strings.TrimPrefix(hdr.Name, parentsPrefixToRemove)
hdr.Name = strings.TrimPrefix(hdr.Name, "/")
if hdr.Typeflag == tar.TypeLink {
hdr.Linkname = strings.TrimPrefix(hdr.Linkname, parentsPrefixToRemove)
hdr.Linkname = strings.TrimPrefix(hdr.Linkname, "/")
}
if hdr.Name == "" {
return true, false, nil
}
return false, false, nil
})
}
writer = newTarFilterer(writer, func(_ *tar.Header) (bool, bool, io.Reader) {
itemsCopied++
return false, false, nil
})
@ -546,8 +778,10 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
StripSetuidBit: options.StripSetuidBit,
StripSetgidBit: options.StripSetgidBit,
StripStickyBit: options.StripStickyBit,
Parents: options.Parents,
Timestamp: options.Timestamp,
}
getErr = copier.Get(contextDir, contextDir, getOptions, []string{glob}, writer)
getErr = copier.Get(contextDir, contextDir, getOptions, []string{globbedToGlobbable(globbed)}, writer)
closeErr = writer.Close()
if renameTarget != "" && renamedItems > 1 {
renameErr = fmt.Errorf("internal error: renamed %d items when we expected to only rename 1", renamedItems)
@ -578,14 +812,15 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
ChmodDirs: nil,
ChownFiles: nil,
ChmodFiles: nil,
IgnoreDevices: runningInUserNS(),
IgnoreDevices: userns.RunningInUserNS(),
}
putErr = copier.Put(extractDirectory, extractDirectory, putOptions, io.TeeReader(pipeReader, hasher))
putErr = copier.Put(putRoot, putDir, putOptions, io.TeeReader(pipeReader, hasher))
}
hashCloser.Close()
pipeReader.Close()
wg.Done()
}()
wg.Wait()
if getErr != nil {
getErr = fmt.Errorf("reading %q: %w", src, getErr)
@ -615,6 +850,58 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
return fmt.Errorf("no items matching glob %q copied (%d filtered out%s): %w", localSourceStat.Glob, len(localSourceStat.Globbed), excludesFile, syscall.ENOENT)
}
}
if options.Link {
if !latestTimestamp.IsZero() {
for _, dir := range createdDirs {
if err := os.Chtimes(dir, latestTimestamp, latestTimestamp); err != nil {
logrus.Warnf("failed to set timestamp on directory %q: %v", dir, err)
}
}
}
var created time.Time
if options.Timestamp != nil {
created = *options.Timestamp
} else if !latestTimestamp.IsZero() {
created = latestTimestamp
} else {
created = time.Unix(0, 0).UTC()
}
command := "ADD"
if !extract {
command = "COPY"
}
contentType, digest := b.ContentDigester.Digest()
summary := contentType
if digest != "" {
if summary != "" {
summary = summary + ":"
}
summary = summary + digest.Encoded()
logrus.Debugf("added content from --link %s", summary)
}
createdBy := "/bin/sh -c #(nop) " + command + " --link " + summary + " in " + destination + " " + options.BuildMetadata
history := v1.History{
Created: &created,
CreatedBy: createdBy,
Comment: b.HistoryComment(),
}
linkedLayer := LinkedLayer{
History: history,
BlobPath: stagingDir,
}
b.AppendedLinkedLayers = append(b.AppendedLinkedLayers, linkedLayer)
if err := b.Save(); err != nil {
return fmt.Errorf("saving builder state after queuing linked layer: %w", err)
}
}
return nil
}
@ -640,7 +927,6 @@ func (b *Builder) userForRun(mountPoint string, userspec string) (specs.User, st
} else {
u.AdditionalGids = groups
}
}
return u, homeDir, err
}
@ -691,8 +977,8 @@ func (b *Builder) userForCopy(mountPoint string, userspec string) (uint32, uint3
return owner.UID, owner.GID, nil
}
// EnsureContainerPathAs creates the specified directory owned by USER
// with the file mode set to MODE.
// EnsureContainerPathAs creates the specified directory if it doesn't exist,
// setting a newly-created directory's owner to USER and its permissions to MODE.
func (b *Builder) EnsureContainerPathAs(path, user string, mode *os.FileMode) error {
mountPoint, err := b.Mount(b.MountLabel)
if err != nil {
@ -722,5 +1008,4 @@ func (b *Builder) EnsureContainerPathAs(path, user string, mode *os.FileMode) er
GIDMap: destGIDMap,
}
return copier.Mkdir(mountPoint, filepath.Join(mountPoint, path), opts)
}

View File

@ -1,8 +0,0 @@
//go:build !linux
// +build !linux
package buildah
func runningInUserNS() bool {
return false
}

View File

@ -1,9 +0,0 @@
package buildah
import (
"github.com/opencontainers/runc/libcontainer/userns"
)
func runningInUserNS() bool {
return userns.RunningInUserNS()
}

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package bind
@ -8,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"syscall"
"github.com/containers/buildah/util"
@ -15,7 +15,6 @@ import (
"github.com/containers/storage/pkg/mount"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
"golang.org/x/sys/unix"
)
@ -49,7 +48,7 @@ func SetupIntermediateMountNamespace(spec *specs.Spec, bundlePath string) (unmou
if err != nil {
return nil, fmt.Errorf("checking permissions on %q: %w", bundlePath, err)
}
if err = os.Chmod(bundlePath, info.Mode()|0111); err != nil {
if err = os.Chmod(bundlePath, info.Mode()|0o111); err != nil {
return nil, fmt.Errorf("loosening permissions on %q: %w", bundlePath, err)
}
@ -116,7 +115,7 @@ func SetupIntermediateMountNamespace(spec *specs.Spec, bundlePath string) (unmou
// other unprivileged users outside of containers, shouldn't be able to
// access.
mnt := filepath.Join(bundlePath, "mnt")
if err = idtools.MkdirAndChown(mnt, 0100, idtools.IDPair{UID: int(rootUID), GID: int(rootGID)}); err != nil {
if err = idtools.MkdirAndChown(mnt, 0o100, idtools.IDPair{UID: int(rootUID), GID: int(rootGID)}); err != nil {
return unmountAll, fmt.Errorf("creating %q owned by the container's root user: %w", mnt, err)
}
@ -129,7 +128,7 @@ func SetupIntermediateMountNamespace(spec *specs.Spec, bundlePath string) (unmou
// Create a bind mount for the root filesystem and add it to the list.
rootfs := filepath.Join(mnt, "rootfs")
if err = os.Mkdir(rootfs, 0000); err != nil {
if err = os.Mkdir(rootfs, 0o000); err != nil {
return unmountAll, fmt.Errorf("creating directory %q: %w", rootfs, err)
}
if err = unix.Mount(rootPath, rootfs, "", unix.MS_BIND|unix.MS_REC|unix.MS_PRIVATE, ""); err != nil {
@ -160,13 +159,13 @@ func SetupIntermediateMountNamespace(spec *specs.Spec, bundlePath string) (unmou
if info.IsDir() {
// If the source is a directory, make one to use as the
// mount target.
if err = os.Mkdir(stage, 0000); err != nil {
if err = os.Mkdir(stage, 0o000); err != nil {
return unmountAll, fmt.Errorf("creating directory %q: %w", stage, err)
}
} else {
// If the source is not a directory, create an empty
// file to use as the mount target.
file, err := os.OpenFile(stage, os.O_WRONLY|os.O_CREATE, 0000)
file, err := os.OpenFile(stage, os.O_WRONLY|os.O_CREATE, 0o000)
if err != nil {
return unmountAll, fmt.Errorf("creating file %q: %w", stage, err)
}

View File

@ -1,4 +1,4 @@
// +build !linux
//go:build !linux
package bind

View File

@ -1,8 +1,9 @@
package bind
import (
"slices"
"github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/exp/slices"
)
const (

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
${CPP:-${CC:-cc} -E} ${CPPFLAGS} - > /dev/null 2> /dev/null << EOF
#include <btrfs/version.h>
EOF
if test $? -ne 0 ; then
echo btrfs_noversion
fi

View File

@ -91,7 +91,7 @@ type Builder struct {
// Logger is the logrus logger to write log messages with
Logger *logrus.Logger `json:"-"`
// Args define variables that users can pass at build-time to the builder
// Args define variables that users can pass at build-time to the builder.
Args map[string]string
// Type is used to help identify a build container's metadata. It
// should not be modified.
@ -118,7 +118,7 @@ type Builder struct {
// MountPoint is the last location where the container's root
// filesystem was mounted. It should not be modified.
MountPoint string `json:"mountpoint,omitempty"`
// ProcessLabel is the SELinux process label associated with the container
// ProcessLabel is the SELinux process label to use during subsequent Run() calls.
ProcessLabel string `json:"process-label,omitempty"`
// MountLabel is the SELinux mount label associated with the container
MountLabel string `json:"mount-label,omitempty"`
@ -139,7 +139,7 @@ type Builder struct {
// Isolation controls how we handle "RUN" statements and the Run() method.
Isolation define.Isolation
// NamespaceOptions controls how we set up the namespaces for processes that we run in the container.
// NamespaceOptions controls how we set up the namespaces for processes that we Run().
NamespaceOptions define.NamespaceOptions
// ConfigureNetwork controls whether or not network interfaces and
// routing are configured for a new network namespace (i.e., when not
@ -157,11 +157,11 @@ type Builder struct {
// NetworkInterface is the libnetwork network interface used to setup CNI or netavark networks.
NetworkInterface nettypes.ContainerNetwork `json:"-"`
// GroupAdd is a list of groups to add to the primary process within
// the container. 'keep-groups' allows container processes to use
// supplementary groups.
// GroupAdd is a list of groups to add to the primary process when Run() is
// called. The magic 'keep-groups' value indicates that the process should
// be allowed to inherit the current set of supplementary groups.
GroupAdd []string
// ID mapping options to use when running processes in the container with non-host user namespaces.
// ID mapping options to use when running processes with non-host user namespaces.
IDMappingOptions define.IDMappingOptions
// Capabilities is a list of capabilities to use when running commands in the container.
Capabilities []string
@ -177,14 +177,28 @@ type Builder struct {
CommonBuildOpts *define.CommonBuildOptions
// TopLayer is the top layer of the image
TopLayer string
// Format for the build Image
// Format to use for a container image we eventually commit, when we do.
Format string
// TempVolumes are temporary mount points created during container runs
// TempVolumes are temporary mount points created during Run() calls.
// Deprecated: do not use.
TempVolumes map[string]bool
// ContentDigester counts the digest of all Add()ed content
// ContentDigester counts the digest of all Add()ed content since it was
// last restarted.
ContentDigester CompositeDigester
// Devices are the additional devices to add to the containers
// Devices are parsed additional devices to provide to Run() calls.
Devices define.ContainerDevices
// DeviceSpecs are unparsed additional devices to provide to Run() calls.
DeviceSpecs []string
// CDIConfigDir is the location of CDI configuration files, if the files in
// the default configuration locations shouldn't be used.
CDIConfigDir string
// PrependedLinkedLayers and AppendedLinkedLayers are combinations of
// history entries and locations of either directory trees (if
// directories, per os.Stat()) or uncompressed layer blobs which should
// be added to the image at commit-time. The order of these relative
// to PrependedEmptyLayers and AppendedEmptyLayers in the committed
// image is not guaranteed.
PrependedLinkedLayers, AppendedLinkedLayers []LinkedLayer
}
// BuilderInfo are used as objects to display container information
@ -215,6 +229,8 @@ type BuilderInfo struct {
IDMappingOptions define.IDMappingOptions
History []v1.History
Devices define.ContainerDevices
DeviceSpecs []string
CDIConfigDir string
}
// GetBuildInfo gets a pointer to a Builder object and returns a BuilderInfo object from it.
@ -251,6 +267,8 @@ func GetBuildInfo(b *Builder) BuilderInfo {
Capabilities: b.Capabilities,
History: history,
Devices: b.Devices,
DeviceSpecs: b.DeviceSpecs,
CDIConfigDir: b.CDIConfigDir,
}
}
@ -328,13 +346,15 @@ type BuilderOptions struct {
// ID mapping options to use if we're setting up our own user namespace.
IDMappingOptions *define.IDMappingOptions
// Capabilities is a list of capabilities to use when
// running commands in the container.
// running commands for Run().
Capabilities []string
CommonBuildOpts *define.CommonBuildOptions
// Format for the container image
// Format to use for a container image we eventually commit, when we do.
Format string
// Devices are the additional devices to add to the containers
// Devices are additional parsed devices to provide for Run() calls.
Devices define.ContainerDevices
// DeviceSpecs are additional unparsed devices to provide for Run() calls.
DeviceSpecs []string
// DefaultEnv is deprecated and ignored.
DefaultEnv []string
// MaxPullRetries is the maximum number of attempts we'll make to pull
@ -345,9 +365,9 @@ type BuilderOptions struct {
// OciDecryptConfig contains the config that can be used to decrypt an image if it is
// encrypted if non-nil. If nil, it does not attempt to decrypt an image.
OciDecryptConfig *encconfig.DecryptConfig
// ProcessLabel is the SELinux process label associated with the container
// ProcessLabel is the SELinux process label associated with commands we Run()
ProcessLabel string
// MountLabel is the SELinux mount label associated with the container
// MountLabel is the SELinux mount label associated with the working container
MountLabel string
// PreserveBaseImageAnns indicates that we should preserve base
// image information (Annotations) that are present in our base image,
@ -355,6 +375,14 @@ type BuilderOptions struct {
// itself. Useful as an internal implementation detail of multistage
// builds, and does not need to be set by most callers.
PreserveBaseImageAnns bool
// CDIConfigDir is the location of CDI configuration files, if the files in
// the default configuration locations shouldn't be used.
CDIConfigDir string
// CompatScratchConfig controls whether a "scratch" image is created
// with a truly empty configuration, as would have happened in the past
// (when set to true), or with a minimal initial configuration which
// has a working directory set in it.
CompatScratchConfig types.OptionalBool
}
// ImportOptions are used to initialize a Builder from an existing container
@ -548,7 +576,7 @@ func (b *Builder) Save() error {
if err != nil {
return err
}
if err = ioutils.AtomicWriteFile(filepath.Join(cdir, stateFile), buildstate, 0600); err != nil {
if err = ioutils.AtomicWriteFile(filepath.Join(cdir, stateFile), buildstate, 0o600); err != nil {
return fmt.Errorf("saving builder state to %q: %w", filepath.Join(cdir, stateFile), err)
}
return nil

View File

@ -6,6 +6,7 @@ import (
"os"
"testing"
imagetypes "github.com/containers/image/v5/types"
"github.com/containers/storage"
"github.com/containers/storage/types"
"github.com/sirupsen/logrus"
@ -13,6 +14,11 @@ import (
"github.com/stretchr/testify/require"
)
var testSystemContext = imagetypes.SystemContext{
SignaturePolicyPath: "tests/policy.json",
SystemRegistriesConfPath: "tests/registries.conf",
}
func TestMain(m *testing.M) {
var logLevel string
debug := false
@ -34,6 +40,12 @@ func TestMain(m *testing.M) {
}
func TestOpenBuilderCommonBuildOpts(t *testing.T) {
// This test cannot be parallelized as this uses NewBuilder()
// which eventually and indirectly accesses a global variable
// defined in `go-selinux`, this must be fixed at `go-selinux`
// or builder must enable sometime of locking mechanism i.e if
// routine is creating Builder other's must wait for it.
// Tracked here: https://github.com/containers/buildah/issues/5967
ctx := context.TODO()
store, err := storage.GetStore(types.StoreOptions{
RunRoot: t.TempDir(),
@ -68,7 +80,8 @@ func TestOpenBuilderCommonBuildOpts(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, container)
b, err = ImportBuilder(ctx, store, ImportOptions{
Container: container.ID,
Container: container.ID,
SignaturePolicyPath: testSystemContext.SignaturePolicyPath,
})
require.NoError(t, err)
require.NotNil(t, b.CommonBuildOpts)

View File

@ -1,3 +1,470 @@
- Changelog for v1.40.0 (2025-04-17)
* Bump c/storage to v1.58.0, c/image v5.35.0, c/common v0.63.0
* fix(deps): update module github.com/docker/docker to v28.1.0+incompatible
* fix(deps): update module github.com/containers/storage to v1.58.0
* cirrus: make Total Success wait for rootless integration
* chroot: use symbolic names when complaining about mount() errors
* cli: hide the `completion` command instead of disabling it outright
* Document rw and src options for --mount flag in buildah-run(1)
* fix(deps): update module github.com/moby/buildkit to v0.21.0
* build: add support for inherit-labels
* chore(deps): update dependency golangci/golangci-lint to v2.1.0
* .github: check_cirrus_cron work around github bug
* stage_executor,getCreatedBy: expand buildArgs for sources correctly
* Add a link to project governance and MAINTAINERS file
* fix(deps): update github.com/containers/storage digest to b1d1b45
* generateHostname: simplify
* Use maps.Copy
* Use slices.Concat
* Use slices.Clone
* Use slices.Contains
* Use for range over integers
* tests/testreport: don't copy os.Environ
* Use any instead of interface{}
* ci: add golangci-lint run with --tests=false
* ci: add nolintlint, fix found issues
* copier: rm nolint:unparam annotation
* .golangci.yml: add unused linter
* chroot: fix unused warnings
* copier: fix unused warnings
* tests/conformance: fix unused warning
* ci: switch to golangci-lint v2
* internal/mkcw: disable ST1003 warnings
* tests/conformance: do not double import (fix ST1019)
* cmd/buildah: don't double import (fix ST1019)
* Do not capitalize error strings
* cmd/buildah: do not capitalize error strings
* tests/conformance: fix QF1012 warnings
* tests/serve: fix QF1012 warning
* Use strings.ReplaceAll to fix QF1004 warnings
* Use switch to fix QF1003 warnings
* Apply De Morgan's law to fix QF1001 warnings
* Fix QF1007 staticcheck warnings
* imagebuildah: fix revive warning
* Rename max variable
* tests/tools: install lint from binary, use renovate
* fix(deps): update module github.com/containernetworking/cni to v1.3.0
* Update Buildah issue template to new version and support podman build
* fix(deps): update module golang.org/x/crypto to v0.37.0
* stage_executor: reset platform in systemcontext for stages
* fix(deps): update github.com/opencontainers/runtime-tools digest to 260e151
* cmd/buildah: rm unused containerOutputUsingTemplate
* cmd/buildah: rm unused getDateAndDigestAndSize
* build: return ExecErrorCodeGeneric when git operation fails
* add: report error while creating dir for URL source.
* createPlatformContainer: drop MS_REMOUNT|MS_BIND
* fix(deps): update module github.com/docker/docker to v28.0.3+incompatible
* fix: bats won't fail on ! without cleverness
* feat: use HistoryTimestamp, if set, for oci-archive entries
* Allow extendedGlob to work with Windows paths
* fix(deps): update module github.com/moby/buildkit to v0.20.2
* fix(deps): update github.com/openshift/imagebuilder digest to e87e4e1
* fix(deps): update module github.com/docker/docker to v28.0.2+incompatible
* fix(deps): update module tags.cncf.io/container-device-interface to v1.0.1
* chore(deps): update dependency containers/automation_images to v20250324
* vendor: update github.com/opencontainers/selinux to v1.12.0
* replace deprecated selinux/label calls
* vendor: bump c/common to dbeb17e40c80
* Use builtin arg defaults from imagebuilder
* linux: accept unmask paths as glob values
* vendor: update containers/common
* Add --parents option for COPY in Dockerfiles
* fix(deps): update module github.com/opencontainers/runc to v1.2.6
* update go.sum from the previous commit
* fix(deps): update module tags.cncf.io/container-device-interface to v1
* chore(deps): update module golang.org/x/net to v0.36.0 [security]
* packit: remove f40 from copr builds
* cirrus: update to go 1.23 image
* vendor bump to golang.org/x/crypto v0.36.0
* cirrus: update PRIOR_FEDORA comment
* github: remove cirrus rerun action
* fix(deps): update module github.com/containers/common to v0.62.2
* fix(deps): update module github.com/containers/image/v5 to v5.34.2
* fix: close files properly when BuildDockerfiles exits
* fix(deps): update module github.com/containers/storage to v1.57.2
* stage_executor: history should include heredoc summary correctly
* fix(deps): update module github.com/containers/common to v0.62.1
* github: disable cron rerun action
* fix(deps): update module github.com/moby/buildkit to v0.20.1
* internal/mkcw.Archive(): use github.com/containers/storage/pkg/ioutils
* [skip-ci] TMT: system tests
* buildah-build.1.md: secret examples
* fix(deps): update github.com/containers/luksy digest to 40bd943
* fix(deps): update module github.com/opencontainers/image-spec to v1.1.1
* fix(deps): update module github.com/containers/image/v5 to v5.34.1
* Use UnparsedInstance.Manifest instead of ImageSource.GetManifest
* fix(deps): update module github.com/opencontainers/runtime-spec to v1.2.1
* tests/conformance/testdata/Dockerfile.add: update some URLs
* Vendor imagebuilder
* Fix source of OS, architecture and variant
* chore(deps): update module github.com/go-jose/go-jose/v4 to v4.0.5 [security]
* fix(deps): update module tags.cncf.io/container-device-interface to v0.8.1
* fix(deps): update module github.com/moby/buildkit to v0.20.0
* chroot createPlatformContainer: use MS_REMOUNT
* conformance: make TestCommit and TestConformance parallel
* cirrus: reduce task timeout
* mkcw: mkcw_check_image use bats run_with_log
* test: use /tmp as TMPDIR
* heredoc: create temp subdirs for each build
* test: heredoc remove python dependency from test
* Support the containers.conf container_name_as_hostname option
* fix(deps): update module github.com/opencontainers/runc to v1.2.5
* fix(deps): update module github.com/spf13/cobra to v1.9.0
* .cirrus: use more cores for smoke
* Switch to the CNCF Code of Conduct
* .cirrus: bump ci resources
* fix(deps): update module golang.org/x/crypto to v0.33.0
* Distinguish --mount=type=cache locations by ownership, too
* fix(deps): update module golang.org/x/term to v0.29.0
* .cirrus: run -race only on non-PR branch
* unit: deparallize some tests
* .cirrus: use multiple cpu for unit tests
* Makefile: use -parallel for go test
* unit_test: use Parallel test where possible
* Update module golang.org/x/sys to v0.30.0
* Update module golang.org/x/sync to v0.11.0
* Update dependency containers/automation_images to v20250131
* Bump to Buildah v1.40.0-dev
- Changelog for v1.39.0 (2025-01-31)
* Bump c/storage v1.57.1, c/image 5.34.0, c/common v0.62.0
* Update module github.com/containers/storage to v1.57.0
* CI, .cirrus: parallelize containerized integration
* ed's comment: cleanup
* use seperate blobinfocache for flaky test
* bump CI VMs to 4 CPUs (was: 2) for integration tests
* cleanup, debug, and disable parallel in blobcache tests
* bats tests - parallelize
* pkg/overlay: cleanups
* RPM: include check section to silence rpmlint
* RPM: use default gobuild macro on RHEL
* tests: remove masked /sys/dev/block check
* vendor to latest c/{common,image,storage}
* build, run: record hash or digest in image history
* Accept image names as sources for cache mounts
* Run(): always clean up options.ExternalImageMounts
* refactor: replace golang.org/x/exp with stdlib
* Update to c/image @main
* fix broken doc link
* run_freebsd.go: only import runtime-spec once
* fix(deps): update module github.com/docker/docker to v27.5.1+incompatible
* bump github.com/vbatts/tar-split
* Add more checks to the --mount flag parsing logic
* chroot mount flags integration test: copy binaries
* fix(deps): update module github.com/moby/buildkit to v0.19.0
* relabel(): correct a misleading parameter name
* Fix TOCTOU error when bind and cache mounts use "src" values
* define.TempDirForURL(): always use an intermediate subdirectory
* internal/volume.GetBindMount(): discard writes in bind mounts
* pkg/overlay: add a MountLabel flag to Options
* pkg/overlay: add a ForceMount flag to Options
* Add internal/volumes.bindFromChroot()
* Add an internal/open package
* fix(deps): update module github.com/containers/common to v0.61.1
* fix(deps): update module github.com/containers/image/v5 to v5.33.1
* [CI:DOCS] Touch up changelogs
* fix(deps): update module github.com/docker/docker to v27.5.0+incompatible
* copy-preserving-extended-attributes: use a different base image
* fix(deps): update github.com/containers/luksy digest to a3a812d
* chore(deps): update module golang.org/x/net to v0.33.0 [security]
* fix(deps): update module golang.org/x/crypto to v0.32.0
* New VM Images
* fix(deps): update module github.com/opencontainers/runc to v1.2.4
* fix(deps): update module github.com/docker/docker to v27.4.1+incompatible
* fix(deps): update module github.com/containers/ocicrypt to v1.2.1
* Add support for --security-opt mask and unmask
* Allow cache mounts to be stages or additional build contexts
* [skip-ci] RPM: cleanup changelog conditionals
* fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.6
* fix(deps): update module github.com/moby/buildkit to v0.18.2
* Fix an error message in the chroot unit test
* copier: use .PAXRecords instead of .Xattrs
* chroot: on Linux, try to pivot_root before falling back to chroot
* manifest add: add --artifact-annotation
* Add context to an error message
* Update module golang.org/x/crypto to v0.31.0
* Update module github.com/opencontainers/runc to v1.2.3
* Update module github.com/docker/docker to v27.4.0+incompatible
* Update module github.com/cyphar/filepath-securejoin to v0.3.5
* CI: don't build a binary in the unit tests task
* CI: use /tmp for $GOCACHE
* CI: remove dependencies on the cross-build task
* CI: run cross-compile task with make -j
* Update module github.com/docker/docker to v27.4.0-rc.4+incompatible
* Update module github.com/moby/buildkit to v0.18.1
* Update module golang.org/x/crypto to v0.30.0
* Update golang.org/x/exp digest to 2d47ceb
* Update github.com/opencontainers/runtime-tools digest to f7e3563
* [skip-ci] Packit: remove rhel copr build jobs
* [skip-ci] Packit: switch to fedora-all for copr
* Update module github.com/stretchr/testify to v1.10.0
* Update module github.com/moby/buildkit to v0.17.2
* Makefile: use `find` to detect source files
* Tests: make _prefetch() parallel-safe
* Update module github.com/opencontainers/runc to v1.2.2
* executor: allow to specify --no-pivot-root
* Update module github.com/moby/sys/capability to v0.4.0
* Makefile: mv codespell config to .codespellrc
* Fix some codespell errors
* Makefile,install.md: rm gopath stuff
* Makefile: rm targets working on ..
* build: rm exclude_graphdriver_devicemapper tag
* Makefile: rm unused var
* Finish updating to go 1.22
* CI VMs: bump again
* Bump to Buidah v1.39.0-dev
* stage_executor: set avoidLookingCache only if mounting stage
* imagebuildah: additionalContext is not a local built stage
- Changelog for v1.38.0 (2024-11-08)
* Bump to c/common v0.61.0, c/image v5.33.0, c/storage v1.56.0
* fix(deps): update module golang.org/x/crypto to v0.29.0
* fix(deps): update module github.com/moby/buildkit to v0.17.1
* fix(deps): update module github.com/containers/storage to v1.56.0
* tests: skip two ulimit tests
* CI VMs: bump f40 -> f41
* tests/tools: rebuild tools when we change versions
* tests/tools: update golangci-lint to v1.61.0
* fix(deps): update module github.com/moby/buildkit to v0.17.0
* Handle RUN --mount with relative targets and no configured workdir
* tests: bud: make parallel-safe
* fix(deps): update module github.com/opencontainers/runc to v1.2.1
* fix(deps): update golang.org/x/exp digest to f66d83c
* fix(deps): update github.com/opencontainers/runtime-tools digest to 6c9570a
* tests: blobcache: use unique image name
* tests: sbom: never write to cwd
* tests: mkcw: bug fixes, refactor
* deps: bump runc to v1.2.0
* deps: switch to moby/sys/userns
* tests/test_runner.sh: remove some redundancies
* Integration tests: run git daemon on a random-but-bind()able port
* fix(deps): update module github.com/opencontainers/selinux to v1.11.1
* go.mod: remove unnecessary replace
* Document more buildah build --secret options
* Add support for COPY --exclude and ADD --exclude options
* fix(deps): update github.com/containers/luksy digest to e2530d6
* chore(deps): update dependency containers/automation_images to v20241010
* fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.4
* Properly validate cache IDs and sources
* [skip-ci] Packit: constrain koji job to fedora package to avoid dupes
* Audit and tidy OWNERS
* fix(deps): update module golang.org/x/crypto to v0.28.0
* tests: add quotes to names
* vendor: update c/common to latest
* CVE-2024-9407: validate "bind-propagation" flag settings
* vendor: switch to moby/sys/capability
* Don't set ambient capabilities
* Document that zstd:chunked is downgraded to zstd when encrypting
* fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.3
* buildah-manifest-create.1: Fix manpage section
* chore(deps): update dependency ubuntu to v24
* Make `buildah manifest push --all` true by default
* chroot: add newlines at the end of printed error messages
* Do not error on trying to write IMA xattr as rootless
* fix: remove duplicate conditions
* fix(deps): update module github.com/moby/buildkit to v0.16.0
* fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.2
* Document how entrypoint is configured in buildah config
* In a container, try to register binfmt_misc
* imagebuildah.StageExecutor: clean up volumes/volumeCache
* build: fall back to parsing a TARGETPLATFORM build-arg
* `manifest add --artifact`: handle multiple values
* Packit: split out ELN jobs and reuse fedora downstream targets
* Packit: Enable sidetags for bodhi updates
* fix(deps): update module github.com/docker/docker to v27.2.1+incompatible
* tests/bud.bats: add git source
* add: add support for git source
* Add support for the new c/common pasta options
* vendor latest c/common
* fix(deps): update module golang.org/x/term to v0.24.0
* fix(deps): update module github.com/fsouza/go-dockerclient to v1.12.0
* packit: update fedora and epel targets
* cirrus: disable f39 testing
* cirrus: fix fedora names
* update to go 1.22
* Vendor c/common:9d025e4cb348
* copier: handle globbing with "**" path components
* fix(deps): update golang.org/x/exp digest to 9b4947d
* fix(deps): update github.com/containers/luksy digest to 2e7307c
* imagebuildah: make scratch config handling toggleable
* fix(deps): update module github.com/docker/docker to v27.2.0+incompatible
* Add a validation script for Makefile $(SOURCES)
* fix(deps): update module github.com/openshift/imagebuilder to v1.2.15
* New VMs
* Update some godocs, use 0o to prefix an octal in a comment
* buildah-build.1.md: expand the --layer-label description
* fix(deps): update module github.com/containers/common to v0.60.2
* run: fix a nil pointer dereference on FreeBSD
* CI: enable the whitespace linter
* Fix some govet linter warnings
* Commit(): retry committing to local storage on storage.LayerUnknown
* CI: enable the gofumpt linter
* conformance: move weirdly-named files out of the repository
* fix(deps): update module github.com/docker/docker to v27.1.2+incompatible
* fix(deps): update module github.com/containers/common to v0.60.1
* *: use gofmt -s, add gofmt linter
* *: fix build tags
* fix(deps): update module github.com/containers/image/v5 to v5.32.1
* Add(): re-escape any globbed items that included escapes
* conformance tests: use mirror.gcr.io for most images
* unit tests: use test-specific policy.json and registries.conf
* fix(deps): update module golang.org/x/sys to v0.24.0
* Update to spun-out "github.com/containerd/platforms"
* Bump github.com/containerd/containerd
* test/tools/Makefile: duplicate the vendor-in-container target
* linters: unchecked error
* linters: don't end loop iterations with "else" when "then" would
* linters: unused arguments shouldn't have names
* linters: rename checkIdsGreaterThan5() to checkIDsGreaterThan5()
* linters: don't name variables "cap"
* `make lint`: use --timeout instead of --deadline
* Drop the e2e test suite
* fix(deps): update module golang.org/x/crypto to v0.26.0
* fix(deps): update module github.com/onsi/gomega to v1.34.1
* `make vendor-in-container`: use the caller's Go cache if it exists
* fix(deps): fix test/tools ginkgo typo
* fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.1
* Update to keep up with API changes in storage
* fix(deps): update github.com/containers/luksy digest to 1f482a9
* install: On Debian/Ubuntu, add installation of libbtrfs-dev
* fix(deps): update module golang.org/x/sys to v0.23.0
* fix(deps): update golang.org/x/exp digest to 8a7402a
* fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.2
* Use Epoch: 2 and respect the epoch in dependencies.
* Bump to Buildah v1.38.0-dev
* AddAndCopyOptions: add CertPath, InsecureSkipTLSVerify, Retry fields
* Add PrependedLinkedLayers/AppendedLinkedLayers to CommitOptions
* integration tests: teach starthttpd() about TLS and pid files
- Changelog for v1.37.0 (2024-07-26)
* Bump c/storage, c/image, c/common for v1.37.0
* "build with basename resolving user arg" tests: correct ARG use
* bud-multiple-platform-no-run test: correct ARG use
* imagebuildah: always have default values for $TARGET... args ready
* bump github.com/openshift/imagebuilder to v1.2.14
* fix(deps): update module github.com/docker/docker to v27.1.1+incompatible
* fix(deps): update module github.com/cyphar/filepath-securejoin to v0.3.1
* fix(deps): update module github.com/docker/docker to v27.1.0+incompatible
* CI: use local registry, part 2 of 2
* CI: use local registry, part 1 of 2
* fix(deps): update module github.com/fsouza/go-dockerclient to v1.11.1
* Revert "fix(deps): update github.com/containers/image/v5 to v5.31.1"
* Replace libimage.LookupReferenceFunc with the manifests version
* conformance tests: enable testing CompatVolumes
* conformance tests: add a test that tries to chown a volume
* imagebuildah: make traditional volume handling not the default
* StageExecutor.prepare(): mark base image volumes for preservation
* fix(deps): update module github.com/containers/image/v5 to v5.31.1
* Vendor in latest containers/(common, storage, image)
* fix(deps): update module golang.org/x/term to v0.22.0
* fix(deps): update module golang.org/x/sys to v0.22.0
* fix(deps): update golang.org/x/exp digest to 7f521ea
* fix(deps): update github.com/containers/luksy digest to a8846e2
* imagebuildah.StageExecutor.Copy(): reject new flags for now
* bump github.com/openshift/imagebuilder to v1.2.11
* Rework parsing of --pull flags
* fix(deps): update module github.com/containers/image/v5 to v5.31.1
* imagebuildah.StageExecutor.prepare(): log the --platform flag
* CI VMs: bump
* buildah copy: preserve owner info with --from= a container or image
* conformance tests: enable testing CompatSetParent
* containerImageRef.NewImageSource(): move the FROM comment to first
* commit: set "parent" for docker format only when requested
* Update godoc for Builder.EnsureContainerPathAs
* fix(deps): update module github.com/spf13/cobra to v1.8.1
* fix(deps): update module github.com/containernetworking/cni to v1.2.0
* fix(deps): update module github.com/opencontainers/runc to v1.1.13
* Change default for podman build to --pull missing
* fix(deps): update module github.com/containers/common to v0.59.1
* Clarify definition of --pull options
* buildah: fix a nil pointer reference on FreeBSD
* Use /var/tmp for $TMPDIR for vfs conformance jobs
* Cirrus: run `df` during job setup
* conformance: use quay.io/libpod/centos:7 instead of centos:8
* Stop setting "parent" in docker format
* conformance: check if workdir trims path separator suffixes
* push integration test: pass password to docker login via stdin
* Re-enable the "copy with chown" conformance test
* healthcheck: Add support for `--start-interval`
* fix(deps): update module github.com/docker/docker to v26.1.4+incompatible
* fix(deps): update module github.com/containerd/containerd to v1.7.18
* tests: set _CONTAINERS_USERNS_CONFIGURED=done for libnetwork
* Cross-build on Fedora
* Drop copyStringSlice() and copyStringStringMap()
* fix(deps): update module golang.org/x/crypto to v0.24.0
* fix(deps): update module github.com/openshift/imagebuilder to v1.2.10
* Provide an uptime_netbsd.go
* Spell unix as "!windows"
* Add netbsd to lists-of-OSes
* fix(deps): update golang.org/x/exp digest to fd00a4e
* [skip-ci] Packit: enable c10s downstream sync
* CI VMs: bump, to debian with cgroups v2
* Document when BlobDirectory is overridden
* fix secret mounts for env vars when using chroot isolation
* Change to take a types.ImageReference arg
* imagebuildah: Support custom image reference lookup for cache push/pull
* fix(deps): update module github.com/onsi/ginkgo/v2 to v2.19.0
* Bump to v1.37.0-dev
* CI: Clarify Debian use for conformance tests
- Changelog for v1.36.0 (2024-05-23)
* build: be more selective about specifying the default OS
* Bump to c/common v0.59.0
* Fix buildah prune --help showing the same example twice
* fix(deps): update module github.com/onsi/ginkgo/v2 to v2.18.0
* fix(deps): update module github.com/containers/image/v5 to v5.31.0
* bud tests: fix breakage when vendoring into podman
* Integration tests: fake up a replacement for nixery.dev/shell
* copierWithSubprocess(): try to capture stderr on io.ErrClosedPipe
* Don't expand RUN heredocs ourselves, let the shell do it
* Don't leak temp files on failures
* Add release note template to split dependency chores
* fix CentOS/RHEL build - no BATS there
* fix(deps): update module github.com/containers/luksy to v0.0.0-20240506205542-84b50f50f3ee
* Address CVE-2024-3727
* chore(deps): update module github.com/opencontainers/runtime-spec to v1.2.0
* Builder.cdiSetupDevicesInSpecdefConfig(): use configured CDI dirs
* Setting --arch should set the TARGETARCH build arg
* fix(deps): update module golang.org/x/exp to v0.0.0-20240416160154-fe59bbe5cc7f
* [CI:DOCS] Add link to Buildah image page to README.md
* Don't set GOTOOLCHAIN=local
* fix(deps): update module github.com/cyphar/filepath-securejoin to v0.2.5
* Makefile: set GOTOOLCHAIN=local
* Integration tests: switch some base images
* containerImageRef.NewImageSource: merge the tar filters
* fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.2
* fix(deps): update module github.com/containers/luksy to v0.0.0-20240408185936-afd8e7619947
* Disable packit builds for centos-stream+epel-next-8
* Makefile: add missing files to $(SOURCES)
* CI VMs: bump to new versions with tmpfs /tmp
* chore(deps): update module golang.org/x/net to v0.23.0 [security]
* integration test: handle new labels in "bud and test --unsetlabel"
* Switch packit configuration to use epel-9-$arch ...
* Give unit tests a bit more time
* Integration tests: remove a couple of duplicated tests
* Integration tests: whitespace tweaks
* Integration tests: don't remove images at start or end of test
* Integration tests: use cached images more
* Integration tests _prefetch: use registry configs
* internal: use fileutils.(Le|E)xists
* pkg/parse: use fileutils.(Le|E)xists
* buildah: use fileutils.(Le|E)xists
* chroot: use fileutils.(Le|E)xists
* vendor: update containers/(common|storage)
* Fix issue/pr lock workflow
* [CI:DOCS] Add golang 1.21 update warning
* heredoc: honor inline COPY irrespective of ignorefiles
* Update install.md
* source-push: add support for --digestfile
* Fix caching when mounting a cached stage with COPY/ADD
* fix(deps): update github.com/containers/luksy digest to 3d2cf0e
* Makefile: softcode `strip`, use it from env var
* Man page updates
* Add support for passing CDI specs to --device
* Update comments on some API objects
* pkg/parse.DeviceFromPath(): dereference src symlinks
* fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.1
- Changelog for v1.35.0 (2024-03-06)
* fix(deps): update module github.com/stretchr/testify to v1.9.0
* cgroups: reuse version check from c/common

View File

@ -1,47 +0,0 @@
//go:build linux
// +build linux
package chroot
import (
"fmt"
"os"
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)
// Open a PTY using the /dev/ptmx device. The main advantage of using
// this instead of posix_openpt is that it avoids cgo.
func getPtyDescriptors() (int, int, error) {
// Create a pseudo-terminal -- open a copy of the master side.
controlFd, err := unix.Open("/dev/ptmx", os.O_RDWR, 0600)
if err != nil {
return -1, -1, fmt.Errorf("opening PTY master using /dev/ptmx: %v", err)
}
// Set the kernel's lock to "unlocked".
locked := 0
if result, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(controlFd), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&locked))); int(result) == -1 {
return -1, -1, fmt.Errorf("unlocking PTY descriptor: %v", err)
}
// Get a handle for the other end.
ptyFd, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(controlFd), unix.TIOCGPTPEER, unix.O_RDWR|unix.O_NOCTTY)
if int(ptyFd) == -1 {
if errno, isErrno := err.(syscall.Errno); !isErrno || (errno != syscall.EINVAL && errno != syscall.ENOTTY) {
return -1, -1, fmt.Errorf("getting PTY descriptor: %v", err)
}
// EINVAL means the kernel's too old to understand TIOCGPTPEER. Try TIOCGPTN.
ptyN, err := unix.IoctlGetInt(controlFd, unix.TIOCGPTN)
if err != nil {
return -1, -1, fmt.Errorf("getting PTY number: %v", err)
}
ptyName := fmt.Sprintf("/dev/pts/%d", ptyN)
fd, err := unix.Open(ptyName, unix.O_RDWR|unix.O_NOCTTY, 0620)
if err != nil {
return -1, -1, fmt.Errorf("opening PTY %q: %v", ptyName, err)
}
ptyFd = uintptr(fd)
}
return controlFd, int(ptyFd), nil
}

View File

@ -1,13 +0,0 @@
//go:build !linux && !(freebsd && cgo)
// +build !linux
// +build !freebsd !cgo
package chroot
import (
"errors"
)
func getPtyDescriptors() (int, int, error) {
return -1, -1, errors.New("getPtyDescriptors not supported on this platform")
}

View File

@ -1,5 +1,4 @@
//go:build linux || freebsd
// +build linux freebsd
package chroot
@ -19,6 +18,7 @@ import (
"syscall"
"github.com/containers/buildah/bind"
"github.com/containers/buildah/internal/pty"
"github.com/containers/buildah/util"
"github.com/containers/storage/pkg/ioutils"
"github.com/containers/storage/pkg/reexec"
@ -49,12 +49,13 @@ func init() {
type runUsingChrootExecSubprocOptions struct {
Spec *specs.Spec
BundlePath string
NoPivot bool
}
// RunUsingChroot runs a chrooted process, using some of the settings from the
// passed-in spec, and using the specified bundlePath to hold temporary files,
// directories, and mountpoints.
func RunUsingChroot(spec *specs.Spec, bundlePath, homeDir string, stdin io.Reader, stdout, stderr io.Writer) (err error) {
func RunUsingChroot(spec *specs.Spec, bundlePath, homeDir string, stdin io.Reader, stdout, stderr io.Writer, noPivot bool) (err error) {
var confwg sync.WaitGroup
var homeFound bool
for _, env := range spec.Process.Env {
@ -74,7 +75,7 @@ func RunUsingChroot(spec *specs.Spec, bundlePath, homeDir string, stdin io.Reade
if err != nil {
return err
}
if err = ioutils.AtomicWriteFile(filepath.Join(bundlePath, "config.json"), specbytes, 0600); err != nil {
if err = ioutils.AtomicWriteFile(filepath.Join(bundlePath, "config.json"), specbytes, 0o600); err != nil {
return fmt.Errorf("storing runtime configuration: %w", err)
}
logrus.Debugf("config = %v", string(specbytes))
@ -98,6 +99,7 @@ func RunUsingChroot(spec *specs.Spec, bundlePath, homeDir string, stdin io.Reade
config, conferr := json.Marshal(runUsingChrootSubprocOptions{
Spec: spec,
BundlePath: bundlePath,
NoPivot: noPivot,
})
if conferr != nil {
return fmt.Errorf("encoding configuration for %q: %w", runUsingChrootCommand, conferr)
@ -197,6 +199,7 @@ func runUsingChrootMain() {
fmt.Fprintf(os.Stderr, "invalid options spec in runUsingChrootMain\n")
os.Exit(1)
}
noPivot := options.NoPivot
// Prepare to shuttle stdio back and forth.
rootUID32, rootGID32, err := util.GetHostRootIDs(options.Spec)
@ -215,7 +218,7 @@ func runUsingChrootMain() {
var stderr io.Writer
fdDesc := make(map[int]string)
if options.Spec.Process.Terminal {
ptyMasterFd, ptyFd, err := getPtyDescriptors()
ptyMasterFd, ptyFd, err := pty.GetPtyDescriptors()
if err != nil {
logrus.Errorf("error opening PTY descriptors: %v", err)
os.Exit(1)
@ -266,7 +269,7 @@ func runUsingChrootMain() {
logrus.Warnf("error %s ownership of container PTY %sto %d/%d: %v", op, from, rootUID, rootGID, err)
}
// Set permissions on the PTY.
if err = ctty.Chmod(0620); err != nil {
if err = ctty.Chmod(0o620); err != nil {
logrus.Errorf("error setting permissions of container PTY: %v", err)
os.Exit(1)
}
@ -443,7 +446,7 @@ func runUsingChrootMain() {
}()
// Set up mounts and namespaces, and run the parent subprocess.
status, err := runUsingChroot(options.Spec, options.BundlePath, ctty, stdin, stdout, stderr, closeOnceRunning)
status, err := runUsingChroot(options.Spec, options.BundlePath, ctty, stdin, stdout, stderr, noPivot, closeOnceRunning)
if err != nil {
fmt.Fprintf(os.Stderr, "error running subprocess: %v\n", err)
os.Exit(1)
@ -464,7 +467,7 @@ func runUsingChrootMain() {
// runUsingChroot, still in the grandparent process, sets up various bind
// mounts and then runs the parent process in its own user namespace with the
// necessary ID mappings.
func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io.Reader, stdout, stderr io.Writer, closeOnceRunning []*os.File) (wstatus unix.WaitStatus, err error) {
func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io.Reader, stdout, stderr io.Writer, noPivot bool, closeOnceRunning []*os.File) (wstatus unix.WaitStatus, err error) {
var confwg sync.WaitGroup
// Create a new mount namespace for ourselves and bind mount everything to a new location.
@ -497,9 +500,10 @@ func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io
config, conferr := json.Marshal(runUsingChrootExecSubprocOptions{
Spec: spec,
BundlePath: bundlePath,
NoPivot: noPivot,
})
if conferr != nil {
fmt.Fprintf(os.Stderr, "error re-encoding configuration for %q", runUsingChrootExecCommand)
fmt.Fprintf(os.Stderr, "error re-encoding configuration for %q\n", runUsingChrootExecCommand)
os.Exit(1)
}
@ -526,7 +530,6 @@ func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io
cmd.ExtraFiles = append([]*os.File{preader}, cmd.ExtraFiles...)
if err := setPlatformUnshareOptions(spec, cmd); err != nil {
return 1, fmt.Errorf("setting platform unshare options: %w", err)
}
interrupted := make(chan os.Signal, 100)
cmd.Hook = func(int) error {
@ -569,7 +572,7 @@ func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io
}
}
}
fmt.Fprintf(os.Stderr, "process exited with error: %v", err)
fmt.Fprintf(os.Stderr, "process exited with error: %v\n", err)
os.Exit(1)
}
@ -621,8 +624,10 @@ func runUsingChrootExecMain() {
// Try to chroot into the root. Do this before we potentially
// block the syscall via the seccomp profile. Allow the
// platform to override this - on FreeBSD, we use a simple
// jail to set the hostname in the container
// jail to set the hostname in the container, and on Linux
// we attempt to pivot_root.
if err := createPlatformContainer(options); err != nil {
logrus.Debugf("createPlatformContainer: %v", err)
var oldst, newst unix.Stat_t
if err := unix.Stat(options.Spec.Root.Path, &oldst); err != nil {
fmt.Fprintf(os.Stderr, "error stat()ing intended root directory %q: %v\n", options.Spec.Root.Path, err)
@ -697,7 +702,7 @@ func runUsingChrootExecMain() {
}
logrus.Debugf("setting supplemental groups")
if err = syscall.Setgroups(gids); err != nil {
fmt.Fprintf(os.Stderr, "error setting supplemental groups list: %v", err)
fmt.Fprintf(os.Stderr, "error setting supplemental groups list: %v\n", err)
os.Exit(1)
}
} else {
@ -705,7 +710,7 @@ func runUsingChrootExecMain() {
if strings.Trim(string(setgroups), "\n") != "deny" {
logrus.Debugf("clearing supplemental groups")
if err = syscall.Setgroups([]int{}); err != nil {
fmt.Fprintf(os.Stderr, "error clearing supplemental groups list: %v", err)
fmt.Fprintf(os.Stderr, "error clearing supplemental groups list: %v\n", err)
os.Exit(1)
}
}
@ -713,7 +718,7 @@ func runUsingChrootExecMain() {
logrus.Debugf("setting gid")
if err = unix.Setresgid(int(user.GID), int(user.GID), int(user.GID)); err != nil {
fmt.Fprintf(os.Stderr, "error setting GID: %v", err)
fmt.Fprintf(os.Stderr, "error setting GID: %v\n", err)
os.Exit(1)
}
@ -734,7 +739,7 @@ func runUsingChrootExecMain() {
logrus.Debugf("setting uid")
if err = unix.Setresuid(int(user.UID), int(user.UID), int(user.UID)); err != nil {
fmt.Fprintf(os.Stderr, "error setting UID: %v", err)
fmt.Fprintf(os.Stderr, "error setting UID: %v\n", err)
os.Exit(1)
}
@ -747,7 +752,7 @@ func runUsingChrootExecMain() {
logrus.Debugf("Running %#v (PATH = %q)", cmd, os.Getenv("PATH"))
interrupted := make(chan os.Signal, 100)
if err = cmd.Start(); err != nil {
fmt.Fprintf(os.Stderr, "process failed to start with error: %v", err)
fmt.Fprintf(os.Stderr, "process failed to start with error: %v\n", err)
}
go func() {
for range interrupted {
@ -774,7 +779,7 @@ func runUsingChrootExecMain() {
}
}
}
fmt.Fprintf(os.Stderr, "process exited with error: %v", err)
fmt.Fprintf(os.Stderr, "process exited with error: %v\n", err)
os.Exit(1)
}
}

View File

@ -1,11 +1,12 @@
//go:build freebsd
// +build freebsd
package chroot
import (
"errors"
"fmt"
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
@ -13,6 +14,7 @@ import (
"syscall"
"github.com/containers/buildah/pkg/jail"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/mount"
"github.com/containers/storage/pkg/unshare"
"github.com/opencontainers/runtime-spec/specs-go"
@ -39,6 +41,7 @@ var (
type runUsingChrootSubprocOptions struct {
Spec *specs.Spec
BundlePath string
NoPivot bool
}
func setPlatformUnshareOptions(spec *specs.Spec, cmd *unshare.Cmd) error {
@ -178,9 +181,9 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
}
}
target := filepath.Join(spec.Root.Path, m.Destination)
if _, err := os.Stat(target); err != nil {
if err := fileutils.Exists(target); err != nil {
// If the target can't be stat()ted, check the error.
if !os.IsNotExist(err) {
if !errors.Is(err, fs.ErrNotExist) {
return undoBinds, fmt.Errorf("examining %q for mounting in mount namespace: %w", target, err)
}
// The target isn't there yet, so create it, and make a
@ -188,12 +191,12 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
// XXX: This was copied from the linux version which supports bind mounting files.
// Leaving it here since I plan to add this to FreeBSD's nullfs.
if m.Type != "nullfs" || srcinfo.IsDir() {
if err = os.MkdirAll(target, 0111); err != nil {
if err = os.MkdirAll(target, 0o111); err != nil {
return undoBinds, fmt.Errorf("creating mountpoint %q in mount namespace: %w", target, err)
}
removes = append(removes, target)
} else {
if err = os.MkdirAll(filepath.Dir(target), 0111); err != nil {
if err = os.MkdirAll(filepath.Dir(target), 0o111); err != nil {
return undoBinds, fmt.Errorf("ensuring parent of mountpoint %q (%q) is present in mount namespace: %w", target, filepath.Dir(target), err)
}
// Don't do this until we can support file mounts in nullfs
@ -211,12 +214,12 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
// Do the bind mount.
if !srcinfo.IsDir() {
logrus.Debugf("emulating file mount %q on %q", m.Source, target)
_, err := os.Stat(target)
err := fileutils.Exists(target)
if err == nil {
save := saveDir(spec, target)
if _, err := os.Stat(save); err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(save, 0111)
if err := fileutils.Exists(save); err != nil {
if errors.Is(err, fs.ErrNotExist) {
err = os.MkdirAll(save, 0o111)
}
if err != nil {
return undoBinds, fmt.Errorf("creating file mount save directory %q: %w", save, err)
@ -224,7 +227,7 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
removes = append(removes, save)
}
savePath := filepath.Join(save, filepath.Base(target))
if _, err := os.Stat(target); err == nil {
if err := fileutils.Exists(target); err == nil {
logrus.Debugf("moving %q to %q", target, savePath)
if err := os.Rename(target, savePath); err != nil {
return undoBinds, fmt.Errorf("moving %q to %q: %w", target, savePath, err)

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package chroot
@ -9,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"strings"
"syscall"
"time"
@ -16,10 +16,10 @@ import (
"github.com/containers/buildah/copier"
"github.com/containers/storage/pkg/mount"
"github.com/containers/storage/pkg/unshare"
"github.com/moby/sys/capability"
"github.com/opencontainers/runc/libcontainer/apparmor"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"github.com/syndtr/gocapability/capability"
"golang.org/x/sys/unix"
)
@ -43,11 +43,86 @@ var (
"RLIMIT_STACK": unix.RLIMIT_STACK,
}
rlimitsReverseMap = map[int]string{}
mountFlagMap = map[int]string{
unix.MS_ACTIVE: "MS_ACTIVE",
unix.MS_BIND: "MS_BIND",
unix.MS_BORN: "MS_BORN",
unix.MS_DIRSYNC: "MS_DIRSYNC",
unix.MS_KERNMOUNT: "MS_KERNMOUNT",
unix.MS_LAZYTIME: "MS_LAZYTIME",
unix.MS_MANDLOCK: "MS_MANDLOCK",
unix.MS_MOVE: "MS_MOVE",
unix.MS_NOATIME: "MS_NOATIME",
unix.MS_NODEV: "MS_NODEV",
unix.MS_NODIRATIME: "MS_NODIRATIME",
unix.MS_NOEXEC: "MS_NOEXEC",
unix.MS_NOREMOTELOCK: "MS_NOREMOTELOCK",
unix.MS_NOSEC: "MS_NOSEC",
unix.MS_NOSUID: "MS_NOSUID",
unix.MS_NOSYMFOLLOW: "MS_NOSYMFOLLOW",
unix.MS_NOUSER: "MS_NOUSER",
unix.MS_POSIXACL: "MS_POSIXACL",
unix.MS_PRIVATE: "MS_PRIVATE",
unix.MS_RDONLY: "MS_RDONLY",
unix.MS_REC: "MS_REC",
unix.MS_RELATIME: "MS_RELATIME",
unix.MS_REMOUNT: "MS_REMOUNT",
unix.MS_SHARED: "MS_SHARED",
unix.MS_SILENT: "MS_SILENT",
unix.MS_SLAVE: "MS_SLAVE",
unix.MS_STRICTATIME: "MS_STRICTATIME",
unix.MS_SUBMOUNT: "MS_SUBMOUNT",
unix.MS_SYNCHRONOUS: "MS_SYNCHRONOUS",
unix.MS_UNBINDABLE: "MS_UNBINDABLE",
}
statFlagMap = map[int]string{
unix.ST_MANDLOCK: "ST_MANDLOCK",
unix.ST_NOATIME: "ST_NOATIME",
unix.ST_NODEV: "ST_NODEV",
unix.ST_NODIRATIME: "ST_NODIRATIME",
unix.ST_NOEXEC: "ST_NOEXEC",
unix.ST_NOSUID: "ST_NOSUID",
unix.ST_RDONLY: "ST_RDONLY",
unix.ST_RELATIME: "ST_RELATIME",
unix.ST_SYNCHRONOUS: "ST_SYNCHRONOUS",
}
)
func mountFlagNames(flags uintptr) []string {
var names []string
for flag, name := range mountFlagMap {
if int(flags)&flag == flag {
names = append(names, name)
flags = flags &^ (uintptr(flag))
}
}
if flags != 0 { // got some unknown leftovers
names = append(names, fmt.Sprintf("%#x", flags))
}
slices.Sort(names)
return names
}
func statFlagNames(flags uintptr) []string {
var names []string
flags = flags & ^uintptr(0x20) // mask off ST_VALID
for flag, name := range statFlagMap {
if int(flags)&flag == flag {
names = append(names, name)
flags = flags &^ (uintptr(flag))
}
}
if flags != 0 { // got some unknown leftovers
names = append(names, fmt.Sprintf("%#x", flags))
}
slices.Sort(names)
return names
}
type runUsingChrootSubprocOptions struct {
Spec *specs.Spec
BundlePath string
NoPivot bool
UIDMappings []syscall.SysProcIDMap
GIDMappings []syscall.SysProcIDMap
}
@ -61,14 +136,14 @@ func setPlatformUnshareOptions(spec *specs.Spec, cmd *unshare.Cmd) error {
uidmap, gidmap := spec.Linux.UIDMappings, spec.Linux.GIDMappings
if len(uidmap) == 0 {
// No UID mappings are configured for the container. Borrow our parent's mappings.
uidmap = append([]specs.LinuxIDMapping{}, hostUidmap...)
uidmap = slices.Clone(hostUidmap)
for i := range uidmap {
uidmap[i].HostID = uidmap[i].ContainerID
}
}
if len(gidmap) == 0 {
// No GID mappings are configured for the container. Borrow our parent's mappings.
gidmap = append([]specs.LinuxIDMapping{}, hostGidmap...)
gidmap = slices.Clone(hostGidmap)
for i := range gidmap {
gidmap[i].HostID = gidmap[i].ContainerID
}
@ -179,39 +254,39 @@ func setCapabilities(spec *specs.Spec, keepCaps ...string) error {
capMap := map[capability.CapType][]string{
capability.BOUNDING: spec.Process.Capabilities.Bounding,
capability.EFFECTIVE: spec.Process.Capabilities.Effective,
capability.INHERITABLE: []string{},
capability.INHERITABLE: {},
capability.PERMITTED: spec.Process.Capabilities.Permitted,
capability.AMBIENT: spec.Process.Capabilities.Ambient,
capability.AMBIENT: {},
}
knownCaps := capability.List()
knownCaps := capability.ListKnown()
noCap := capability.Cap(-1)
for capType, capList := range capMap {
for _, capToSet := range capList {
cap := noCap
for _, capSpec := range capList {
capToSet := noCap
for _, c := range knownCaps {
if strings.EqualFold("CAP_"+c.String(), capToSet) {
cap = c
if strings.EqualFold("CAP_"+c.String(), capSpec) {
capToSet = c
break
}
}
if cap == noCap {
return fmt.Errorf("mapping capability %q to a number", capToSet)
if capToSet == noCap {
return fmt.Errorf("mapping capability %q to a number", capSpec)
}
caps.Set(capType, cap)
caps.Set(capType, capToSet)
}
for _, capToSet := range keepCaps {
cap := noCap
for _, capSpec := range keepCaps {
capToSet := noCap
for _, c := range knownCaps {
if strings.EqualFold("CAP_"+c.String(), capToSet) {
cap = c
if strings.EqualFold("CAP_"+c.String(), capSpec) {
capToSet = c
break
}
}
if cap == noCap {
return fmt.Errorf("mapping capability %q to a number", capToSet)
if capToSet == noCap {
return fmt.Errorf("mapping capability %q to a number", capSpec)
}
if currentCaps.Get(capType, cap) {
caps.Set(capType, cap)
if currentCaps.Get(capType, capToSet) {
caps.Set(capType, capToSet)
}
}
}
@ -226,7 +301,56 @@ func makeRlimit(limit specs.POSIXRlimit) unix.Rlimit {
}
func createPlatformContainer(options runUsingChrootExecSubprocOptions) error {
return errors.New("unsupported createPlatformContainer")
if options.NoPivot {
return errors.New("not using pivot_root()")
}
// borrowing a technique from runc, who credit the LXC maintainers for this
// open descriptors for the old and new root directories so that we can use fchdir()
oldRootFd, err := unix.Open("/", unix.O_DIRECTORY, 0)
if err != nil {
return fmt.Errorf("opening host root directory: %w", err)
}
defer func() {
if err := unix.Close(oldRootFd); err != nil {
logrus.Warnf("closing host root directory: %v", err)
}
}()
newRootFd, err := unix.Open(options.Spec.Root.Path, unix.O_DIRECTORY, 0)
if err != nil {
return fmt.Errorf("opening container root directory: %w", err)
}
defer func() {
if err := unix.Close(newRootFd); err != nil {
logrus.Warnf("closing container root directory: %v", err)
}
}()
// change to the new root directory
if err := unix.Fchdir(newRootFd); err != nil {
return fmt.Errorf("changing to container root directory: %w", err)
}
// this makes the current directory the root directory. not actually
// sure what happens to the other one
if err := unix.PivotRoot(".", "."); err != nil {
return fmt.Errorf("pivot_root: %w", err)
}
// go back and clean up the old one
if err := unix.Fchdir(oldRootFd); err != nil {
return fmt.Errorf("changing to host root directory: %w", err)
}
// make sure we only unmount things under this tree
if err := unix.Mount(".", ".", "", unix.MS_SLAVE|unix.MS_REC, ""); err != nil {
return fmt.Errorf("tweaking mount flags on host root directory before unmounting from mount namespace: %w", err)
}
// detach this (unnamed?) old directory
if err := unix.Unmount(".", unix.MNT_DETACH); err != nil {
return fmt.Errorf("unmounting host root directory in mount namespace: %w", err)
}
// go back to a named root directory
if err := unix.Fchdir(newRootFd); err != nil {
return fmt.Errorf("changing to container root directory at last: %w", err)
}
logrus.Debugf("pivot_root()ed into %q", options.Spec.Root.Path)
return nil
}
func mountFlagsForFSFlags(fsFlags uintptr) uintptr {
@ -302,7 +426,7 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
subDev := filepath.Join(spec.Root.Path, "/dev")
if err := unix.Mount("/dev", subDev, "bind", devFlags, ""); err != nil {
if errors.Is(err, os.ErrNotExist) {
err = os.Mkdir(subDev, 0755)
err = os.Mkdir(subDev, 0o755)
if err == nil {
err = unix.Mount("/dev", subDev, "bind", devFlags, "")
}
@ -326,7 +450,7 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
subProc := filepath.Join(spec.Root.Path, "/proc")
if err := unix.Mount("/proc", subProc, "bind", procFlags, ""); err != nil {
if errors.Is(err, os.ErrNotExist) {
err = os.Mkdir(subProc, 0755)
err = os.Mkdir(subProc, 0o755)
if err == nil {
err = unix.Mount("/proc", subProc, "bind", procFlags, "")
}
@ -341,7 +465,7 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
subSys := filepath.Join(spec.Root.Path, "/sys")
if err := unix.Mount("/sys", subSys, "bind", sysFlags, ""); err != nil {
if errors.Is(err, os.ErrNotExist) {
err = os.Mkdir(subSys, 0755)
err = os.Mkdir(subSys, 0o755)
if err == nil {
err = unix.Mount("/sys", subSys, "bind", sysFlags, "")
}
@ -364,9 +488,9 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
if err := unix.Mount(m.Mountpoint, subSys, "bind", sysFlags, ""); err != nil {
msg := fmt.Sprintf("could not bind mount %q, skipping: %v", m.Mountpoint, err)
if strings.HasPrefix(m.Mountpoint, "/sys") {
logrus.Infof(msg)
logrus.Info(msg)
} else {
logrus.Warningf(msg)
logrus.Warning(msg)
}
continue
}
@ -433,15 +557,15 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
// The target isn't there yet, so create it. If the source is a directory,
// we need a directory, otherwise we need a non-directory (i.e., a file).
if srcinfo.IsDir() {
if err = os.MkdirAll(target, 0755); err != nil {
if err = os.MkdirAll(target, 0o755); err != nil {
return undoBinds, fmt.Errorf("creating mountpoint %q in mount namespace: %w", target, err)
}
} else {
if err = os.MkdirAll(filepath.Dir(target), 0755); err != nil {
if err = os.MkdirAll(filepath.Dir(target), 0o755); err != nil {
return undoBinds, fmt.Errorf("ensuring parent of mountpoint %q (%q) is present in mount namespace: %w", target, filepath.Dir(target), err)
}
var file *os.File
if file, err = os.OpenFile(target, os.O_WRONLY|os.O_CREATE, 0755); err != nil {
if file, err = os.OpenFile(target, os.O_WRONLY|os.O_CREATE, 0o755); err != nil {
return undoBinds, fmt.Errorf("creating mountpoint %q in mount namespace: %w", target, err)
}
file.Close()
@ -518,16 +642,21 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
if effectiveImportantFlags != expectedImportantFlags {
// Do a remount to try to get the desired flags to stick.
effectiveUnimportantFlags := uintptr(fs.Flags) & ^possibleImportantFlags
if err = unix.Mount(target, target, m.Type, unix.MS_REMOUNT|bindFlags|requestFlags|mountFlagsForFSFlags(effectiveUnimportantFlags), ""); err != nil {
return undoBinds, fmt.Errorf("remounting %q in mount namespace with flags %#x instead of %#x: %w", target, requestFlags, effectiveImportantFlags, err)
remountFlags := unix.MS_REMOUNT | bindFlags | requestFlags | mountFlagsForFSFlags(effectiveUnimportantFlags)
// If we are requesting a read-only mount, add any possibleImportantFlags present in fs.Flags to remountFlags.
if requestFlags&unix.ST_RDONLY == unix.ST_RDONLY {
remountFlags |= uintptr(fs.Flags) & possibleImportantFlags
}
if err = unix.Mount(target, target, m.Type, remountFlags, ""); err != nil {
return undoBinds, fmt.Errorf("remounting %q in mount namespace with flags %v instead of %v: %w", target, mountFlagNames(requestFlags), statFlagNames(effectiveImportantFlags), err)
}
// Check if the desired flags stuck.
if err = unix.Statfs(target, &fs); err != nil {
return undoBinds, fmt.Errorf("checking if directory %q was remounted with requested flags %#x instead of %#x: %w", target, requestFlags, effectiveImportantFlags, err)
return undoBinds, fmt.Errorf("checking if directory %q was remounted with requested flags %v instead of %v: %w", target, mountFlagNames(requestFlags), statFlagNames(effectiveImportantFlags), err)
}
newEffectiveImportantFlags := uintptr(fs.Flags) & importantFlags
if newEffectiveImportantFlags != expectedImportantFlags {
return undoBinds, fmt.Errorf("unable to remount %q with requested flags %#x instead of %#x, just got %#x back", target, requestFlags, effectiveImportantFlags, newEffectiveImportantFlags)
return undoBinds, fmt.Errorf("unable to remount %q with requested flags %v instead of %v, just got %v back", target, mountFlagNames(requestFlags), statFlagNames(effectiveImportantFlags), statFlagNames(newEffectiveImportantFlags))
}
}
}
@ -589,7 +718,7 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func(
// Create an empty directory for to use for masking directories.
roEmptyDir := filepath.Join(bundlePath, "empty")
if len(spec.Linux.MaskedPaths) > 0 {
if err := os.Mkdir(roEmptyDir, 0700); err != nil {
if err := os.Mkdir(roEmptyDir, 0o700); err != nil {
return undoBinds, fmt.Errorf("creating empty directory %q: %w", roEmptyDir, err)
}
}

32
chroot/run_linux_test.go Normal file
View File

@ -0,0 +1,32 @@
package chroot
import (
"slices"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStatFlagNames(t *testing.T) {
var names []string
var flags int
for flag := range statFlagMap {
flags |= flag
names = append(names, statFlagMap[flag])
assert.Equal(t, []string{statFlagMap[flag]}, statFlagNames(uintptr(flag)))
}
slices.Sort(names)
assert.Equal(t, names, statFlagNames(uintptr(flags)))
}
func TestMountFlagNames(t *testing.T) {
var names []string
var flags int
for flag := range mountFlagMap {
flags |= flag
names = append(names, mountFlagMap[flag])
assert.Equal(t, []string{mountFlagMap[flag]}, mountFlagNames(uintptr(flag)))
}
slices.Sort(names)
assert.Equal(t, names, mountFlagNames(uintptr(flags)))
}

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package chroot
@ -10,6 +9,7 @@ import (
"io"
"os"
"path/filepath"
"slices"
"strconv"
"strings"
"testing"
@ -22,7 +22,6 @@ import (
"github.com/opencontainers/runtime-tools/generate"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/sys/unix"
)
@ -37,7 +36,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundleDir string), verify func(t *testing.T, report *types.TestReport)) {
func testMinimalWithPivot(t *testing.T, noPivot bool, modify func(g *generate.Generator, rootDir, bundleDir string), verify func(t *testing.T, report *types.TestReport)) {
t.Helper()
g, err := generate.New("linux")
if err != nil {
@ -50,17 +49,17 @@ func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundl
// t.TempDir returns /tmp/TestName/001.
// /tmp/TestName/001 has permission 0777, but /tmp/TestName is 0700
tempDir := t.TempDir()
if err = os.Chmod(filepath.Dir(tempDir), 0711); err != nil {
if err = os.Chmod(filepath.Dir(tempDir), 0o711); err != nil {
t.Fatalf("error loosening permissions on %q: %v", tempDir, err)
}
rootDir := filepath.Join(tempDir, "root")
if err := os.Mkdir(rootDir, 0711); err != nil {
if err := os.Mkdir(rootDir, 0o711); err != nil {
t.Fatalf("os.Mkdir(%q): %v", rootDir, err)
}
rootTmpDir := filepath.Join(rootDir, "tmp")
if err := os.Mkdir(rootTmpDir, 01777); err != nil {
if err := os.Mkdir(rootTmpDir, 0o1777); err != nil {
t.Fatalf("os.Mkdir(%q): %v", rootTmpDir, err)
}
@ -70,7 +69,7 @@ func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundl
t.Fatalf("open(%q): %v", specPath, err)
}
defer specBinarySource.Close()
specBinary, err := os.OpenFile(filepath.Join(rootDir, reportCommand), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0711)
specBinary, err := os.OpenFile(filepath.Join(rootDir, reportCommand), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o711)
if err != nil {
t.Fatalf("open(%q): %v", filepath.Join(rootDir, reportCommand), err)
}
@ -84,7 +83,7 @@ func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundl
g.SetProcessArgs([]string{"/" + reportCommand})
bundleDir := filepath.Join(tempDir, "bundle")
if err := os.Mkdir(bundleDir, 0700); err != nil {
if err := os.Mkdir(bundleDir, 0o700); err != nil {
t.Fatalf("os.Mkdir(%q): %v", bundleDir, err)
}
@ -101,8 +100,8 @@ func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundl
}
output := new(bytes.Buffer)
if err := RunUsingChroot(g.Config, bundleDir, "/", new(bytes.Buffer), output, output); err != nil {
t.Fatalf("run: %v: %s", err, output.String())
if err := RunUsingChroot(g.Config, bundleDir, "/", new(bytes.Buffer), output, output, noPivot); err != nil {
t.Fatalf("run(noPivot=%v): %v: %s", noPivot, err, output.String())
}
var report types.TestReport
@ -115,7 +114,16 @@ func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundl
}
}
func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundleDir string), verify func(t *testing.T, report *types.TestReport)) {
for _, noPivot := range []bool{false, true} {
t.Run(fmt.Sprintf("noPivot=%v", noPivot), func(t *testing.T) {
testMinimalWithPivot(t, noPivot, modify, verify)
})
}
}
func TestNoop(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
@ -123,24 +131,26 @@ func TestNoop(t *testing.T) {
}
func TestMinimalSkeleton(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(_ *generate.Generator, _, _ string) {
},
func(t *testing.T, report *types.TestReport) {
func(_ *testing.T, _ *types.TestReport) {
},
)
}
func TestProcessTerminal(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
for _, terminal := range []bool{false, true} {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.SetProcessTerminal(terminal)
},
func(t *testing.T, report *types.TestReport) {
@ -153,12 +163,13 @@ func TestProcessTerminal(t *testing.T) {
}
func TestProcessConsoleSize(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
for _, size := range [][2]uint{{80, 25}, {132, 50}} {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.SetProcessTerminal(true)
g.SetProcessConsoleSize(size[0], size[1])
},
@ -175,12 +186,13 @@ func TestProcessConsoleSize(t *testing.T) {
}
func TestProcessUser(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
for _, id := range []uint32{0, 1000} {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.SetProcessUID(id)
g.SetProcessGID(id + 1)
g.AddProcessAdditionalGid(id + 2)
@ -198,20 +210,19 @@ func TestProcessUser(t *testing.T) {
}
func TestProcessEnv(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
e := fmt.Sprintf("PARENT_TEST_PID=%d", unix.Getpid())
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.ClearProcessEnv()
g.AddProcessEnv("PARENT_TEST_PID", strconv.Itoa(unix.Getpid()))
},
func(t *testing.T, report *types.TestReport) {
for _, ev := range report.Spec.Process.Env {
if ev == e {
return
}
if slices.Contains(report.Spec.Process.Env, e) {
return
}
t.Fatalf("expected environment variable %q", e)
},
@ -219,12 +230,13 @@ func TestProcessEnv(t *testing.T) {
}
func TestProcessCwd(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
if err := os.Mkdir(filepath.Join(rootDir, "/no-such-directory"), 0700); err != nil {
func(g *generate.Generator, rootDir, _ string) {
if err := os.Mkdir(filepath.Join(rootDir, "/no-such-directory"), 0o700); err != nil {
t.Fatalf("mkdir(%q): %v", filepath.Join(rootDir, "/no-such-directory"), err)
}
g.SetProcessCwd("/no-such-directory")
@ -238,11 +250,12 @@ func TestProcessCwd(t *testing.T) {
}
func TestProcessCapabilities(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.ClearProcessCapabilities()
},
func(t *testing.T, report *types.TestReport) {
@ -252,7 +265,7 @@ func TestProcessCapabilities(t *testing.T) {
},
)
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.ClearProcessCapabilities()
if err := g.AddProcessCapabilityEffective("CAP_IPC_LOCK"); err != nil {
t.Fatalf("%v", err)
@ -282,12 +295,13 @@ func TestProcessCapabilities(t *testing.T) {
}
func TestProcessRlimits(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
for _, limit := range []uint64{100 * 1024 * 1024 * 1024, 200 * 1024 * 1024 * 1024, unix.RLIM_INFINITY} {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.ClearProcessRlimits()
if limit != unix.RLIM_INFINITY {
g.AddProcessRlimits("rlimit_as", limit, limit)
@ -300,7 +314,7 @@ func TestProcessRlimits(t *testing.T) {
rlim = &report.Spec.Process.Rlimits[i]
}
}
if limit == unix.RLIM_INFINITY && !(rlim == nil || (rlim.Soft == unix.RLIM_INFINITY && rlim.Hard == unix.RLIM_INFINITY)) {
if limit == unix.RLIM_INFINITY && rlim != nil && (rlim.Soft != unix.RLIM_INFINITY || rlim.Hard != unix.RLIM_INFINITY) {
t.Fatalf("wasn't supposed to set limit on number of open files: %#v", rlim)
}
if limit != unix.RLIM_INFINITY && rlim == nil {
@ -320,6 +334,7 @@ func TestProcessRlimits(t *testing.T) {
}
func TestProcessNoNewPrivileges(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
@ -328,7 +343,7 @@ func TestProcessNoNewPrivileges(t *testing.T) {
}
for _, nope := range []bool{false, true} {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.SetProcessNoNewPrivileges(nope)
},
func(t *testing.T, report *types.TestReport) {
@ -341,12 +356,13 @@ func TestProcessNoNewPrivileges(t *testing.T) {
}
func TestProcessOOMScoreAdj(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
for _, adj := range []int{0, 1, 2, 3} {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.SetProcessOOMScoreAdj(adj)
},
func(t *testing.T, report *types.TestReport) {
@ -363,12 +379,13 @@ func TestProcessOOMScoreAdj(t *testing.T) {
}
func TestHostname(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
hostname := fmt.Sprintf("host%d", unix.Getpid())
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.SetHostname(hostname)
},
func(t *testing.T, report *types.TestReport) {
@ -380,12 +397,13 @@ func TestHostname(t *testing.T) {
}
func TestMounts(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
t.Run("tmpfs", func(t *testing.T) {
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.AddMount(specs.Mount{
Source: "tmpfs",
Destination: "/was-not-there-before",
@ -432,7 +450,8 @@ func TestMounts(t *testing.T) {
name: "nosuid",
destination: "/nosuid",
options: []string{"nosuid"},
reject: []string{"suid"}},
reject: []string{"suid"},
},
{
name: "nodev,noexec",
destination: "/nodev,noexec",
@ -485,7 +504,7 @@ func TestMounts(t *testing.T) {
tmpfsFlags, tmpfsOptions := mount.ParseOptions(tmpfsOptions)
require.NoErrorf(t, unix.Mount("none", tmpfsMount, "tmpfs", uintptr(tmpfsFlags), tmpfsOptions), "error mounting a tmpfs with flags=%#x,options=%q at %s", tmpfsFlags, tmpfsOptions, tmpfsMount)
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
fsType := bind.fsType
if fsType == "" {
fsType = "bind"
@ -539,11 +558,12 @@ func TestMounts(t *testing.T) {
}
func TestLinuxIDMapping(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.ClearLinuxUIDMappings()
g.ClearLinuxGIDMappings()
g.AddLinuxUIDMapping(uint32(unix.Getuid()), 0, 1)
@ -576,11 +596,12 @@ func TestLinuxIDMapping(t *testing.T) {
}
func TestLinuxIDMappingShift(t *testing.T) {
t.Parallel()
if unix.Getuid() != 0 {
t.Skip("tests need to be run as root")
}
testMinimal(t,
func(g *generate.Generator, rootDir, bundleDir string) {
func(g *generate.Generator, _, _ string) {
g.ClearLinuxUIDMappings()
g.ClearLinuxGIDMappings()
g.AddLinuxUIDMapping(uint32(unix.Getuid())+1, 0, 1)

View File

@ -1,20 +1,15 @@
//go:build linux && seccomp
// +build linux,seccomp
package chroot
import (
"fmt"
"os"
"github.com/containers/common/pkg/seccomp"
specs "github.com/opencontainers/runtime-spec/specs-go"
libseccomp "github.com/seccomp/libseccomp-golang"
"github.com/sirupsen/logrus"
)
const seccompAvailable = true
// setSeccomp sets the seccomp filter for ourselves and any processes that we'll start.
func setSeccomp(spec *specs.Spec) error {
logrus.Debugf("setting seccomp configuration")
@ -179,27 +174,3 @@ func setSeccomp(spec *specs.Spec) error {
}
return nil
}
func setupSeccomp(spec *specs.Spec, seccompProfilePath string) error {
switch seccompProfilePath {
case "unconfined":
spec.Linux.Seccomp = nil
case "":
seccompConfig, err := seccomp.GetDefaultProfile(spec)
if err != nil {
return fmt.Errorf("loading default seccomp profile failed: %w", err)
}
spec.Linux.Seccomp = seccompConfig
default:
seccompProfile, err := os.ReadFile(seccompProfilePath)
if err != nil {
return fmt.Errorf("opening seccomp profile failed: %w", err)
}
seccompConfig, err := seccomp.LoadProfile(string(seccompProfile), spec)
if err != nil {
return fmt.Errorf("loading seccomp profile (%s) failed: %w", seccompProfilePath, err)
}
spec.Linux.Seccomp = seccompConfig
}
return nil
}

View File

@ -1,5 +1,4 @@
//go:build freebsd && seccomp
// +build freebsd,seccomp
package chroot

37
chroot/seccomp_test.go Normal file
View File

@ -0,0 +1,37 @@
//go:build linux && seccomp
package chroot
import (
"fmt"
"os"
"github.com/containers/common/pkg/seccomp"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
const seccompAvailable = true
func setupSeccomp(spec *specs.Spec, seccompProfilePath string) error {
switch seccompProfilePath {
case "unconfined":
spec.Linux.Seccomp = nil
case "":
seccompConfig, err := seccomp.GetDefaultProfile(spec)
if err != nil {
return fmt.Errorf("loading default seccomp profile failed: %w", err)
}
spec.Linux.Seccomp = seccompConfig
default:
seccompProfile, err := os.ReadFile(seccompProfilePath)
if err != nil {
return fmt.Errorf("opening seccomp profile failed: %w", err)
}
seccompConfig, err := seccomp.LoadProfile(string(seccompProfile), spec)
if err != nil {
return fmt.Errorf("loading seccomp profile (%s) failed: %w", seccompProfilePath, err)
}
spec.Linux.Seccomp = seccompConfig
}
return nil
}

View File

@ -1,5 +1,4 @@
//go:build (!linux && !freebsd) || !seccomp
// +build !linux,!freebsd !seccomp
package chroot
@ -9,19 +8,9 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
)
const seccompAvailable = false
func setSeccomp(spec *specs.Spec) error {
if spec.Linux.Seccomp != nil {
return errors.New("configured a seccomp filter without seccomp support?")
}
return nil
}
func setupSeccomp(spec *specs.Spec, seccompProfilePath string) error {
if spec.Linux != nil {
// runtime-tools may have supplied us with a default filter
spec.Linux.Seccomp = nil
}
return nil
}

View File

@ -0,0 +1,17 @@
//go:build (!linux && !freebsd) || !seccomp
package chroot
import (
"github.com/opencontainers/runtime-spec/specs-go"
)
const seccompAvailable = false
func setupSeccomp(spec *specs.Spec, _ string) error {
if spec.Linux != nil {
// runtime-tools may have supplied us with a default filter
spec.Linux.Seccomp = nil
}
return nil
}

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package chroot
@ -8,7 +7,6 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
selinux "github.com/opencontainers/selinux/go-selinux"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/sirupsen/logrus"
)
@ -16,7 +14,7 @@ import (
func setSelinuxLabel(spec *specs.Spec) error {
logrus.Debugf("setting selinux label")
if spec.Process.SelinuxLabel != "" && selinux.GetEnabled() {
if err := label.SetProcessLabel(spec.Process.SelinuxLabel); err != nil {
if err := selinux.SetExecLabel(spec.Process.SelinuxLabel); err != nil {
return fmt.Errorf("setting process label to %q: %w", spec.Process.SelinuxLabel, err)
}
}

View File

@ -1,5 +1,4 @@
//go:build !linux && !freebsd
// +build !linux,!freebsd
package chroot

View File

@ -1,5 +1,4 @@
//go:build !linux && !freebsd
// +build !linux,!freebsd
package chroot

View File

@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
@ -37,6 +38,10 @@ type addCopyResults struct {
certDir string
retry int
retryDelay string
excludes []string
parents bool
timestamp string
link bool
}
func createCommand(addCopy string, desc string, short string, opts *addCopyResults) *cobra.Command {
@ -48,7 +53,8 @@ func createCommand(addCopy string, desc string, short string, opts *addCopyResul
return addAndCopyCmd(cmd, args, strings.ToUpper(addCopy), *opts)
},
Example: `buildah ` + addCopy + ` containerID '/myapp/app.conf'
buildah ` + addCopy + ` containerID '/myapp/app.conf' '/myapp/app.conf'`,
buildah ` + addCopy + ` containerID 'app.conf' '/myapp/app.conf'
buildah ` + addCopy + ` containerID 'app.conf' 'drop-in.conf' '/myapp/app.conf.d/'`,
Args: cobra.MinimumNArgs(1),
}
}
@ -64,14 +70,12 @@ func applyFlagVars(flags *pflag.FlagSet, opts *addCopyResults) {
if err := flags.MarkHidden("blob-cache"); err != nil {
panic(fmt.Sprintf("error marking blob-cache as hidden: %v", err))
}
flags.StringVar(&opts.certDir, "cert-dir", "", "use certificates at the specified path to access registries")
if err := flags.MarkHidden("cert-dir"); err != nil {
panic(fmt.Sprintf("error marking cert-dir as hidden: %v", err))
}
flags.StringVar(&opts.certDir, "cert-dir", "", "use certificates at the specified path to access registries and sources in HTTPS locations")
flags.StringVar(&opts.checksum, "checksum", "", "checksum the HTTP source content")
flags.StringVar(&opts.chown, "chown", "", "set the user and group ownership of the destination content")
flags.StringVar(&opts.chmod, "chmod", "", "set the access permissions of the destination content")
flags.StringVar(&opts.creds, "creds", "", "use `[username[:password]]` for accessing registries when pulling images")
flags.BoolVar(&opts.link, "link", false, "enable layer caching for this operation (creates an independent layer)")
if err := flags.MarkHidden("creds"); err != nil {
panic(fmt.Sprintf("error marking creds as hidden: %v", err))
}
@ -80,15 +84,13 @@ func applyFlagVars(flags *pflag.FlagSet, opts *addCopyResults) {
if err := flags.MarkHidden("decryption-key"); err != nil {
panic(fmt.Sprintf("error marking decryption-key as hidden: %v", err))
}
flags.StringSliceVar(&opts.excludes, "exclude", nil, "exclude pattern when copying files")
flags.StringVar(&opts.ignoreFile, "ignorefile", "", "path to .containerignore file")
flags.StringVar(&opts.contextdir, "contextdir", "", "context directory path")
flags.IntVar(&opts.retry, "retry", cli.MaxPullPushRetries, "number of times to retry in case of failure when performing pull")
flags.StringVar(&opts.retryDelay, "retry-delay", cli.PullPushRetryDelay.String(), "delay between retries in case of pull failures")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "don't output a digest of the newly-added/copied content")
flags.BoolVar(&opts.tlsVerify, "tls-verify", true, "require HTTPS and verify certificates when accessing registries when pulling images. TLS verification cannot be used when talking to an insecure registry.")
if err := flags.MarkHidden("tls-verify"); err != nil {
panic(fmt.Sprintf("error marking tls-verify as hidden: %v", err))
}
flags.BoolVar(&opts.tlsVerify, "tls-verify", true, "require HTTPS and verify certificates when accessing registries when pulling images, and when retrieving sources from HTTPS URLs. TLS verification cannot be used when talking to an insecure registry.")
flags.BoolVarP(&opts.removeSignatures, "remove-signatures", "", false, "don't copy signatures when pulling image")
if err := flags.MarkHidden("remove-signatures"); err != nil {
panic(fmt.Sprintf("error marking remove-signatures as hidden: %v", err))
@ -97,6 +99,7 @@ func applyFlagVars(flags *pflag.FlagSet, opts *addCopyResults) {
if err := flags.MarkHidden("signature-policy"); err != nil {
panic(fmt.Sprintf("error marking signature-policy as hidden: %v", err))
}
flags.StringVar(&opts.timestamp, "timestamp", "", "set timestamps on new content to `seconds` after the epoch")
}
func init() {
@ -119,6 +122,7 @@ func init() {
copyFlags := copyCommand.Flags()
applyFlagVars(copyFlags, &copyOpts)
copyFlags.BoolVar(&copyOpts.parents, "parents", false, "preserve leading directories in the paths of items being copied")
rootCmd.AddCommand(addCommand)
rootCmd.AddCommand(copyCommand)
@ -160,13 +164,14 @@ func addAndCopyCmd(c *cobra.Command, args []string, verb string, iopts addCopyRe
return errors.New("--ignorefile option requires that you specify a context dir using --contextdir")
}
systemContext, err := parse.SystemContextFromOptions(c)
if err != nil {
return fmt.Errorf("building system context: %w", err)
}
var preserveOwnership bool
if iopts.from != "" {
if from, err = openBuilder(getContext(), store, iopts.from); err != nil && errors.Is(err, storage.ErrContainerUnknown) {
systemContext, err2 := parse.SystemContextFromOptions(c)
if err2 != nil {
return fmt.Errorf("building system context: %w", err2)
}
decryptConfig, err2 := cli.DecryptConfig(iopts.decryptionKeys)
if err2 != nil {
return fmt.Errorf("unable to obtain decrypt config: %w", err2)
@ -221,6 +226,7 @@ func addAndCopyCmd(c *cobra.Command, args []string, verb string, iopts addCopyRe
}
}()
idMappingOptions = &from.IDMappingOptions
preserveOwnership = true
contextdir = filepath.Join(fromMountPoint, iopts.contextdir)
for i := range args {
args[i] = filepath.Join(fromMountPoint, args[i])
@ -234,12 +240,32 @@ func addAndCopyCmd(c *cobra.Command, args []string, verb string, iopts addCopyRe
builder.ContentDigester.Restart()
var timestamp *time.Time
if iopts.timestamp != "" {
u, err := strconv.ParseInt(iopts.timestamp, 10, 64)
if err != nil {
return fmt.Errorf("parsing timestamp value %q: %w", iopts.timestamp, err)
}
t := time.Unix(u, 0).UTC()
timestamp = &t
}
options := buildah.AddAndCopyOptions{
Chmod: iopts.chmod,
Chown: iopts.chown,
Checksum: iopts.checksum,
ContextDir: contextdir,
IDMappingOptions: idMappingOptions,
Chmod: iopts.chmod,
Chown: iopts.chown,
PreserveOwnership: preserveOwnership,
Checksum: iopts.checksum,
ContextDir: contextdir,
Excludes: iopts.excludes,
IDMappingOptions: idMappingOptions,
// These next two fields are set based on command line flags
// with more generic-sounding names.
CertPath: systemContext.DockerCertPath,
InsecureSkipTLSVerify: systemContext.DockerInsecureSkipTLSVerify,
MaxRetries: iopts.retry,
Parents: iopts.parents,
Timestamp: timestamp,
Link: iopts.link,
}
if iopts.contextdir != "" {
var excludes []string
@ -248,7 +274,14 @@ func addAndCopyCmd(c *cobra.Command, args []string, verb string, iopts addCopyRe
if err != nil {
return err
}
options.Excludes = excludes
options.Excludes = append(excludes, options.Excludes...)
}
if iopts.retryDelay != "" {
retryDelay, err := time.ParseDuration(iopts.retryDelay)
if err != nil {
return fmt.Errorf("unable to parse value provided %q as --retry-delay: %w", iopts.retryDelay, err)
}
options.RetryDelay = retryDelay
}
extractLocalArchives := verb == "ADD"

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"github.com/containers/buildah/imagebuildah"
@ -71,9 +72,9 @@ func init() {
func buildCmd(c *cobra.Command, inputArgs []string, iopts buildahcli.BuildOptions) error {
if c.Flag("logfile").Changed {
logfile, err := os.OpenFile(iopts.Logfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
logfile, err := os.OpenFile(iopts.Logfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600)
if err != nil {
return err
return fmt.Errorf("opening log file: %w", err)
}
iopts.Logwriter = logfile
defer iopts.Logwriter.Close()

View File

@ -5,11 +5,13 @@ import (
"errors"
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/containers/buildah"
"github.com/containers/buildah/define"
"github.com/containers/buildah/internal"
"github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/buildah/util"
@ -39,6 +41,8 @@ type commitInputOptions struct {
manifest string
omitTimestamp bool
timestamp int64
sourceDateEpoch string
rewriteTimestamp bool
quiet bool
referenceTime string
rm bool
@ -62,6 +66,9 @@ type commitInputOptions struct {
encryptLayers []int
unsetenvs []string
addFile []string
unsetAnnotation []string
annotation []string
createdAnnotation bool
}
func init() {
@ -83,7 +90,6 @@ func init() {
commitCommand.SetUsageTemplate(UsageTemplate())
commitListFlagSet(commitCommand, &opts)
rootCmd.AddCommand(commitCommand)
}
func commitListFlagSet(cmd *cobra.Command, opts *commitInputOptions) {
@ -118,14 +124,21 @@ func commitListFlagSet(cmd *cobra.Command, opts *commitInputOptions) {
flags.StringVar(&opts.iidfile, "iidfile", "", "write the image ID to the file")
_ = cmd.RegisterFlagCompletionFunc("iidfile", completion.AutocompleteDefault)
flags.BoolVar(&opts.omitTimestamp, "omit-timestamp", false, "set created timestamp to epoch 0 to allow for deterministic builds")
flags.Int64Var(&opts.timestamp, "timestamp", 0, "set created timestamp to epoch seconds to allow for deterministic builds, defaults to current time")
sourceDateEpochUsageDefault := "current time"
if v := os.Getenv(internal.SourceDateEpochName); v != "" {
sourceDateEpochUsageDefault = fmt.Sprintf("%q", v)
}
flags.StringVar(&opts.sourceDateEpoch, "source-date-epoch", os.Getenv(internal.SourceDateEpochName), "set new timestamps in image info to `seconds` after the epoch, defaults to "+sourceDateEpochUsageDefault)
_ = cmd.RegisterFlagCompletionFunc("source-date-epoch", completion.AutocompleteNone)
flags.BoolVar(&opts.rewriteTimestamp, "rewrite-timestamp", false, "set timestamps in layer to no later than the value for --source-date-epoch")
flags.Int64Var(&opts.timestamp, "timestamp", 0, "set new timestamps in image info and layer to `seconds` after the epoch, defaults to current times")
_ = cmd.RegisterFlagCompletionFunc("timestamp", completion.AutocompleteNone)
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "don't output progress information when writing images")
flags.StringVar(&opts.referenceTime, "reference-time", "", "set the timestamp on the image to match the named `file`")
_ = cmd.RegisterFlagCompletionFunc("reference-time", completion.AutocompleteNone)
flags.StringVar(&opts.pull, "pull", "true", "pull SBOM scanner images from the registry if newer or not present in store, if false, only pull SBOM scanner images if not present, if always, pull SBOM scanner images even if the named images are present in store, if never, only use images present in store if available")
flags.Lookup("pull").NoOptDefVal = "true" //allow `--pull ` to be set to `true` as expected.
flags.Lookup("pull").NoOptDefVal = "true" // allow `--pull ` to be set to `true` as expected.
flags.BoolVar(&opts.pullAlways, "pull-always", false, "pull the image even if the named image is present in store")
if err := flags.MarkHidden("pull-always"); err != nil {
@ -177,6 +190,11 @@ func commitListFlagSet(cmd *cobra.Command, opts *commitInputOptions) {
flags.StringSliceVar(&opts.unsetenvs, "unsetenv", nil, "unset env from final image")
_ = cmd.RegisterFlagCompletionFunc("unsetenv", completion.AutocompleteNone)
flags.StringSliceVar(&opts.unsetAnnotation, "unsetannotation", nil, "unset annotation when inheriting annotations from base image")
_ = cmd.RegisterFlagCompletionFunc("unsetannotation", completion.AutocompleteNone)
flags.StringArrayVar(&opts.annotation, "annotation", []string{}, "set metadata for an image (default [])")
_ = cmd.RegisterFlagCompletionFunc("annotation", completion.AutocompleteNone)
flags.BoolVar(&opts.createdAnnotation, "created-annotation", true, `set an "org.opencontainers.image.created" annotation in the image`)
}
func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error {
@ -245,11 +263,6 @@ func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error
}
}
// Add builder identity information.
if iopts.identityLabel {
builder.SetLabel(buildah.BuilderIdentityAnnotation, define.Version)
}
encConfig, encLayers, err := cli.EncryptConfig(iopts.encryptionKeys, iopts.encryptLayers)
if err != nil {
return fmt.Errorf("unable to obtain encryption config: %w", err)
@ -306,6 +319,9 @@ func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error
OverrideChanges: iopts.changes,
OverrideConfig: overrideConfig,
ExtraImageContent: addFiles,
UnsetAnnotations: iopts.unsetAnnotation,
Annotations: iopts.annotation,
CreatedAnnotation: types.NewOptionalBool(iopts.createdAnnotation),
}
exclusiveFlags := 0
if c.Flag("reference-time").Changed {
@ -318,6 +334,16 @@ func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error
timestamp := finfo.ModTime().UTC()
options.HistoryTimestamp = &timestamp
}
if iopts.sourceDateEpoch != "" {
exclusiveFlags++
sourceDateEpochVal, err := strconv.ParseInt(iopts.sourceDateEpoch, 10, 64)
if err != nil {
return fmt.Errorf("parsing source date epoch %q: %w", iopts.sourceDateEpoch, err)
}
sourceDateEpoch := time.Unix(sourceDateEpochVal, 0).UTC()
options.SourceDateEpoch = &sourceDateEpoch
}
options.RewriteTimestamp = iopts.rewriteTimestamp
if c.Flag("timestamp").Changed {
exclusiveFlags++
timestamp := time.Unix(iopts.timestamp, 0).UTC()
@ -328,6 +354,25 @@ func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error
timestamp := time.Unix(0, 0).UTC()
options.HistoryTimestamp = &timestamp
}
if exclusiveFlags > 1 {
return errors.New("cannot use more then one timestamp option at at time")
}
// Add builder identity information.
var identityLabel types.OptionalBool
if c.Flag("identity-label").Changed {
identityLabel = types.NewOptionalBool(iopts.identityLabel)
}
switch identityLabel {
case types.OptionalBoolTrue:
builder.SetLabel(buildah.BuilderIdentityAnnotation, define.Version)
case types.OptionalBoolFalse:
// nothing - don't clear it if there's a value set in the base image
default:
if options.HistoryTimestamp == nil && options.SourceDateEpoch == nil {
builder.SetLabel(buildah.BuilderIdentityAnnotation, define.Version)
}
}
if iopts.cwOptions != "" {
confidentialWorkloadOptions, err := parse.GetConfidentialWorkloadOptions(iopts.cwOptions)
@ -353,10 +398,6 @@ func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error
options.SBOMScanOptions = sbomOptions
}
if exclusiveFlags > 1 {
return errors.New("can not use more then one timestamp option at at time")
}
if !iopts.quiet {
options.ReportWriter = os.Stderr
}

View File

@ -5,12 +5,9 @@ import (
"errors"
"fmt"
"os"
"time"
"github.com/containers/buildah"
"github.com/containers/common/pkg/umask"
"github.com/containers/image/v5/image"
"github.com/containers/image/v5/manifest"
is "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/types"
"github.com/containers/storage"
@ -20,10 +17,8 @@ import (
"github.com/spf13/pflag"
)
var (
// configuration, including customizations made in containers.conf
needToShutdownStore = false
)
// configuration, including customizations made in containers.conf
var needToShutdownStore = false
func getStore(c *cobra.Command) (storage.Store, error) {
if err := setXDGRuntimeDir(); err != nil {
@ -156,46 +151,6 @@ func openImage(ctx context.Context, sc *types.SystemContext, store storage.Store
return builder, nil
}
func getDateAndDigestAndSize(ctx context.Context, sys *types.SystemContext, store storage.Store, storeImage storage.Image) (time.Time, string, int64, error) {
created := time.Time{}
is.Transport.SetStore(store)
storeRef, err := is.Transport.ParseStoreReference(store, storeImage.ID)
if err != nil {
return created, "", -1, err
}
img, err := storeRef.NewImageSource(ctx, nil)
if err != nil {
return created, "", -1, err
}
defer img.Close()
imgSize, sizeErr := store.ImageSize(storeImage.ID)
if sizeErr != nil {
imgSize = -1
}
manifestBytes, _, manifestErr := img.GetManifest(ctx, nil)
manifestDigest := ""
if manifestErr == nil && len(manifestBytes) > 0 {
mDigest, err := manifest.Digest(manifestBytes)
manifestErr = err
if manifestErr == nil {
manifestDigest = mDigest.String()
}
}
inspectable, inspectableErr := image.FromUnparsedImage(ctx, sys, image.UnparsedInstance(img, nil))
if inspectableErr == nil {
inspectInfo, inspectErr := inspectable.Inspect(ctx)
if inspectErr == nil && inspectInfo != nil && inspectInfo.Created != nil {
created = *inspectInfo.Created
}
}
if sizeErr != nil {
err = sizeErr
} else if manifestErr != nil {
err = manifestErr
}
return created, manifestDigest, imgSize, err
}
// getContext returns a context.TODO
func getContext() context.Context {
return context.TODO()

View File

@ -7,8 +7,6 @@ import (
"testing"
"github.com/containers/buildah"
"github.com/containers/buildah/define"
is "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/types"
"github.com/containers/storage"
"github.com/sirupsen/logrus"
@ -18,7 +16,10 @@ import (
var (
signaturePolicyPath = ""
storeOptions, _ = storage.DefaultStoreOptions()
testSystemContext = types.SystemContext{}
testSystemContext = types.SystemContext{
SignaturePolicyPath: "../../tests/policy.json",
SystemRegistriesConfPath: "../../tests/registries.conf",
}
)
func TestMain(m *testing.M) {
@ -49,7 +50,7 @@ func TestGetStore(t *testing.T) {
failTestIfNotRoot(t)
testCmd := &cobra.Command{
Use: "test",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
_, err := getStore(cmd)
return err
},
@ -74,31 +75,6 @@ func TestGetStore(t *testing.T) {
}
}
func TestGetSize(t *testing.T) {
// Make sure the tests are running as root
failTestIfNotRoot(t)
store, err := storage.GetStore(storeOptions)
if err != nil {
t.Fatal(err)
} else if store != nil {
is.Transport.SetStore(store)
}
// Pull an image so that we know we have at least one
pullTestImage(t)
images, err := store.Images()
if err != nil {
t.Fatalf("Error reading images: %v", err)
}
_, _, _, err = getDateAndDigestAndSize(getContext(), &testSystemContext, store, images[0])
if err != nil {
t.Error(err)
}
}
func failTestIfNotRoot(t *testing.T) {
u, err := user.Current()
if err != nil {
@ -107,30 +83,3 @@ func failTestIfNotRoot(t *testing.T) {
t.Fatal("tests will fail unless run as root")
}
}
func pullTestImage(t *testing.T) string {
store, err := storage.GetStore(storeOptions)
if err != nil {
t.Fatal(err)
}
commonOpts := &define.CommonBuildOptions{
LabelOpts: nil,
}
options := buildah.BuilderOptions{
FromImage: "busybox:latest",
SignaturePolicyPath: signaturePolicyPath,
CommonBuildOpts: commonOpts,
SystemContext: &testSystemContext,
}
b, err := buildah.NewBuilder(getContext(), store, options)
if err != nil {
t.Fatal(err)
}
id := b.FromImageID
err = b.Delete()
if err != nil {
t.Fatal(err)
}
return id
}

View File

@ -18,36 +18,38 @@ import (
)
type configResults struct {
addHistory bool
annotation []string
arch string
author string
cmd string
comment string
createdBy string
domainName string
entrypoint string
env []string
healthcheck string
healthcheckInterval string
healthcheckRetries int
healthcheckStartPeriod string
healthcheckTimeout string
historyComment string
hostname string
label []string
onbuild []string
os string
osfeature []string
osversion string
ports []string
shell string
stopSignal string
user string
variant string
volume []string
workingDir string
unsetLabels []string
addHistory bool
annotation []string
arch string
author string
cmd string
comment string
createdBy string
domainName string
entrypoint string
env []string
healthcheck string
healthcheckInterval string
healthcheckRetries int
healthcheckStartPeriod string
healthcheckStartInterval string
healthcheckTimeout string
historyComment string
hostname string
label []string
onbuild []string
os string
osfeature []string
osversion string
ports []string
shell string
stopSignal string
user string
variant string
volume []string
workingDir string
unsetLabels []string
unsetAnnotations []string
}
func init() {
@ -84,6 +86,7 @@ func init() {
flags.StringVar(&opts.healthcheckInterval, "healthcheck-interval", "", "set the `interval` between runs of the `healthcheck` command for the target image")
flags.IntVar(&opts.healthcheckRetries, "healthcheck-retries", 0, "set the `number` of times the `healthcheck` command has to fail")
flags.StringVar(&opts.healthcheckStartPeriod, "healthcheck-start-period", "", "set the amount of `time` to wait after starting a container before a failed `healthcheck` command will count as a failure")
flags.StringVar(&opts.healthcheckStartInterval, "healthcheck-start-interval", "", "set the time between health checks during the start period. Only available with format `docker`")
flags.StringVar(&opts.healthcheckTimeout, "healthcheck-timeout", "", "set the maximum amount of `time` to wait for a `healthcheck` command for the target image")
flags.StringVar(&opts.historyComment, "history-comment", "", "set a `comment` for the history of the target image")
flags.StringVar(&opts.hostname, "hostname", "", "set a host`name` for containers based on image")
@ -100,9 +103,9 @@ func init() {
flags.StringSliceVarP(&opts.volume, "volume", "v", []string{}, "add default `volume` path to be created for containers based on image (default [])")
flags.StringVar(&opts.workingDir, "workingdir", "", "set working `directory` for containers based on image")
flags.StringSliceVar(&opts.unsetLabels, "unsetlabel", nil, "remove image configuration label")
flags.StringSliceVar(&opts.unsetAnnotations, "unsetannotation", nil, "remove image configuration annotation")
rootCmd.AddCommand(configCommand)
}
func updateCmd(builder *buildah.Builder, cmd string) error {
@ -153,7 +156,7 @@ func updateEntrypoint(builder *buildah.Builder, entrypoint string) {
builder.SetEntrypoint(entrypointSpec)
}
func conditionallyAddHistory(builder *buildah.Builder, c *cobra.Command, createdByFmt string, args ...interface{}) {
func conditionallyAddHistory(builder *buildah.Builder, c *cobra.Command, createdByFmt string, args ...any) {
history := buildahcli.DefaultHistory()
if c.Flag("add-history").Changed {
history, _ = c.Flags().GetBool("add-history")
@ -308,6 +311,10 @@ func updateConfig(builder *buildah.Builder, c *cobra.Command, iopts configResult
for _, key := range iopts.unsetLabels {
builder.UnsetLabel(key)
}
// unset annotation if any
for _, key := range iopts.unsetAnnotations {
builder.UnsetAnnotation(key)
}
if c.Flag("workingdir").Changed {
builder.SetWorkDir(iopts.workingDir)
conditionallyAddHistory(builder, c, "/bin/sh -c #(nop) WORKDIR %s", iopts.workingDir)
@ -384,8 +391,7 @@ func updateHealthcheck(builder *buildah.Builder, c *cobra.Command, iopts configR
if c.Flag("healthcheck-retries").Changed {
healthcheck.Retries = iopts.healthcheckRetries
args = args + "--retries=" + strconv.Itoa(iopts.healthcheckRetries) + " "
//args = fmt.Sprintf("%s --retries=%d ", args, iopts.healthcheckRetries)
// args = fmt.Sprintf("%s --retries=%d ", args, iopts.healthcheckRetries)
}
if c.Flag("healthcheck-start-period").Changed {
duration, err := time.ParseDuration(iopts.healthcheckStartPeriod)
@ -395,6 +401,14 @@ func updateHealthcheck(builder *buildah.Builder, c *cobra.Command, iopts configR
healthcheck.StartPeriod = duration
args = args + "--start-period=" + iopts.healthcheckStartPeriod + " "
}
if c.Flag("healthcheck-start-interval").Changed {
duration, err := time.ParseDuration(iopts.healthcheckStartInterval)
if err != nil {
return fmt.Errorf("parsing --healthcheck-start-interval %q: %w", iopts.healthcheckStartInterval, err)
}
healthcheck.StartInterval = duration
args = args + "--start-interval=" + iopts.healthcheckStartInterval + " "
}
if c.Flag("healthcheck-timeout").Changed {
duration, err := time.ParseDuration(iopts.healthcheckTimeout)
if err != nil {

View File

@ -4,15 +4,12 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"regexp"
"strings"
"text/template"
"github.com/containers/buildah"
"github.com/containers/buildah/define"
"github.com/containers/buildah/pkg/formats"
"github.com/containers/buildah/util"
"github.com/containers/common/pkg/formats"
"github.com/containers/storage"
"github.com/spf13/cobra"
)
@ -76,7 +73,7 @@ func init() {
Aliases: []string{"list", "ls", "ps"},
Short: "List working containers and their base images",
Long: containersDescription,
//Flags: sortFlags(containersFlags),
// Flags: sortFlags(containersFlags),
RunE: func(cmd *cobra.Command, args []string) error {
return containersCmd(cmd, args, opts)
},
@ -168,11 +165,13 @@ func outputContainers(store storage.Store, opts containerOptions, params *contai
continue
}
if opts.json {
JSONContainers = append(JSONContainers, jsonContainer{ID: builder.ContainerID,
JSONContainers = append(JSONContainers, jsonContainer{
ID: builder.ContainerID,
Builder: true,
ImageID: builder.FromImageID,
ImageName: image,
ContainerName: builder.Container})
ContainerName: builder.Container,
})
continue
}
output := containerOutputParams{
@ -208,11 +207,13 @@ func outputContainers(store storage.Store, opts containerOptions, params *contai
continue
}
if opts.json {
JSONContainers = append(JSONContainers, jsonContainer{ID: container.ID,
JSONContainers = append(JSONContainers, jsonContainer{
ID: container.ID,
Builder: ours,
ImageID: container.ImageID,
ImageName: imageNameForID(container.ImageID),
ContainerName: name})
ContainerName: name,
})
continue
}
output := containerOutputParams{
@ -249,35 +250,15 @@ func outputContainers(store storage.Store, opts containerOptions, params *contai
return nil
}
func containersToGeneric(templParams []containerOutputParams) (genericParams []interface{}) {
func containersToGeneric(templParams []containerOutputParams) (genericParams []any) {
if len(templParams) > 0 {
for _, v := range templParams {
genericParams = append(genericParams, interface{}(v))
genericParams = append(genericParams, any(v))
}
}
return genericParams
}
func containerOutputUsingTemplate(format string, params containerOutputParams) error {
if matched, err := regexp.MatchString("{{.*}}", format); err != nil {
return fmt.Errorf("validating format provided: %s: %w", format, err)
} else if !matched {
return fmt.Errorf("invalid format provided: %s", format)
}
tmpl, err := template.New("container").Parse(format)
if err != nil {
return fmt.Errorf("Template parsing error: %w", err)
}
err = tmpl.Execute(os.Stdout, params)
if err != nil {
return err
}
fmt.Println()
return nil
}
func containerOutputUsingFormatString(truncate bool, params containerOutputParams) {
if truncate {
fmt.Printf("%-12.12s %-8s %-12.12s %-32s %s\n", params.ContainerID, params.Builder, params.ImageID, util.TruncateString(params.ImageName, 32), params.ContainerName)

View File

@ -5,66 +5,9 @@ import (
"fmt"
"io"
"os"
"strings"
"testing"
)
func TestContainerTemplateOutputValidFormat(t *testing.T) {
params := containerOutputParams{
ContainerID: "e477836657bb",
Builder: " ",
ImageID: "f975c5035748",
ImageName: "test/image:latest",
ContainerName: "test-container",
}
formatString := "Container ID: {{.ContainerID}}"
expectedString := "Container ID: " + params.ContainerID
output, err := captureOutputWithError(func() error {
return containerOutputUsingTemplate(formatString, params)
})
if err != nil {
t.Error(err)
} else if strings.TrimSpace(output) != expectedString {
t.Errorf("Errorf with template output:\nExpected: %s\nReceived: %s\n", expectedString, output)
}
}
func TestContainerTemplateOutputInvalidFormat(t *testing.T) {
params := containerOutputParams{
ContainerID: "e477836657bb",
Builder: " ",
ImageID: "f975c5035748",
ImageName: "test/image:latest",
ContainerName: "test-container",
}
formatString := "ContainerID"
err := containerOutputUsingTemplate(formatString, params)
if err == nil || err.Error() != "invalid format provided: ContainerID" {
t.Fatalf("expected error invalid format")
}
}
func TestContainerTemplateOutputNonexistentField(t *testing.T) {
params := containerOutputParams{
ContainerID: "e477836657bb",
Builder: " ",
ImageID: "f975c5035748",
ImageName: "test/image:latest",
ContainerName: "test-container",
}
formatString := "{{.ID}}"
err := containerOutputUsingTemplate(formatString, params)
if err == nil || !strings.Contains(err.Error(), "can't evaluate field ID") {
t.Fatalf("expected error nonexistent field")
}
}
func TestContainerFormatStringOutput(t *testing.T) {
params := containerOutputParams{
ContainerID: "e477836657bb",
@ -110,25 +53,6 @@ func TestContainerHeaderOutput(t *testing.T) {
}
}
func captureOutputWithError(f func() error) (string, error) {
old := os.Stdout
r, w, err := os.Pipe()
if err != nil {
return "", err
}
os.Stdout = w
if err := f(); err != nil {
return "", err
}
w.Close()
os.Stdout = old
var buf bytes.Buffer
io.Copy(&buf, r) //nolint
return buf.String(), err
}
// Captures output so that it can be compared to expected values
func captureOutput(f func()) string {
old := os.Stdout

View File

@ -21,8 +21,8 @@ var (
}
)
func dumpBoltCmd(c *cobra.Command, args []string) error {
db, err := bolt.Open(args[0], 0600, &bolt.Options{ReadOnly: true})
func dumpBoltCmd(_ *cobra.Command, args []string) error {
db, err := bolt.Open(args[0], 0o600, &bolt.Options{ReadOnly: true})
if err != nil {
return fmt.Errorf("opening database %q: %w", args[0], err)
}

View File

@ -9,7 +9,6 @@ import (
"time"
"github.com/containers/buildah"
"github.com/containers/buildah/define"
"github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/pkg/auth"
@ -70,8 +69,13 @@ func init() {
flags.StringVar(&opts.creds, "creds", "", "use `[username[:password]]` for accessing the registry")
flags.StringVarP(&opts.format, "format", "f", defaultFormat(), "`format` of the image manifest and metadata")
flags.StringVar(&opts.name, "name", "", "`name` for the working container")
flags.StringVar(&opts.pull, "pull", "true", "pull images from the registry if newer or not present in store, if false, only pull images if not present, if always, pull images even if the named images are present in store, if never, only use images present in store if available")
flags.Lookup("pull").NoOptDefVal = "true" //allow `--pull ` to be set to `true` as expected.
flags.StringVar(&opts.pull, "pull", "missing", `pull images from the registry values:
always: pull images even if the named images are present in store,
missing: pull images if the named images are not present in store,
never: only use images present in store if available,
newer: only pull images when newer images exist on the registry than those in the store.`)
flags.Lookup("pull").NoOptDefVal = "true" // allow `--pull ` to be set to `true` as expected.
flags.BoolVar(&opts.pullAlways, "pull-always", false, "pull the image even if the named image is present in store")
if err := flags.MarkHidden("pull-always"); err != nil {
@ -248,14 +252,6 @@ func fromCmd(c *cobra.Command, args []string, iopts fromReply) error {
if err != nil {
return err
}
devices := define.ContainerDevices{}
for _, device := range append(defaultContainerConfig.Containers.Devices.Get(), iopts.Devices...) {
dev, err := parse.DeviceFromPath(device)
if err != nil {
return err
}
devices = append(devices, dev...)
}
capabilities, err := defaultContainerConfig.Capabilities("", iopts.CapAdd, iopts.CapDrop)
if err != nil {
@ -288,9 +284,10 @@ func fromCmd(c *cobra.Command, args []string, iopts fromReply) error {
CommonBuildOpts: commonOpts,
Format: format,
BlobDirectory: iopts.BlobCache,
Devices: devices,
DeviceSpecs: iopts.Devices,
MaxPullRetries: iopts.Retry,
OciDecryptConfig: decConfig,
CDIConfigDir: iopts.CDIConfigDir,
}
if iopts.RetryDelay != "" {
@ -315,7 +312,7 @@ func fromCmd(c *cobra.Command, args []string, iopts fromReply) error {
if iopts.cidfile != "" {
filePath := iopts.cidfile
if err := os.WriteFile(filePath, []byte(builder.ContainerID), 0644); err != nil {
if err := os.WriteFile(filePath, []byte(builder.ContainerID), 0o644); err != nil {
return fmt.Errorf("failed to write container ID file %q: %w", filePath, err)
}
}

View File

@ -10,9 +10,9 @@ import (
"time"
buildahcli "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/formats"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/libimage"
"github.com/containers/common/pkg/formats"
"github.com/docker/go-units"
"github.com/spf13/cobra"
)
@ -142,11 +142,29 @@ func imagesCmd(c *cobra.Command, args []string, iopts *imageResults) error {
options.Filters = append(options.Filters, "intermediate=false")
}
images, err := runtime.ListImages(ctx, args, options)
images, err := runtime.ListImages(ctx, options)
if err != nil {
return err
}
if len(args) > 0 {
imagesMatchName, err := runtime.ListImagesByNames(args)
if err != nil {
return err
}
imagesIDs := map[string]struct{}{}
for _, image := range imagesMatchName {
imagesIDs[image.ID()] = struct{}{}
}
var imagesMatchNameAndFilter []*libimage.Image
for _, image := range images {
if _, ok := imagesIDs[image.ID()]; ok {
imagesMatchNameAndFilter = append(imagesMatchNameAndFilter, image)
}
}
images = imagesMatchNameAndFilter
}
if iopts.quiet && iopts.format != "" {
return errors.New("quiet and format are mutually exclusive")
}
@ -171,7 +189,7 @@ func imagesCmd(c *cobra.Command, args []string, iopts *imageResults) error {
func outputHeader(opts imageOptions) string {
if opts.format != "" {
return strings.Replace(opts.format, `\t`, "\t", -1)
return strings.ReplaceAll(opts.format, `\t`, "\t")
}
if opts.quiet {
return formats.IDString
@ -309,10 +327,10 @@ func truncateID(id string, truncate bool) string {
return id
}
func imagesToGeneric(templParams []imageOutputParams) (genericParams []interface{}) {
func imagesToGeneric(templParams []imageOutputParams) (genericParams []any) {
if len(templParams) > 0 {
for _, v := range templParams {
genericParams = append(genericParams, interface{}(v))
genericParams = append(genericParams, any(v))
}
}
return genericParams

View File

@ -5,6 +5,7 @@ import (
)
func TestSizeFormatting(t *testing.T) {
t.Parallel()
size := formattedSize(0)
if size != "0 B" {
t.Errorf("Error formatting size: expected '%s' got '%s'", "0 B", size)
@ -22,6 +23,7 @@ func TestSizeFormatting(t *testing.T) {
}
func TestMatchWithTag(t *testing.T) {
t.Parallel()
isMatch := matchesReference("gcr.io/pause:latest", "pause:latest")
if !isMatch {
t.Error("expected match, got not match")
@ -34,6 +36,7 @@ func TestMatchWithTag(t *testing.T) {
}
func TestNoMatchesReferenceWithTag(t *testing.T) {
t.Parallel()
isMatch := matchesReference("gcr.io/pause:latest", "redis:latest")
if isMatch {
t.Error("expected no match, got match")
@ -46,6 +49,7 @@ func TestNoMatchesReferenceWithTag(t *testing.T) {
}
func TestMatchesReferenceWithoutTag(t *testing.T) {
t.Parallel()
isMatch := matchesReference("gcr.io/pause:latest", "pause")
if !isMatch {
t.Error("expected match, got not match")
@ -58,6 +62,7 @@ func TestMatchesReferenceWithoutTag(t *testing.T) {
}
func TestNoMatchesReferenceWithoutTag(t *testing.T) {
t.Parallel()
isMatch := matchesReference("gcr.io/pause:latest", "redis")
if isMatch {
t.Error("expected no match, got match")

View File

@ -6,10 +6,10 @@ import (
"os"
"regexp"
"runtime"
"text/template"
"github.com/containers/buildah"
"github.com/containers/buildah/define"
"github.com/containers/common/pkg/formats"
"github.com/spf13/cobra"
"golang.org/x/term"
)
@ -28,7 +28,7 @@ func init() {
Use: "info",
Short: "Display Buildah system information",
Long: infoDescription,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return infoCmd(cmd, opts)
},
Args: cobra.NoArgs,
@ -43,7 +43,7 @@ func init() {
}
func infoCmd(c *cobra.Command, iopts infoResults) error {
info := map[string]interface{}{}
info := map[string]any{}
store, err := getStore(c)
if err != nil {
@ -71,9 +71,9 @@ func infoCmd(c *cobra.Command, iopts infoResults) error {
} else if !matched {
return fmt.Errorf("invalid format provided: %s", format)
}
t, err := template.New("format").Parse(format)
t, err := formats.NewParse("info", format)
if err != nil {
return fmt.Errorf("Template parsing error: %w", err)
return fmt.Errorf("template parsing error: %w", err)
}
if err = t.Execute(os.Stdout, info); err != nil {
return err
@ -92,8 +92,8 @@ func infoCmd(c *cobra.Command, iopts infoResults) error {
}
// top-level "debug" info
func debugInfo() map[string]interface{} {
info := map[string]interface{}{}
func debugInfo() map[string]any {
info := map[string]any{}
info["compiler"] = runtime.Compiler
info["go version"] = runtime.Version()
info["buildah version"] = define.Version

View File

@ -6,11 +6,11 @@ import (
"fmt"
"os"
"regexp"
"text/template"
"github.com/containers/buildah"
buildahcli "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/pkg/formats"
"github.com/spf13/cobra"
"golang.org/x/term"
)
@ -113,9 +113,9 @@ func inspectCmd(c *cobra.Command, args []string, iopts inspectResults) error {
} else if !matched {
return fmt.Errorf("invalid format provided: %s", format)
}
t, err := template.New("format").Parse(format)
t, err := formats.NewParse("inspect", format)
if err != nil {
return fmt.Errorf("Template parsing error: %w", err)
return fmt.Errorf("template parsing error: %w", err)
}
if err = t.Execute(os.Stdout, out); err != nil {
return err

View File

@ -45,13 +45,13 @@ type globalFlags struct {
var rootCmd = &cobra.Command{
Use: "buildah",
Long: "A tool that facilitates building OCI images",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help()
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
return before(cmd)
},
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
PersistentPostRunE: func(cmd *cobra.Command, _ []string) error {
return after(cmd)
},
SilenceUsage: true,
@ -65,14 +65,11 @@ var (
)
func init() {
var (
defaultStoreDriverOptions []string
)
var defaultStoreDriverOptions []string
storageOptions, err := storage.DefaultStoreOptions()
if err != nil {
logrus.Errorf(err.Error())
logrus.Error(err.Error())
os.Exit(1)
}
if len(storageOptions.GraphDriverOptions) > 0 {
@ -82,15 +79,15 @@ func init() {
defaultContainerConfig, err = config.Default()
if err != nil {
logrus.Errorf(err.Error())
logrus.Error(err.Error())
os.Exit(1)
}
defaultContainerConfig.CheckCgroupsAndAdjustConfig()
cobra.OnInitialize(initConfig)
// Disable the implicit `completion` command in cobra.
rootCmd.CompletionOptions.DisableDefaultCmd = true
//rootCmd.TraverseChildren = true
// Hide the implicit `completion` command in cobra.
rootCmd.CompletionOptions.HiddenDefaultCmd = true
// rootCmd.TraverseChildren = true
rootCmd.Version = fmt.Sprintf("%s (image-spec %s, runtime-spec %s)", define.Version, ispecs.Version, rspecs.Version)
rootCmd.PersistentFlags().BoolVar(&globalFlagResults.Debug, "debug", false, "print debugging information")
// TODO Need to allow for environment variable

View File

@ -17,6 +17,7 @@ import (
"github.com/containers/common/libimage/manifests"
"github.com/containers/common/pkg/auth"
cp "github.com/containers/image/v5/copy"
"github.com/containers/image/v5/image"
"github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/pkg/compression"
"github.com/containers/image/v5/transports"
@ -26,7 +27,6 @@ import (
"github.com/hashicorp/go-multierror"
digest "github.com/opencontainers/go-digest"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@ -39,7 +39,7 @@ type manifestCreateOpts struct {
type manifestAddOpts struct {
authfile, certDir, creds, os, arch, variant, osVersion string
features, osFeatures, annotations []string
features, osFeatures, annotations, artifactAnnotations []string
tlsVerify, insecure, all bool
artifact, artifactExcludeTitles bool
artifactType, artifactLayerType string
@ -147,8 +147,9 @@ func init() {
flags.StringVar(&manifestAddOpts.artifactConfigType, "artifact-config-type", imgspecv1.DescriptorEmptyJSON.MediaType, "artifact config media type")
flags.StringVar(&manifestAddOpts.artifactConfigFile, "artifact-config", "", "artifact config file")
flags.StringVar(&manifestAddOpts.artifactLayerType, "artifact-layer-type", "", "artifact layer media type")
flags.BoolVar(&manifestAddOpts.artifactExcludeTitles, "artifact-exclude-titles", false, fmt.Sprintf(`refrain from setting %q annotations on "layers"`, v1.AnnotationTitle))
flags.BoolVar(&manifestAddOpts.artifactExcludeTitles, "artifact-exclude-titles", false, fmt.Sprintf(`refrain from setting %q annotations on "layers"`, imgspecv1.AnnotationTitle))
flags.StringVar(&manifestAddOpts.artifactSubject, "artifact-subject", "", "artifact subject reference")
flags.StringSliceVar(&manifestAddOpts.artifactAnnotations, "artifact-annotation", nil, "artifact annotation")
flags.StringVar(&manifestAddOpts.authfile, "authfile", auth.GetDefaultAuthFile(), "path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
flags.StringVar(&manifestAddOpts.certDir, "cert-dir", "", "use certificates at the specified path to access the registry")
flags.StringVar(&manifestAddOpts.creds, "creds", "", "use `[username[:password]]` for accessing the registry")
@ -246,7 +247,7 @@ func init() {
manifestPushCommand.SetUsageTemplate(UsageTemplate())
flags = manifestPushCommand.Flags()
flags.BoolVar(&manifestPushOpts.rm, "rm", false, "remove the manifest list if push succeeds")
flags.BoolVar(&manifestPushOpts.all, "all", false, "also push the images in the list")
flags.BoolVar(&manifestPushOpts.all, "all", true, "also push the images in the list")
flags.StringVar(&manifestPushOpts.authfile, "authfile", auth.GetDefaultAuthFile(), "path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
flags.StringVar(&manifestPushOpts.certDir, "cert-dir", "", "use certificates at the specified path to access the registry")
flags.StringVar(&manifestPushOpts.creds, "creds", "", "use `[username[:password]]` for accessing the registry")
@ -289,7 +290,7 @@ func init() {
func manifestExistsCmd(c *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("At least a name must be specified for the list")
return errors.New("at least a name must be specified for the list")
}
name := args[0]
@ -320,7 +321,7 @@ func manifestExistsCmd(c *cobra.Command, args []string) error {
func manifestCreateCmd(c *cobra.Command, args []string, opts manifestCreateOpts) error {
if len(args) == 0 {
return errors.New("At least a name must be specified for the list")
return errors.New("at least a name must be specified for the list")
}
listImageSpec := args[0]
imageSpecs := args[1:]
@ -431,26 +432,23 @@ func manifestAddCmd(c *cobra.Command, args []string, opts manifestAddOpts) error
artifactSpec := []string{}
switch len(args) {
case 0, 1:
return errors.New("At least a list image and an image or artifact to add must be specified")
case 2:
return errors.New("at least a list image and an image or artifact to add must be specified")
default:
listImageSpec = args[0]
if listImageSpec == "" {
return fmt.Errorf(`Invalid image name "%s"`, args[0])
return fmt.Errorf("invalid image name %q", args[0])
}
if opts.artifact {
artifactSpec = args[1:]
} else {
if len(args) > 2 {
return errors.New("too many arguments: expected list and image add to list")
}
imageSpec = args[1]
if imageSpec == "" {
return fmt.Errorf(`Invalid image name "%s"`, args[1])
return fmt.Errorf("invalid image name %q", args[1])
}
}
default:
if opts.artifact {
artifactSpec = args[1:]
} else {
return errors.New("Too many arguments: expected list and image add to list")
}
}
store, err := getStore(c)
@ -526,6 +524,13 @@ func manifestAddCmd(c *cobra.Command, args []string, opts manifestAddOpts) error
options.ConfigDescriptor.Size = -1
options.ConfigFile = opts.artifactConfigFile
}
if len(opts.artifactAnnotations) > 0 {
options.Annotations = make(map[string]string, len(opts.artifactAnnotations))
for _, annotation := range opts.artifactAnnotations {
k, v, _ := strings.Cut(annotation, "=")
options.Annotations[k] = v
}
}
options.ExcludeTitles = opts.artifactExcludeTitles
instanceDigest, err = list.AddArtifact(getContext(), systemContext, options, artifactSpec...)
if err != nil {
@ -534,7 +539,7 @@ func manifestAddCmd(c *cobra.Command, args []string, opts manifestAddOpts) error
}
} else {
var changedArtifactFlags []string
for _, artifactOption := range []string{"artifact-type", "artifact-config", "artifact-config-type", "artifact-layer-type", "artifact-subject", "artifact-exclude-titles"} {
for _, artifactOption := range []string{"artifact-type", "artifact-config", "artifact-config-type", "artifact-layer-type", "artifact-subject", "artifact-exclude-titles", "artifact-annotation"} {
if c.Flags().Changed(artifactOption) {
changedArtifactFlags = append(changedArtifactFlags, "--"+artifactOption)
}
@ -623,24 +628,24 @@ func manifestAddCmd(c *cobra.Command, args []string, opts manifestAddOpts) error
return err
}
func manifestRemoveCmd(c *cobra.Command, args []string, opts manifestRemoveOpts) error {
func manifestRemoveCmd(c *cobra.Command, args []string, _ manifestRemoveOpts) error {
listImageSpec := ""
var instanceDigest digest.Digest
var instanceSpec string
switch len(args) {
case 0, 1:
return errors.New("At least a list image and one or more instance digests must be specified")
return errors.New("at least a list image and one or more instance digests must be specified")
case 2:
listImageSpec = args[0]
if listImageSpec == "" {
return fmt.Errorf(`Invalid image name "%s"`, args[0])
return fmt.Errorf(`invalid image name "%s"`, args[0])
}
instanceSpec = args[1]
if instanceSpec == "" {
return fmt.Errorf(`Invalid instance "%s"`, args[1])
return fmt.Errorf(`invalid instance "%s"`, args[1])
}
default:
return errors.New("At least two arguments are necessary: list and digest of instance to remove from list")
return errors.New("at least two arguments are necessary: list and digest of instance to remove from list")
}
store, err := getStore(c)
@ -671,23 +676,23 @@ func manifestRemoveCmd(c *cobra.Command, args []string, opts manifestRemoveOpts)
if err != nil {
if instanceRef, err = alltransports.ParseImageName(util.DefaultTransport + instanceSpec); err != nil {
if instanceRef, _, err = util.FindImage(store, "", systemContext, instanceSpec); err != nil {
return fmt.Errorf(`Invalid instance "%s": %v`, instanceSpec, err)
return fmt.Errorf(`invalid instance "%s": %v`, instanceSpec, err)
}
}
}
ctx := getContext()
instanceImg, err := instanceRef.NewImageSource(ctx, systemContext)
if err != nil {
return fmt.Errorf("Reading image instance: %w", err)
return fmt.Errorf("reading image instance: %w", err)
}
defer instanceImg.Close()
manifestBytes, _, err := instanceImg.GetManifest(ctx, nil)
manifestBytes, _, err := image.UnparsedInstance(instanceImg, nil).Manifest(ctx)
if err != nil {
return fmt.Errorf("Reading image instance manifest: %w", err)
return fmt.Errorf("reading image instance manifest: %w", err)
}
d, err = manifest.Digest(manifestBytes)
if err != nil {
return fmt.Errorf("Digesting image instance manifest: %w", err)
return fmt.Errorf("digesting image instance manifest: %w", err)
}
}
instanceDigest = d
@ -746,29 +751,29 @@ func manifestAnnotateCmd(c *cobra.Command, args []string, opts manifestAnnotateO
}
switch len(args) {
case 0:
return errors.New("At least a list image must be specified")
return errors.New("at least a list image must be specified")
case 1:
listImageSpec = args[0]
if listImageSpec == "" {
return fmt.Errorf(`Invalid image name "%s"`, args[0])
return fmt.Errorf(`invalid image name "%s"`, args[0])
}
if !opts.index {
return errors.New(`Expected an instance digest, image name, or artifact name`)
return errors.New(`expected an instance digest, image name, or artifact name`)
}
case 2:
listImageSpec = args[0]
if listImageSpec == "" {
return fmt.Errorf(`Invalid image name "%s"`, args[0])
return fmt.Errorf(`invalid image name "%s"`, args[0])
}
if opts.index {
return fmt.Errorf(`Did not expect image or artifact name "%s" when modifying the entire index`, args[1])
return fmt.Errorf(`did not expect image or artifact name "%s" when modifying the entire index`, args[1])
}
instanceSpec = args[1]
if instanceSpec == "" {
return fmt.Errorf(`Invalid instance digest, image name, or artifact name "%s"`, instanceSpec)
return fmt.Errorf(`invalid instance digest, image name, or artifact name "%s"`, instanceSpec)
}
default:
return errors.New("Expected either a list name and --index or a list name and an image digest or image name or artifact name")
return errors.New("expected either a list name and --index or a list name and an image digest or image name or artifact name")
}
store, err := getStore(c)
@ -811,23 +816,23 @@ func manifestAnnotateCmd(c *cobra.Command, args []string, opts manifestAnnotateO
if instanceRef, err = alltransports.ParseImageName(util.DefaultTransport + instanceSpec); err != nil {
// check if the local image exists
if instanceRef, _, err = util.FindImage(store, "", systemContext, instanceSpec); err != nil {
return fmt.Errorf(`Invalid instance "%s": %v`, instanceSpec, err)
return fmt.Errorf(`invalid instance "%s": %v`, instanceSpec, err)
}
}
}
ctx := getContext()
instanceImg, err := instanceRef.NewImageSource(ctx, systemContext)
if err != nil {
return fmt.Errorf("Reading image instance: %w", err)
return fmt.Errorf("reading image instance: %w", err)
}
defer instanceImg.Close()
manifestBytes, _, err := instanceImg.GetManifest(ctx, nil)
manifestBytes, _, err := image.UnparsedInstance(instanceImg, nil).Manifest(ctx)
if err != nil {
return fmt.Errorf("Reading image instance manifest: %w", err)
return fmt.Errorf("reading image instance manifest: %w", err)
}
d, err = manifest.Digest(manifestBytes)
if err != nil {
return fmt.Errorf("Digesting image instance manifest: %w", err)
return fmt.Errorf("digesting image instance manifest: %w", err)
}
}
instance = d
@ -917,7 +922,7 @@ func manifestAnnotateCmd(c *cobra.Command, args []string, opts manifestAnnotateO
}
defer src.Close()
manifestBytes, manifestType, err := src.GetManifest(ctx, nil)
manifestBytes, manifestType, err := image.UnparsedInstance(src, nil).Manifest(ctx)
if err != nil {
logrus.Errorf("Error while trying to read artifact subject manifest: %v", err)
return err
@ -958,14 +963,14 @@ func manifestInspectCmd(c *cobra.Command, args []string, opts manifestInspectOpt
imageSpec := ""
switch len(args) {
case 0:
return errors.New("At least a source list ID must be specified")
return errors.New("at least a source list ID must be specified")
case 1:
imageSpec = args[0]
if imageSpec == "" {
return fmt.Errorf(`Invalid image name "%s"`, imageSpec)
return fmt.Errorf(`invalid image name "%s"`, imageSpec)
}
default:
return errors.New("Only one argument is necessary for inspect: an image name")
return errors.New("only one argument is necessary for inspect: an image name")
}
store, err := getStore(c)
@ -1058,7 +1063,7 @@ func manifestInspect(ctx context.Context, store storage.Store, systemContext *ty
}
defer src.Close()
manifestBytes, manifestType, err := src.GetManifest(ctx, nil)
manifestBytes, manifestType, err := image.UnparsedInstance(src, nil).Manifest(ctx)
if err != nil {
appendErr(fmt.Errorf("loading manifest %q: %w", transports.ImageName(ref), err))
continue
@ -1087,7 +1092,7 @@ func manifestPushCmd(c *cobra.Command, args []string, opts pushOptions) error {
destSpec := ""
switch len(args) {
case 0:
return errors.New("At least a source list ID must be specified")
return errors.New("at least a source list ID must be specified")
case 1:
listImageSpec = args[0]
destSpec = "docker://" + listImageSpec
@ -1095,7 +1100,7 @@ func manifestPushCmd(c *cobra.Command, args []string, opts pushOptions) error {
listImageSpec = args[0]
destSpec = args[1]
default:
return errors.New("Only two arguments are necessary to push: source and destination")
return errors.New("only two arguments are necessary to push: source and destination")
}
if listImageSpec == "" {
return fmt.Errorf(`invalid image name "%s"`, listImageSpec)
@ -1207,7 +1212,7 @@ func manifestPush(systemContext *types.SystemContext, store storage.Store, listI
}
if opts.digestfile != "" {
if err = os.WriteFile(opts.digestfile, []byte(digest.String()), 0644); err != nil {
if err = os.WriteFile(opts.digestfile, []byte(digest.String()), 0o644); err != nil {
return util.GetFailureCause(err, fmt.Errorf("failed to write digest to file %q: %w", opts.digestfile, err))
}
}

View File

@ -1,34 +0,0 @@
package main
import (
"fmt"
"github.com/spf13/cobra"
"golang.org/x/crypto/bcrypt"
)
var (
passwdDescription = `Generate a password hash using golang.org/x/crypto/bcrypt.`
passwdCommand = &cobra.Command{
Use: "passwd",
Short: "Generate a password hash",
Long: passwdDescription,
RunE: passwdCmd,
Example: `buildah passwd testpassword`,
Args: cobra.ExactArgs(1),
Hidden: true,
}
)
func passwdCmd(c *cobra.Command, args []string) error {
passwd, err := bcrypt.GenerateFromPassword([]byte(args[0]), bcrypt.DefaultCost)
if err != nil {
return err
}
fmt.Println(string(passwd))
return nil
}
func init() {
rootCmd.AddCommand(passwdCommand)
}

View File

@ -31,7 +31,7 @@ Cleanup intermediate images as well as build and mount cache.`
return pruneCmd(cmd, args, opts)
},
Example: `buildah prune
buildah prune`,
buildah prune --force`,
}
pruneCommand.SetUsageTemplate(UsageTemplate())

View File

@ -1,13 +1,12 @@
package main
import (
"errors"
"fmt"
"os"
"strings"
"time"
"errors"
"github.com/containers/buildah"
"github.com/containers/buildah/define"
"github.com/containers/buildah/pkg/cli"
@ -136,7 +135,7 @@ func pushCmd(c *cobra.Command, args []string, iopts pushOptions) error {
return fmt.Errorf(`invalid image name "%s"`, args[0])
}
default:
return errors.New("Only two arguments are necessary to push: source and destination")
return errors.New("only two arguments are necessary to push: source and destination")
}
compress := define.Gzip
@ -255,7 +254,7 @@ func pushCmd(c *cobra.Command, args []string, iopts pushOptions) error {
logrus.Debugf("Successfully pushed %s with digest %s", transports.ImageName(dest), digest.String())
if iopts.digestfile != "" {
if err = os.WriteFile(iopts.digestfile, []byte(digest.String()), 0644); err != nil {
if err = os.WriteFile(iopts.digestfile, []byte(digest.String()), 0o644); err != nil {
return util.GetFailureCause(err, fmt.Errorf("failed to write digest to file %q: %w", iopts.digestfile, err))
}
}

View File

@ -47,7 +47,7 @@ func renameCmd(c *cobra.Command, args []string) error {
}
if build, err := openBuilder(getContext(), store, newName); err == nil {
return fmt.Errorf("The container name %q is already in use by container %q", newName, build.ContainerID)
return fmt.Errorf("the container name %q is already in use by container %q", newName, build.ContainerID)
}
err = store.SetNames(builder.ContainerID, []string{newName})

View File

@ -86,7 +86,6 @@ func rmCmd(c *cobra.Command, args []string, iopts rmResults) error {
}
fmt.Printf("%s\n", id)
}
}
return lastError
}

View File

@ -7,32 +7,37 @@ import (
"strings"
"github.com/containers/buildah"
"github.com/containers/buildah/internal/tmpdir"
"github.com/containers/buildah/internal/volumes"
buildahcli "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/overlay"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/buildah/util"
"github.com/containers/storage/pkg/mount"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
type runInputOptions struct {
addHistory bool
capAdd []string
capDrop []string
contextDir string
env []string
hostname string
isolation string
mounts []string
runtime string
runtimeFlag []string
noHostname bool
noHosts bool
noPivot bool
terminal bool
volumes []string
workingDir string
addHistory bool
capAdd []string
capDrop []string
cdiConfigDir string
contextDir string
devices []string
env []string
hostname string
isolation string
mounts []string
runtime string
runtimeFlag []string
noHostname bool
noHosts bool
noPivot bool
terminal bool
volumes []string
workingDir string
*buildahcli.NameSpaceResults
}
@ -51,7 +56,6 @@ func init() {
RunE: func(cmd *cobra.Command, args []string) error {
opts.NameSpaceResults = &namespaceResults
return runCmd(cmd, args, opts)
},
Example: `buildah run containerID -- ps -auxw
buildah run --terminal containerID /bin/bash
@ -64,7 +68,10 @@ func init() {
flags.BoolVar(&opts.addHistory, "add-history", false, "add an entry for this operation to the image's history. Use BUILDAH_HISTORY environment variable to override. (default false)")
flags.StringSliceVar(&opts.capAdd, "cap-add", []string{}, "add the specified capability (default [])")
flags.StringSliceVar(&opts.capDrop, "cap-drop", []string{}, "drop the specified capability (default [])")
flags.StringVar(&opts.cdiConfigDir, "cdi-config-dir", "", "`directory` of CDI configuration files")
_ = flags.MarkHidden("cdi-config-dir")
flags.StringVar(&opts.contextDir, "contextdir", "", "context directory path")
flags.StringArrayVar(&opts.devices, "device", []string{}, "additional devices to provide")
flags.StringArrayVarP(&opts.env, "env", "e", []string{}, "add environment variable to be set temporarily when running command (default [])")
flags.StringVar(&opts.hostname, "hostname", "", "set the hostname inside of the container")
flags.StringVar(&opts.isolation, "isolation", "", "`type` of process isolation to use. Use BUILDAH_ISOLATION environment variable to override.")
@ -103,6 +110,16 @@ func runCmd(c *cobra.Command, args []string, iopts runInputOptions) error {
return errors.New("command must be specified")
}
tmpDir, err := os.MkdirTemp(tmpdir.GetTempDir(), "buildahvolume")
if err != nil {
return fmt.Errorf("creating temporary directory: %w", err)
}
defer func() {
if err := os.Remove(tmpDir); err != nil {
logrus.Debugf("removing should-be-empty temporary directory %q: %v", tmpDir, err)
}
}()
store, err := getStore(c)
if err != nil {
return err
@ -156,6 +173,8 @@ func runCmd(c *cobra.Command, args []string, iopts runInputOptions) error {
AddCapabilities: iopts.capAdd,
DropCapabilities: iopts.capDrop,
WorkingDir: iopts.workingDir,
DeviceSpecs: iopts.devices,
CDIConfigDir: iopts.cdiConfigDir,
}
if c.Flag("terminal").Changed {
@ -172,14 +191,30 @@ func runCmd(c *cobra.Command, args []string, iopts runInputOptions) error {
if err != nil {
return fmt.Errorf("building system context: %w", err)
}
mounts, mountedImages, targetLocks, err := volumes.GetVolumes(systemContext, store, iopts.volumes, iopts.mounts, iopts.contextDir, iopts.workingDir)
mounts, mountedImages, intermediateMounts, _, targetLocks, err := volumes.GetVolumes(systemContext, store, builder.MountLabel, iopts.volumes, iopts.mounts, iopts.contextDir, builder.IDMappingOptions, iopts.workingDir, tmpDir)
if err != nil {
return err
}
defer volumes.UnlockLockArray(targetLocks)
defer func() {
if err := overlay.CleanupContent(tmpDir); err != nil {
logrus.Debugf("unmounting overlay mounts under %q: %v", tmpDir, err)
}
for _, intermediateMount := range intermediateMounts {
if err := mount.Unmount(intermediateMount); err != nil {
logrus.Debugf("unmounting mount %q: %v", intermediateMount, err)
}
if err := os.Remove(intermediateMount); err != nil {
logrus.Debugf("removing should-be-empty mount directory %q: %v", intermediateMount, err)
}
}
for _, mountedImage := range mountedImages {
if _, err := store.UnmountImage(mountedImage, false); err != nil {
logrus.Debugf("unmounting image %q: %v", mountedImage, err)
}
}
volumes.UnlockLockArray(targetLocks)
}()
options.Mounts = mounts
// Run() will automatically clean them up.
options.ExternalImageMounts = mountedImages
options.CgroupManager = globalFlagResults.CgroupManager
runerr := builder.Run(args, options)

View File

@ -17,7 +17,7 @@ var (
Use: "source",
Short: "Manage source containers",
Long: sourceDescription,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return nil
},
}
@ -34,7 +34,7 @@ var (
Short: "Create a source image",
Long: sourceCreateDescription,
Example: "buildah source create /tmp/fedora:latest-source",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return source.Create(context.Background(), args[0], sourceCreateOptions)
},
}
@ -51,7 +51,7 @@ var (
Short: "Add a source artifact to a source image",
Long: sourceAddDescription,
Example: "buildah source add /tmp/fedora sources.tar.gz",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return source.Add(context.Background(), args[0], args[1], sourceAddOptions)
},
}
@ -68,7 +68,7 @@ var (
Short: "Pull a source image from a registry to a specified path",
Long: sourcePullDescription,
Example: "buildah source pull quay.io/sourceimage/example:latest /tmp/sourceimage:latest",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return source.Pull(context.Background(), args[0], args[1], sourcePullOptions)
},
}
@ -85,7 +85,7 @@ var (
Short: "Push a source image from a specified path to a registry",
Long: sourcePushDescription,
Example: "buildah source push /tmp/sourceimage:latest quay.io/sourceimage/example:latest",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return source.Push(context.Background(), args[0], args[1], sourcePushOptions)
},
}
@ -122,6 +122,7 @@ func init() {
sourceCommand.AddCommand(sourcePushCommand)
sourcePushFlags := sourcePushCommand.Flags()
sourcePushFlags.StringVar(&sourcePushOptions.Credentials, "creds", "", "use `[username[:password]]` for accessing the registry")
sourcePushFlags.StringVar(&sourcePushOptions.DigestFile, "digestfile", "", "after copying the artifact, write the digest of the resulting image to the file")
sourcePushFlags.BoolVar(&sourcePushOptions.TLSVerify, "tls-verify", true, "require HTTPS and verify certificates when accessing the registry")
sourcePushFlags.BoolVarP(&sourcePushOptions.Quiet, "quiet", "q", false, "don't output push progress information")
}

View File

@ -30,10 +30,8 @@ func init() {
}
func umountCmd(c *cobra.Command, args []string) error {
umountAll := false
if c.Flag("all").Changed {
umountAll = true
}
umountAll := c.Flag("all").Changed
umountContainerErrStr := "error unmounting container"
if len(args) == 0 && !umountAll {
return errors.New("at least one container ID must be specified")

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package main
@ -12,9 +11,9 @@ import (
"github.com/containers/storage"
"github.com/containers/storage/pkg/unshare"
"github.com/moby/sys/capability"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/syndtr/gocapability/capability"
)
var (
@ -139,7 +138,7 @@ func debugCapabilities() {
logrus.Errorf("error loading our current capabilities: %v", err)
return
}
knownCaps := capability.List()
knownCaps := capability.ListKnown()
effective := make([]string, 0, len(knownCaps))
for i := range knownCaps {
have := pid.Get(capability.EFFECTIVE, knownCaps[i])

View File

@ -1,5 +1,4 @@
//go:build !linux
// +build !linux
package main

View File

@ -7,7 +7,7 @@ import (
"strconv"
"time"
"github.com/containerd/containerd/platforms"
"github.com/containerd/platforms"
cniversion "github.com/containernetworking/cni/pkg/version"
"github.com/containers/buildah/define"
iversion "github.com/containers/image/v5/version"
@ -16,7 +16,7 @@ import (
"github.com/spf13/cobra"
)
//Overwritten at build time
// Overwritten at build time
var (
GitCommit string
buildInfo string
@ -44,12 +44,12 @@ type versionOptions struct {
func init() {
var opts versionOptions
//cli command to print out the version info of buildah
// cli command to print out the version info of buildah
versionCommand := &cobra.Command{
Use: "version",
Short: "Display the Buildah version information",
Long: "Displays Buildah version information.",
RunE: func(c *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return versionCmd(opts)
},
Args: cobra.NoArgs,
@ -67,7 +67,7 @@ func versionCmd(opts versionOptions) error {
var err error
buildTime := int64(0)
if buildInfo != "" {
//converting unix time from string to int64
// converting unix time from string to int64
buildTime, err = strconv.ParseInt(buildInfo, 10, 64)
if err != nil {
return err
@ -106,7 +106,7 @@ func versionCmd(opts versionOptions) error {
fmt.Println("image Version: ", version.ImageVersion)
fmt.Println("Git Commit: ", version.GitCommit)
//Prints out the build time in readable format
// Prints out the build time in readable format
fmt.Println("Built: ", version.Built)
fmt.Println("OS/Arch: ", version.OsArch)
fmt.Println("BuildPlatform: ", version.BuildPlatform)

128
commit.go
View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"maps"
"os"
"strings"
"time"
@ -24,13 +25,15 @@ import (
"github.com/containers/storage/pkg/archive"
"github.com/containers/storage/pkg/stringid"
digest "github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
)
const (
// BuilderIdentityAnnotation is the name of the annotation key containing
// the name and version of the producer of the image stored as an
// annotation on commit.
// BuilderIdentityAnnotation is the name of the label which will be set
// to contain the name and version of the producer of the image at
// commit-time. (N.B. yes, the constant's name includes "Annotation",
// but it's added as a label.)
BuilderIdentityAnnotation = "io.buildah.version"
)
@ -56,9 +59,20 @@ type CommitOptions struct {
// ReportWriter is an io.Writer which will be used to log the writing
// of the new image.
ReportWriter io.Writer
// HistoryTimestamp is the timestamp used when creating new items in the
// image's history. If unset, the current time will be used.
// HistoryTimestamp specifies a timestamp to use for the image's
// created-on date, the corresponding field in new history entries, and
// the timestamps to set on contents in new layer diffs. If left
// unset, the current time is used for the configuration and manifest,
// and timestamps of layer contents are used as-is.
HistoryTimestamp *time.Time
// SourceDateEpoch specifies a timestamp to use for the image's
// created-on date and the corresponding field in new history entries.
// If left unset, the current time is used for the configuration and
// manifest.
SourceDateEpoch *time.Time
// RewriteTimestamp, if set, forces timestamps in generated layers to
// not be later than the SourceDateEpoch, if it is set.
RewriteTimestamp bool
// github.com/containers/image/types SystemContext to hold credentials
// and other authentication/authorization information.
SystemContext *types.SystemContext
@ -80,9 +94,18 @@ type CommitOptions struct {
// EmptyLayer tells the builder to omit the diff for the working
// container.
EmptyLayer bool
// OmitLayerHistoryEntry tells the builder to omit the diff for the
// working container and to not add an entry in the commit history. By
// default, the rest of the image's history is preserved, subject to
// the OmitHistory setting. N.B.: setting this flag, without any
// PrependedEmptyLayers, AppendedEmptyLayers, PrependedLinkedLayers, or
// AppendedLinkedLayers will more or less produce a copy of the base
// image.
OmitLayerHistoryEntry bool
// OmitTimestamp forces epoch 0 as created timestamp to allow for
// deterministic, content-addressable builds.
// Deprecated use HistoryTimestamp instead.
// Deprecated: use HistoryTimestamp or SourceDateEpoch (possibly with
// RewriteTimestamp) instead.
OmitTimestamp bool
// SignBy is the fingerprint of a GPG key to use for signing the image.
SignBy string
@ -108,7 +131,8 @@ type CommitOptions struct {
// contents of a rootfs.
ConfidentialWorkloadOptions ConfidentialWorkloadOptions
// UnsetEnvs is a list of environments to not add to final image.
// Deprecated: use UnsetEnv() before committing instead.
// Deprecated: use UnsetEnv() before committing, or set OverrideChanges
// instead.
UnsetEnvs []string
// OverrideConfig is an optional Schema2Config which can override parts
// of the working container's configuration for the image that is being
@ -119,25 +143,59 @@ type CommitOptions struct {
// OverrideConfig is applied.
OverrideChanges []string
// ExtraImageContent is a map which describes additional content to add
// to the committed image. The map's keys are filesystem paths in the
// image and the corresponding values are the paths of files whose
// contents will be used in their place. The contents will be owned by
// 0:0 and have mode 0644. Currently only accepts regular files.
// to the new layer in the committed image. The map's keys are
// filesystem paths in the image and the corresponding values are the
// paths of files whose contents will be used in their place. The
// contents will be owned by 0:0 and have mode 0o644. Currently only
// accepts regular files.
ExtraImageContent map[string]string
// SBOMScanOptions encapsulates options which control whether or not we
// run scanners on the rootfs that we're about to commit, and how.
SBOMScanOptions []SBOMScanOptions
// CompatSetParent causes the "parent" field to be set when committing
// the image in Docker format. Newer BuildKit-based builds don't set
// this field.
CompatSetParent types.OptionalBool
// CompatLayerOmissions causes the "/dev", "/proc", and "/sys"
// directories to be omitted from the layer diff and related output, as
// the classic builder did. Newer BuildKit-based builds include them
// in the built image by default.
CompatLayerOmissions types.OptionalBool
// PrependedLinkedLayers and AppendedLinkedLayers are combinations of
// history entries and locations of either directory trees (if
// directories, per os.Stat()) or uncompressed layer blobs which should
// be added to the image at commit-time. The order of these relative
// to PrependedEmptyLayers and AppendedEmptyLayers, and relative to the
// corresponding members in the Builder object, in the committed image
// is not guaranteed.
PrependedLinkedLayers, AppendedLinkedLayers []LinkedLayer
// UnsetAnnotations is a list of annotations (names only) to withhold
// from the image.
UnsetAnnotations []string
// Annotations is a list of annotations (in the form "key=value") to
// add to the image.
Annotations []string
// CreatedAnnotation controls whether or not an "org.opencontainers.image.created"
// annotation is present in the output image.
CreatedAnnotation types.OptionalBool
}
var (
// storageAllowedPolicyScopes overrides the policy for local storage
// to ensure that we can read images from it.
storageAllowedPolicyScopes = signature.PolicyTransportScopes{
"": []signature.PolicyRequirement{
signature.NewPRInsecureAcceptAnything(),
},
}
)
// LinkedLayer combines a history entry with the location of either a directory
// tree (if it's a directory, per os.Stat()) or an uncompressed layer blob
// which should be added to the image at commit-time. The BlobPath and
// History.EmptyLayer fields should be considered mutually-exclusive.
type LinkedLayer struct {
History v1.History // history entry to add
BlobPath string // corresponding uncompressed blob file (layer as a tar archive), or directory tree to archive
}
// storageAllowedPolicyScopes overrides the policy for local storage
// to ensure that we can read images from it.
var storageAllowedPolicyScopes = signature.PolicyTransportScopes{
"": []signature.PolicyRequirement{
signature.NewPRInsecureAcceptAnything(),
},
}
// checkRegistrySourcesAllows checks the $BUILD_REGISTRY_SOURCES environment
// variable, if it's set. The contents are expected to be a JSON-encoded
@ -252,8 +310,9 @@ func (b *Builder) addManifest(ctx context.Context, manifestName string, imageSpe
// if commit was successful and the image destination was local.
func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options CommitOptions) (string, reference.Canonical, digest.Digest, error) {
var (
imgID string
src types.ImageReference
imgID string
src types.ImageReference
destinationTimestamp *time.Time
)
// If we weren't given a name, build a destination reference using a
@ -266,11 +325,15 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
// work twice.
if options.OmitTimestamp {
if options.HistoryTimestamp != nil {
return imgID, nil, "", fmt.Errorf("OmitTimestamp ahd HistoryTimestamp can not be used together")
return imgID, nil, "", fmt.Errorf("OmitTimestamp and HistoryTimestamp can not be used together")
}
timestamp := time.Unix(0, 0).UTC()
options.HistoryTimestamp = &timestamp
}
destinationTimestamp = options.HistoryTimestamp
if options.SourceDateEpoch != nil {
destinationTimestamp = options.SourceDateEpoch
}
nameToRemove := ""
if dest == nil {
nameToRemove = stringid.GenerateRandomID() + "-tmp"
@ -325,7 +388,7 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
logrus.Debugf("committing image with reference %q is allowed by policy", transports.ImageName(dest))
// If we need to scan the rootfs, do it now.
options.ExtraImageContent = copyStringStringMap(options.ExtraImageContent)
options.ExtraImageContent = maps.Clone(options.ExtraImageContent)
var extraImageContent, extraLocalContent map[string]string
if len(options.SBOMScanOptions) != 0 {
var scansDirectory string
@ -339,9 +402,15 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
}
}()
}
for k, v := range extraImageContent {
if _, set := options.ExtraImageContent[k]; !set {
options.ExtraImageContent[k] = v
if len(extraImageContent) > 0 {
if options.ExtraImageContent == nil {
options.ExtraImageContent = make(map[string]string, len(extraImageContent))
}
// merge in the scanner-generated content
for k, v := range extraImageContent {
if _, set := options.ExtraImageContent[k]; !set {
options.ExtraImageContent[k] = v
}
}
}
}
@ -387,7 +456,7 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
}
var manifestBytes []byte
if manifestBytes, err = retryCopyImage(ctx, policyContext, maybeCachedDest, maybeCachedSrc, dest, getCopyOptions(b.store, options.ReportWriter, nil, systemContext, "", false, options.SignBy, options.OciEncryptLayers, options.OciEncryptConfig, nil), options.MaxRetries, options.RetryDelay); err != nil {
if manifestBytes, err = retryCopyImage(ctx, policyContext, maybeCachedDest, maybeCachedSrc, dest, getCopyOptions(b.store, options.ReportWriter, nil, systemContext, "", false, options.SignBy, options.OciEncryptLayers, options.OciEncryptConfig, nil, destinationTimestamp), options.MaxRetries, options.RetryDelay); err != nil {
return imgID, nil, "", fmt.Errorf("copying layers and metadata for container %q: %w", b.ContainerID, err)
}
// If we've got more names to attach, and we know how to do that for
@ -428,7 +497,7 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
logrus.Debugf("removing %v from assigned names to image %q", nameToRemove, img.ID)
}
if options.IIDFile != "" {
if err = os.WriteFile(options.IIDFile, []byte("sha256:"+img.ID), 0644); err != nil {
if err = os.WriteFile(options.IIDFile, []byte("sha256:"+img.ID), 0o644); err != nil {
return imgID, nil, "", err
}
}
@ -477,7 +546,6 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
return imgID, nil, "", err
}
logrus.Debugf("added imgID %s to manifestID %s", imgID, manifestID)
}
return imgID, ref, manifestDigest, nil
}

570
commit_test.go Normal file
View File

@ -0,0 +1,570 @@
package buildah
import (
"archive/tar"
"context"
"crypto/rand"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"testing"
"time"
"github.com/containers/image/v5/manifest"
ociLayout "github.com/containers/image/v5/oci/layout"
imageStorage "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/transports"
"github.com/containers/image/v5/types"
"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
storageTypes "github.com/containers/storage/types"
digest "github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func makeFile(t *testing.T, base string, size int64) string {
t.Helper()
fn := filepath.Join(t.TempDir(), base)
f, err := os.Create(fn)
require.NoError(t, err)
defer f.Close()
if size == 0 {
size = 512
}
_, err = io.CopyN(f, rand.Reader, size)
require.NoErrorf(t, err, "writing payload file %d", base)
return f.Name()
}
func TestCommitLinkedLayers(t *testing.T) {
// This test cannot be parallelized as this uses NewBuilder()
// which eventually and indirectly accesses a global variable
// defined in `go-selinux`, this must be fixed at `go-selinux`
// or builder must enable sometime of locking mechanism i.e if
// routine is creating Builder other's must wait for it.
// Tracked here: https://github.com/containers/buildah/issues/5967
ctx := context.TODO()
now := time.Now()
graphDriverName := os.Getenv("STORAGE_DRIVER")
if graphDriverName == "" {
graphDriverName = "vfs"
}
t.Logf("using storage driver %q", graphDriverName)
store, err := storage.GetStore(storageTypes.StoreOptions{
RunRoot: t.TempDir(),
GraphRoot: t.TempDir(),
GraphDriverName: graphDriverName,
})
require.NoError(t, err, "initializing storage")
t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
imageName := func(i int) string { return fmt.Sprintf("image%d", i) }
makeFile := func(base string, size int64) string {
return makeFile(t, base, size)
}
makeArchive := func(base string, size int64) string {
t.Helper()
file := makeFile(base, size)
archiveDir := t.TempDir()
st, err := os.Stat(file)
require.NoError(t, err)
archiveName := filepath.Join(archiveDir, filepath.Base(file))
f, err := os.Create(archiveName)
require.NoError(t, err)
defer f.Close()
tw := tar.NewWriter(f)
defer tw.Close()
hdr, err := tar.FileInfoHeader(st, "")
require.NoErrorf(t, err, "building tar header for %s", file)
err = tw.WriteHeader(hdr)
require.NoErrorf(t, err, "writing tar header for %s", file)
f, err = os.Open(file)
require.NoError(t, err)
defer f.Close()
_, err = io.Copy(tw, f)
require.NoErrorf(t, err, "writing tar payload for %s", file)
return archiveName
}
layerNumber := 0
// Build a from-scratch image with one layer.
builderOptions := BuilderOptions{
FromImage: "scratch",
NamespaceOptions: []NamespaceOption{{
Name: string(rspec.NetworkNamespace),
Host: true,
}},
SystemContext: &testSystemContext,
}
b, err := NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder")
b.SetCreatedBy(imageName(layerNumber))
firstFile := makeFile("file0", 0)
err = b.Add("/", false, AddAndCopyOptions{}, firstFile)
require.NoError(t, err, "adding", firstFile)
commitOptions := CommitOptions{
SystemContext: &testSystemContext,
}
ref, err := imageStorage.Transport.ParseStoreReference(store, imageName(layerNumber))
require.NoError(t, err, "parsing reference for to-be-committed image", imageName(layerNumber))
_, _, _, err = b.Commit(ctx, ref, commitOptions)
require.NoError(t, err, "committing", imageName(layerNumber))
// Build another image based on the first with not much in its layer.
builderOptions.FromImage = imageName(layerNumber)
layerNumber++
b, err = NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder")
b.SetCreatedBy(imageName(layerNumber))
secondFile := makeFile("file1", 0)
err = b.Add("/", false, AddAndCopyOptions{}, secondFile)
require.NoError(t, err, "adding", secondFile)
commitOptions = CommitOptions{
SystemContext: &testSystemContext,
}
ref, err = imageStorage.Transport.ParseStoreReference(store, imageName(layerNumber))
require.NoError(t, err, "parsing reference for to-be-committed image", imageName(layerNumber))
_, _, _, err = b.Commit(ctx, ref, commitOptions)
require.NoError(t, err, "committing", imageName(layerNumber))
// Build a third image with two layers on either side of its read-write layer.
builderOptions.FromImage = imageName(layerNumber)
layerNumber++
b, err = NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder")
thirdFile := makeFile("file2", 0)
fourthArchiveFile := makeArchive("file3", 0)
fifthFile := makeFile("file4", 0)
sixthFile := makeFile("file5", 0)
seventhArchiveFile := makeArchive("file6", 0)
eighthFile := makeFile("file7", 0)
ninthArchiveFile := makeArchive("file8", 0)
err = b.Add("/", false, AddAndCopyOptions{}, sixthFile)
require.NoError(t, err, "adding", sixthFile)
b.SetCreatedBy(imageName(layerNumber + 3))
b.AddPrependedLinkedLayer(nil, imageName(layerNumber), "", "", filepath.Dir(thirdFile))
commitOptions = CommitOptions{
PrependedLinkedLayers: []LinkedLayer{
{
BlobPath: fourthArchiveFile,
History: v1.History{
Created: &now,
CreatedBy: imageName(layerNumber + 1),
},
},
{
BlobPath: filepath.Dir(fifthFile),
History: v1.History{
Created: &now,
CreatedBy: imageName(layerNumber + 2),
},
},
},
AppendedLinkedLayers: []LinkedLayer{
{
BlobPath: seventhArchiveFile,
History: v1.History{
Created: &now,
CreatedBy: imageName(layerNumber + 4),
},
},
{
BlobPath: filepath.Dir(eighthFile),
History: v1.History{
Created: &now,
CreatedBy: imageName(layerNumber + 5),
},
},
},
SystemContext: &testSystemContext,
}
b.AddAppendedLinkedLayer(nil, imageName(layerNumber+6), "", "", ninthArchiveFile)
ref, err = imageStorage.Transport.ParseStoreReference(store, imageName(layerNumber))
require.NoErrorf(t, err, "parsing reference for to-be-committed image %q", imageName(layerNumber))
_, _, _, err = b.Commit(ctx, ref, commitOptions)
require.NoErrorf(t, err, "committing %q", imageName(layerNumber))
// Build one last image based on the previous one.
builderOptions.FromImage = imageName(layerNumber)
layerNumber += 7
b, err = NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder")
b.SetCreatedBy(imageName(layerNumber))
tenthFile := makeFile("file9", 0)
err = b.Add("/", false, AddAndCopyOptions{}, tenthFile)
require.NoError(t, err, "adding", tenthFile)
commitOptions = CommitOptions{
SystemContext: &testSystemContext,
}
ref, err = imageStorage.Transport.ParseStoreReference(store, imageName(layerNumber))
require.NoError(t, err, "parsing reference for to-be-committed image", imageName(layerNumber))
_, _, _, err = b.Commit(ctx, ref, commitOptions)
require.NoError(t, err, "committing", imageName(layerNumber))
// Get set to examine this image. At this point, each history entry
// should just have "image%d" as its CreatedBy field, and each layer
// should have the corresponding file (and nothing else) in it.
src, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "opening image source")
defer src.Close()
img, err := ref.NewImage(ctx, &testSystemContext)
require.NoError(t, err, "opening image")
defer img.Close()
config, err := img.OCIConfig(ctx)
require.NoError(t, err, "reading config in OCI format")
require.Len(t, config.History, 10, "history length")
for i := range config.History {
require.Equal(t, fmt.Sprintf("image%d", i), config.History[i].CreatedBy, "history createdBy is off")
}
require.Len(t, config.RootFS.DiffIDs, 10, "diffID list")
layerContents := func(archive io.ReadCloser) []string {
var contents []string
defer archive.Close()
tr := tar.NewReader(archive)
entry, err := tr.Next()
for entry != nil {
contents = append(contents, entry.Name)
if err != nil {
break
}
entry, err = tr.Next()
}
require.ErrorIs(t, err, io.EOF)
return contents
}
infos, err := img.LayerInfosForCopy(ctx)
require.NoError(t, err, "getting layer infos")
require.Len(t, infos, 10)
for i, blobInfo := range infos {
func() {
t.Helper()
rc, _, err := src.GetBlob(ctx, blobInfo, nil)
require.NoError(t, err, "getting blob", i)
defer rc.Close()
contents := layerContents(rc)
require.Len(t, contents, 1)
require.Equal(t, fmt.Sprintf("file%d", i), contents[0])
}()
}
}
func TestCommitCompression(t *testing.T) {
// This test cannot be parallelized as this uses NewBuilder()
// which eventually and indirectly accesses a global variable
// defined in `go-selinux`, this must be fixed at `go-selinux`
// or builder must enable sometime of locking mechanism i.e if
// routine is creating Builder other's must wait for it.
// Tracked here: https://github.com/containers/buildah/issues/5967
ctx := context.TODO()
graphDriverName := os.Getenv("STORAGE_DRIVER")
if graphDriverName == "" {
graphDriverName = "vfs"
}
t.Logf("using storage driver %q", graphDriverName)
store, err := storage.GetStore(storageTypes.StoreOptions{
RunRoot: t.TempDir(),
GraphRoot: t.TempDir(),
GraphDriverName: graphDriverName,
})
require.NoError(t, err, "initializing storage")
t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
builderOptions := BuilderOptions{
FromImage: "scratch",
NamespaceOptions: []NamespaceOption{{
Name: string(rspec.NetworkNamespace),
Host: true,
}},
SystemContext: &testSystemContext,
}
b, err := NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder")
payload := makeFile(t, "file0", 0)
b.SetCreatedBy("ADD file0 in /")
err = b.Add("/", false, AddAndCopyOptions{}, payload)
require.NoError(t, err, "adding", payload)
for _, compressor := range []struct {
compression archive.Compression
name string
expectError bool
layerMediaType string
}{
{archive.Uncompressed, "uncompressed", false, v1.MediaTypeImageLayer},
{archive.Gzip, "gzip", false, v1.MediaTypeImageLayerGzip},
{archive.Bzip2, "bz2", true, ""},
{archive.Xz, "xz", true, ""},
{archive.Zstd, "zstd", false, v1.MediaTypeImageLayerZstd},
} {
t.Run(compressor.name, func(t *testing.T) {
var ref types.ImageReference
commitOptions := CommitOptions{
PreferredManifestType: v1.MediaTypeImageManifest,
SystemContext: &testSystemContext,
Compression: compressor.compression,
}
imageName := compressor.name
ref, err := imageStorage.Transport.ParseStoreReference(store, imageName)
require.NoErrorf(t, err, "parsing reference for to-be-committed local image %q", imageName)
_, _, _, err = b.Commit(ctx, ref, commitOptions)
if compressor.expectError {
require.Errorf(t, err, "committing local image %q", imageName)
} else {
require.NoErrorf(t, err, "committing local image %q", imageName)
}
imageName = t.TempDir()
ref, err = ociLayout.Transport.ParseReference(imageName)
require.NoErrorf(t, err, "parsing reference for to-be-committed oci layout %q", imageName)
_, _, _, err = b.Commit(ctx, ref, commitOptions)
if compressor.expectError {
require.Errorf(t, err, "committing oci layout %q", imageName)
return
}
require.NoErrorf(t, err, "committing oci layout %q", imageName)
src, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoErrorf(t, err, "reading oci layout %q", imageName)
defer src.Close()
manifestBytes, manifestType, err := src.GetManifest(ctx, nil)
require.NoErrorf(t, err, "reading manifest from oci layout %q", imageName)
require.Equalf(t, v1.MediaTypeImageManifest, manifestType, "manifest type from oci layout %q looked wrong", imageName)
parsedManifest, err := manifest.OCI1FromManifest(manifestBytes)
require.NoErrorf(t, err, "parsing manifest from oci layout %q", imageName)
require.Lenf(t, parsedManifest.Layers, 1, "expected exactly one layer in oci layout %q", imageName)
require.Equalf(t, compressor.layerMediaType, parsedManifest.Layers[0].MediaType, "expected the layer media type to reflect compression in oci layout %q", imageName)
blobReadCloser, _, err := src.GetBlob(ctx, types.BlobInfo{
Digest: parsedManifest.Layers[0].Digest,
MediaType: parsedManifest.Layers[0].MediaType,
}, nil)
require.NoErrorf(t, err, "reading the first layer from oci layout %q", imageName)
defer blobReadCloser.Close()
blob, err := io.ReadAll(blobReadCloser)
require.NoErrorf(t, err, "consuming the first layer from oci layout %q", imageName)
require.Equalf(t, compressor.compression, archive.DetectCompression(blob), "detected compression looks wrong for layer in oci layout %q")
})
}
}
func TestCommitEmpty(t *testing.T) {
// This test cannot be parallelized as this uses NewBuilder()
// which eventually and indirectly accesses a global variable
// defined in `go-selinux`, this must be fixed at `go-selinux`
// or builder must enable sometime of locking mechanism i.e if
// routine is creating Builder other's must wait for it.
// Tracked here: https://github.com/containers/buildah/issues/5967
ctx := context.TODO()
graphDriverName := os.Getenv("STORAGE_DRIVER")
if graphDriverName == "" {
graphDriverName = "vfs"
}
t.Logf("using storage driver %q", graphDriverName)
store, err := storage.GetStore(storageTypes.StoreOptions{
RunRoot: t.TempDir(),
GraphRoot: t.TempDir(),
GraphDriverName: graphDriverName,
})
require.NoError(t, err, "initializing storage")
t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
builderOptions := BuilderOptions{
FromImage: "scratch",
NamespaceOptions: []NamespaceOption{{
Name: string(rspec.NetworkNamespace),
Host: true,
}},
SystemContext: &testSystemContext,
}
b, err := NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder")
committedLayoutDir := t.TempDir()
committedRef, err := ociLayout.ParseReference(committedLayoutDir)
require.NoError(t, err, "parsing reference to where we're committing a basic image")
_, _, _, err = b.Commit(ctx, committedRef, CommitOptions{})
require.NoError(t, err, "committing with default settings")
committedImg, err := committedRef.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "preparing to read committed image")
defer committedImg.Close()
committedManifestBytes, committedManifestType, err := committedImg.GetManifest(ctx, nil)
require.NoError(t, err, "reading manifest from committed image")
require.Equalf(t, v1.MediaTypeImageManifest, committedManifestType, "unexpected manifest type")
committedManifest, err := manifest.FromBlob(committedManifestBytes, committedManifestType)
require.NoError(t, err, "parsing manifest from committed image")
require.Equalf(t, 1, len(committedManifest.LayerInfos()), "expected one layer in manifest")
configReadCloser, _, err := committedImg.GetBlob(ctx, committedManifest.ConfigInfo(), nil)
require.NoError(t, err, "reading config blob from committed image")
defer configReadCloser.Close()
var committedImage v1.Image
err = json.NewDecoder(configReadCloser).Decode(&committedImage)
require.NoError(t, err, "parsing config blob from committed image")
require.Equalf(t, 1, len(committedImage.History), "expected one history entry")
require.Falsef(t, committedImage.History[0].EmptyLayer, "expected lone history entry to not be marked as an empty layer")
require.Equalf(t, 1, len(committedImage.RootFS.DiffIDs), "expected one rootfs layer")
t.Run("emptylayer", func(t *testing.T) {
options := CommitOptions{
EmptyLayer: true,
}
layoutDir := t.TempDir()
ref, err := ociLayout.ParseReference(layoutDir)
require.NoError(t, err, "parsing reference to image we're going to commit with EmptyLayer")
_, _, _, err = b.Commit(ctx, ref, options)
require.NoError(t, err, "committing with EmptyLayer = true")
img, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "preparing to read committed image")
defer img.Close()
manifestBytes, manifestType, err := img.GetManifest(ctx, nil)
require.NoError(t, err, "reading manifest from committed image")
require.Equalf(t, v1.MediaTypeImageManifest, manifestType, "unexpected manifest type")
parsedManifest, err := manifest.FromBlob(manifestBytes, manifestType)
require.NoError(t, err, "parsing manifest from committed image")
require.Zerof(t, len(parsedManifest.LayerInfos()), "expected no layers in manifest")
configReadCloser, _, err := img.GetBlob(ctx, parsedManifest.ConfigInfo(), nil)
require.NoError(t, err, "reading config blob from committed image")
defer configReadCloser.Close()
var image v1.Image
err = json.NewDecoder(configReadCloser).Decode(&image)
require.NoError(t, err, "parsing config blob from committed image")
require.Equalf(t, 1, len(image.History), "expected one history entry")
require.Truef(t, image.History[0].EmptyLayer, "expected lone history entry to be marked as an empty layer")
})
t.Run("omitlayerhistoryentry", func(t *testing.T) {
options := CommitOptions{
OmitLayerHistoryEntry: true,
}
layoutDir := t.TempDir()
ref, err := ociLayout.ParseReference(layoutDir)
require.NoError(t, err, "parsing reference to image we're going to commit with OmitLayerHistoryEntry")
_, _, _, err = b.Commit(ctx, ref, options)
require.NoError(t, err, "committing with OmitLayerHistoryEntry = true")
img, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "preparing to read committed image")
defer img.Close()
manifestBytes, manifestType, err := img.GetManifest(ctx, nil)
require.NoError(t, err, "reading manifest from committed image")
require.Equalf(t, v1.MediaTypeImageManifest, manifestType, "unexpected manifest type")
parsedManifest, err := manifest.FromBlob(manifestBytes, manifestType)
require.NoError(t, err, "parsing manifest from committed image")
require.Equalf(t, 0, len(parsedManifest.LayerInfos()), "expected no layers in manifest")
configReadCloser, _, err := img.GetBlob(ctx, parsedManifest.ConfigInfo(), nil)
require.NoError(t, err, "reading config blob from committed image")
defer configReadCloser.Close()
var image v1.Image
err = json.NewDecoder(configReadCloser).Decode(&image)
require.NoError(t, err, "parsing config blob from committed image")
require.Equalf(t, 0, len(image.History), "expected no history entries")
require.Equalf(t, 0, len(image.RootFS.DiffIDs), "expected no diff IDs")
})
builderOptions.FromImage = transports.ImageName(committedRef)
b, err = NewBuilder(ctx, store, builderOptions)
require.NoError(t, err, "creating builder from committed base image")
t.Run("derived-emptylayer", func(t *testing.T) {
options := CommitOptions{
EmptyLayer: true,
}
layoutDir := t.TempDir()
ref, err := ociLayout.ParseReference(layoutDir)
require.NoError(t, err, "parsing reference to image we're going to commit with EmptyLayer")
_, _, _, err = b.Commit(ctx, ref, options)
require.NoError(t, err, "committing with EmptyLayer = true")
img, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "preparing to read committed image")
defer img.Close()
manifestBytes, manifestType, err := img.GetManifest(ctx, nil)
require.NoError(t, err, "reading manifest from committed image")
require.Equalf(t, v1.MediaTypeImageManifest, manifestType, "unexpected manifest type")
parsedManifest, err := manifest.FromBlob(manifestBytes, manifestType)
require.NoError(t, err, "parsing manifest from committed image")
require.Equalf(t, len(committedManifest.LayerInfos()), len(parsedManifest.LayerInfos()), "expected no new layers in manifest")
configReadCloser, _, err := img.GetBlob(ctx, parsedManifest.ConfigInfo(), nil)
require.NoError(t, err, "reading config blob from committed image")
defer configReadCloser.Close()
var image v1.Image
err = json.NewDecoder(configReadCloser).Decode(&image)
require.NoError(t, err, "parsing config blob from committed image")
require.Equalf(t, len(committedImage.History)+1, len(image.History), "expected one new history entry")
require.Equalf(t, len(committedImage.RootFS.DiffIDs), len(image.RootFS.DiffIDs), "expected no new diff IDs")
require.Truef(t, image.History[1].EmptyLayer, "expected new history entry to be marked as an empty layer")
})
t.Run("derived-omitlayerhistoryentry", func(t *testing.T) {
options := CommitOptions{
OmitLayerHistoryEntry: true,
}
layoutDir := t.TempDir()
ref, err := ociLayout.ParseReference(layoutDir)
require.NoError(t, err, "parsing reference to image we're going to commit with OmitLayerHistoryEntry")
_, _, _, err = b.Commit(ctx, ref, options)
require.NoError(t, err, "committing with OmitLayerHistoryEntry = true")
img, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "preparing to read committed image")
defer img.Close()
manifestBytes, manifestType, err := img.GetManifest(ctx, nil)
require.NoError(t, err, "reading manifest from committed image")
require.Equalf(t, v1.MediaTypeImageManifest, manifestType, "unexpected manifest type")
parsedManifest, err := manifest.FromBlob(manifestBytes, manifestType)
require.NoError(t, err, "parsing manifest from committed image")
require.Equalf(t, len(committedManifest.LayerInfos()), len(parsedManifest.LayerInfos()), "expected no new layers in manifest")
configReadCloser, _, err := img.GetBlob(ctx, parsedManifest.ConfigInfo(), nil)
require.NoError(t, err, "reading config blob from committed image")
defer configReadCloser.Close()
var image v1.Image
err = json.NewDecoder(configReadCloser).Decode(&image)
require.NoError(t, err, "parsing config blob from committed image")
require.Equalf(t, len(committedImage.History), len(image.History), "expected no new history entry")
require.Equalf(t, len(committedImage.RootFS.DiffIDs), len(image.RootFS.DiffIDs), "expected no new diff IDs")
})
t.Run("derived-synthetic", func(t *testing.T) {
randomDir := t.TempDir()
randomFile, err := os.CreateTemp(randomDir, "file")
require.NoError(t, err, "creating a temporary file")
layerDigest := digest.Canonical.Digester()
_, err = io.CopyN(io.MultiWriter(layerDigest.Hash(), randomFile), rand.Reader, 512)
require.NoError(t, err, "writing a temporary file")
require.NoError(t, randomFile.Close(), "closing temporary file")
options := CommitOptions{
OmitLayerHistoryEntry: true,
AppendedLinkedLayers: []LinkedLayer{{
History: v1.History{
CreatedBy: "yolo",
}, // history entry to add
BlobPath: randomFile.Name(),
}},
}
layoutDir := t.TempDir()
ref, err := ociLayout.ParseReference(layoutDir)
require.NoErrorf(t, err, "parsing reference for to-be-committed image with externally-controlled changes")
_, _, _, err = b.Commit(ctx, ref, options)
require.NoError(t, err, "committing with OmitLayerHistoryEntry = true")
img, err := ref.NewImageSource(ctx, &testSystemContext)
require.NoError(t, err, "preparing to read committed image")
defer img.Close()
manifestBytes, manifestType, err := img.GetManifest(ctx, nil)
require.NoError(t, err, "reading manifest from committed image")
require.Equalf(t, v1.MediaTypeImageManifest, manifestType, "unexpected manifest type")
parsedManifest, err := manifest.FromBlob(manifestBytes, manifestType)
require.NoError(t, err, "parsing manifest from committed image")
require.Equalf(t, len(committedManifest.LayerInfos())+1, len(parsedManifest.LayerInfos()), "expected one new layer in manifest")
configReadCloser, _, err := img.GetBlob(ctx, parsedManifest.ConfigInfo(), nil)
require.NoError(t, err, "reading config blob from committed image")
defer configReadCloser.Close()
var image v1.Image
err = json.NewDecoder(configReadCloser).Decode(&image)
require.NoError(t, err, "decoding image config")
require.Equalf(t, len(committedImage.History)+1, len(image.History), "expected one new history entry")
require.Equalf(t, len(committedImage.RootFS.DiffIDs)+1, len(image.RootFS.DiffIDs), "expected one new diff ID")
require.Equalf(t, layerDigest.Digest(), image.RootFS.DiffIDs[len(image.RootFS.DiffIDs)-1], "expected new diff ID to match the randomly-generated layer")
})
}

View File

@ -2,8 +2,8 @@ package buildah
import (
"context"
"errors"
"io"
"os"
"path/filepath"
"time"
@ -12,9 +12,11 @@ import (
cp "github.com/containers/image/v5/copy"
"github.com/containers/image/v5/docker"
"github.com/containers/image/v5/signature"
is "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/types"
encconfig "github.com/containers/ocicrypt/config"
"github.com/containers/storage"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/unshare"
)
@ -25,7 +27,7 @@ const (
DOCKER = define.DOCKER
)
func getCopyOptions(store storage.Store, reportWriter io.Writer, sourceSystemContext *types.SystemContext, destinationSystemContext *types.SystemContext, manifestType string, removeSignatures bool, addSigner string, ociEncryptLayers *[]int, ociEncryptConfig *encconfig.EncryptConfig, ociDecryptConfig *encconfig.DecryptConfig) *cp.Options {
func getCopyOptions(store storage.Store, reportWriter io.Writer, sourceSystemContext *types.SystemContext, destinationSystemContext *types.SystemContext, manifestType string, removeSignatures bool, addSigner string, ociEncryptLayers *[]int, ociEncryptConfig *encconfig.EncryptConfig, ociDecryptConfig *encconfig.DecryptConfig, destinationTimestamp *time.Time) *cp.Options {
sourceCtx := getSystemContext(store, nil, "")
if sourceSystemContext != nil {
*sourceCtx = *sourceSystemContext
@ -45,6 +47,7 @@ func getCopyOptions(store storage.Store, reportWriter io.Writer, sourceSystemCon
OciEncryptConfig: ociEncryptConfig,
OciDecryptConfig: ociDecryptConfig,
OciEncryptLayers: ociEncryptLayers,
DestinationTimestamp: destinationTimestamp,
}
}
@ -59,7 +62,7 @@ func getSystemContext(store storage.Store, defaults *types.SystemContext, signat
if store != nil {
if sc.SystemRegistriesConfPath == "" && unshare.IsRootless() {
userRegistriesFile := filepath.Join(store.GraphRoot(), "registries.conf")
if _, err := os.Stat(userRegistriesFile); err == nil {
if err := fileutils.Exists(userRegistriesFile); err == nil {
sc.SystemRegistriesConfPath = userRegistriesFile
}
}
@ -67,22 +70,31 @@ func getSystemContext(store storage.Store, defaults *types.SystemContext, signat
return sc
}
func retryCopyImage(ctx context.Context, policyContext *signature.PolicyContext, dest, src, registry types.ImageReference, copyOptions *cp.Options, maxRetries int, retryDelay time.Duration) ([]byte, error) {
func retryCopyImage(ctx context.Context, policyContext *signature.PolicyContext, maybeWrappedDest, maybeWrappedSrc, directDest types.ImageReference, copyOptions *cp.Options, maxRetries int, retryDelay time.Duration) ([]byte, error) {
return retryCopyImageWithOptions(ctx, policyContext, maybeWrappedDest, maybeWrappedSrc, directDest, copyOptions, maxRetries, retryDelay, true)
}
func retryCopyImageWithOptions(ctx context.Context, policyContext *signature.PolicyContext, maybeWrappedDest, maybeWrappedSrc, directDest types.ImageReference, copyOptions *cp.Options, maxRetries int, retryDelay time.Duration, retryOnLayerUnknown bool) ([]byte, error) {
var (
manifestBytes []byte
err error
lastErr error
)
err = retry.RetryIfNecessary(ctx, func() error {
manifestBytes, err = cp.Image(ctx, policyContext, dest, src, copyOptions)
if registry != nil && registry.Transport().Name() != docker.Transport.Name() {
lastErr = err
return nil
}
err = retry.IfNecessary(ctx, func() error {
manifestBytes, err = cp.Image(ctx, policyContext, maybeWrappedDest, maybeWrappedSrc, copyOptions)
return err
}, &retry.RetryOptions{MaxRetry: maxRetries, Delay: retryDelay})
if lastErr != nil {
err = lastErr
}
}, &retry.RetryOptions{MaxRetry: maxRetries, Delay: retryDelay, IsErrorRetryable: func(err error) bool {
if retryOnLayerUnknown && directDest.Transport().Name() == is.Transport.Name() && errors.Is(err, storage.ErrLayerUnknown) {
// we were trying to reuse a layer that belonged to an
// image that was deleted at just the right (worst
// possible) time? yeah, try again
return true
}
if directDest.Transport().Name() != docker.Transport.Name() {
// if we're not talking to a registry, then nah
return false
}
// hand it off to the default should-this-be-retried logic
return retry.IsErrorRetryable(err)
}})
return manifestBytes, err
}

169
common_test.go Normal file
View File

@ -0,0 +1,169 @@
package buildah
import (
"archive/tar"
"bytes"
"context"
"encoding/json"
"os"
"path/filepath"
"testing"
"time"
cp "github.com/containers/image/v5/copy"
"github.com/containers/image/v5/signature"
imageStorage "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/storage"
storageTypes "github.com/containers/storage/types"
digest "github.com/opencontainers/go-digest"
ispec "github.com/opencontainers/image-spec/specs-go"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type testRetryCopyImageWrappedStore struct {
phantomImageID string
storage.Store
}
func (ts *testRetryCopyImageWrappedStore) CreateImage(id string, names []string, layer, metadata string, options *storage.ImageOptions) (*storage.Image, error) {
if id == ts.phantomImageID {
if img, err := ts.Store.Image(id); img != nil && err == nil {
// i'm another thread somewhere
if _, err := ts.Store.DeleteImage(id, true); err != nil {
return nil, err
}
}
}
return ts.Store.CreateImage(id, names, layer, metadata, options)
}
func TestRetryCopyImage(t *testing.T) {
t.Parallel()
ctx := context.TODO()
graphDriverName := os.Getenv("STORAGE_DRIVER")
if graphDriverName == "" {
graphDriverName = "vfs"
}
store, err := storage.GetStore(storageTypes.StoreOptions{
RunRoot: t.TempDir(),
GraphRoot: t.TempDir(),
GraphDriverName: graphDriverName,
})
require.NoError(t, err, "initializing storage")
t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
// construct an "image" that can be pulled into local storage
var layerBuffer bytes.Buffer
tw := tar.NewWriter(&layerBuffer)
err = tw.WriteHeader(&tar.Header{
Name: "rootfile",
Typeflag: tar.TypeReg,
Size: 1234,
})
require.NoError(t, err, "writing header for archive")
_, err = tw.Write(make([]byte, 1234))
require.NoError(t, err, "writing empty file to archive")
require.NoError(t, tw.Close(), "finishing layer")
layerDigest := digest.Canonical.FromBytes(layerBuffer.Bytes())
imageConfig := v1.Image{
RootFS: v1.RootFS{
Type: "layers",
DiffIDs: []digest.Digest{layerDigest},
},
}
imageConfigBytes, err := json.Marshal(&imageConfig)
require.NoError(t, err, "marshalling image configuration blob")
imageConfigDigest := digest.Canonical.FromBytes(imageConfigBytes)
imageManifest := v1.Manifest{
Versioned: ispec.Versioned{
SchemaVersion: 2,
},
MediaType: v1.MediaTypeImageManifest,
Config: v1.Descriptor{
MediaType: v1.MediaTypeImageConfig,
Size: int64(len(imageConfigBytes)),
Digest: digest.FromBytes(imageConfigBytes),
},
Layers: []v1.Descriptor{
{
MediaType: v1.MediaTypeImageLayer,
Size: int64(layerBuffer.Len()),
Digest: layerDigest,
},
},
}
imageManifestBytes, err := json.Marshal(&imageManifest)
require.NoError(t, err, "marshalling image manifest")
imageManifestDigest := digest.Canonical.FromBytes(imageManifestBytes)
// write it to an oci layout
ociDir := t.TempDir()
blobbyDir := filepath.Join(ociDir, "blobs")
require.NoError(t, os.Mkdir(blobbyDir, 0o700))
blobDir := filepath.Join(blobbyDir, layerDigest.Algorithm().String())
require.NoError(t, os.Mkdir(blobDir, 0o700))
require.NoError(t, os.WriteFile(filepath.Join(blobDir, layerDigest.Encoded()), layerBuffer.Bytes(), 0o600), "writing layer")
require.NoError(t, os.WriteFile(filepath.Join(blobDir, imageConfigDigest.Encoded()), imageConfigBytes, 0o600), "writing image config")
require.NoError(t, os.WriteFile(filepath.Join(blobDir, imageManifestDigest.Encoded()), imageManifestBytes, 0o600), "writing manifest")
imageIndex := v1.Index{
Versioned: ispec.Versioned{
SchemaVersion: 2,
},
MediaType: v1.MediaTypeImageIndex,
Manifests: []v1.Descriptor{
{
MediaType: v1.MediaTypeImageManifest,
Digest: imageManifestDigest,
Size: int64(len(imageManifestBytes)),
},
},
}
imageIndexBytes, err := json.Marshal(&imageIndex)
require.NoError(t, err, "marshalling image index")
require.NoError(t, os.WriteFile(filepath.Join(ociDir, v1.ImageIndexFile), imageIndexBytes, 0o600), "writing image index")
imageLayout := v1.ImageLayout{
Version: v1.ImageLayoutVersion,
}
imageLayoutBytes, err := json.Marshal(&imageLayout)
require.NoError(t, err, "marshalling image layout")
require.NoError(t, os.WriteFile(filepath.Join(ociDir, v1.ImageLayoutFile), imageLayoutBytes, 0o600), "writing image layout")
// pull the image, twice, just to make sure nothing weird happens
srcRef, err := alltransports.ParseImageName("oci:" + ociDir)
require.NoError(t, err, "building reference to image layout")
destRef, err := imageStorage.Transport.NewStoreReference(store, nil, imageConfigDigest.Encoded())
require.NoError(t, err, "building reference to image in store")
policy, err := signature.NewPolicyFromFile("tests/policy.json")
require.NoError(t, err, "reading signature policy")
policyContext, err := signature.NewPolicyContext(policy)
require.NoError(t, err, "building policy context")
t.Cleanup(func() {
require.NoError(t, policyContext.Destroy(), "destroying policy context")
})
_, err = retryCopyImage(ctx, policyContext, destRef, srcRef, destRef, &cp.Options{}, 3, 1*time.Second)
require.NoError(t, err, "copying image")
_, err = retryCopyImage(ctx, policyContext, destRef, srcRef, destRef, &cp.Options{}, 3, 1*time.Second)
require.NoError(t, err, "copying image")
// now make something weird happen
wrappedStore := &testRetryCopyImageWrappedStore{
phantomImageID: imageConfigDigest.Encoded(),
Store: store,
}
wrappedDestRef, err := imageStorage.Transport.NewStoreReference(wrappedStore, nil, imageConfigDigest.Encoded())
require.NoError(t, err, "building wrapped reference")
// copy with retry-on-storage-layer-unknown = false: expect an error
// (if it succeeds, either the test is broken, or we can remove this
// case from the retry function)
_, err = retryCopyImageWithOptions(ctx, policyContext, wrappedDestRef, srcRef, wrappedDestRef, &cp.Options{}, 3, 1*time.Second, false)
require.ErrorIs(t, err, storage.ErrLayerUnknown, "copying image")
// copy with retry-on-storage-layer-unknown = true: expect no error
_, err = retryCopyImageWithOptions(ctx, policyContext, wrappedDestRef, srcRef, wrappedDestRef, &cp.Options{}, 3, 1*time.Second, true)
require.NoError(t, err, "copying image")
}

156
config.go
View File

@ -4,11 +4,13 @@ import (
"context"
"encoding/json"
"fmt"
"maps"
"os"
"runtime"
"slices"
"strings"
"time"
"github.com/containerd/platforms"
"github.com/containers/buildah/define"
"github.com/containers/buildah/docker"
internalUtil "github.com/containers/buildah/internal/util"
@ -19,13 +21,12 @@ import (
"github.com/containers/storage/pkg/stringid"
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)
// unmarshalConvertedConfig obtains the config blob of img valid for the wantedManifestMIMEType format
// (either as it exists, or converting the image if necessary), and unmarshals it into dest.
// NOTE: The MIME type is of the _manifest_, not of the _config_ that is returned.
func unmarshalConvertedConfig(ctx context.Context, dest interface{}, img types.Image, wantedManifestMIMEType string) error {
func unmarshalConvertedConfig(ctx context.Context, dest any, img types.Image, wantedManifestMIMEType string) error {
_, actualManifestMIMEType, err := img.Manifest(ctx)
if err != nil {
return fmt.Errorf("getting manifest MIME type for %q: %w", transports.ImageName(img.Reference()), err)
@ -60,7 +61,7 @@ func unmarshalConvertedConfig(ctx context.Context, dest interface{}, img types.I
return nil
}
func (b *Builder) initConfig(ctx context.Context, img types.Image, sys *types.SystemContext) error {
func (b *Builder) initConfig(ctx context.Context, sys *types.SystemContext, img types.Image, options *BuilderOptions) error {
if img != nil { // A pre-existing image, as opposed to a "FROM scratch" new one.
rawManifest, manifestMIMEType, err := img.Manifest(ctx)
if err != nil {
@ -91,8 +92,26 @@ func (b *Builder) initConfig(ctx context.Context, img types.Image, sys *types.Sy
if err := json.Unmarshal(b.Manifest, &v1Manifest); err != nil {
return fmt.Errorf("parsing OCI manifest %q: %w", string(b.Manifest), err)
}
for k, v := range v1Manifest.Annotations {
b.ImageAnnotations[k] = v
if len(v1Manifest.Annotations) > 0 {
if b.ImageAnnotations == nil {
b.ImageAnnotations = make(map[string]string, len(v1Manifest.Annotations))
}
maps.Copy(b.ImageAnnotations, v1Manifest.Annotations)
}
}
} else {
if options == nil || options.CompatScratchConfig != types.OptionalBoolTrue {
b.Docker = docker.V2Image{
V1Image: docker.V1Image{
Config: &docker.Config{
WorkingDir: "/",
},
},
}
b.OCIv1 = ociv1.Image{
Config: ociv1.ImageConfig{
WorkingDir: "/",
},
}
}
}
@ -116,27 +135,21 @@ func (b *Builder) fixupConfig(sys *types.SystemContext) {
if b.OCIv1.Created == nil || b.OCIv1.Created.IsZero() {
b.OCIv1.Created = &now
}
currentPlatformSpecification := platforms.DefaultSpec()
if b.OS() == "" {
if sys != nil && sys.OSChoice != "" {
b.SetOS(sys.OSChoice)
} else {
b.SetOS(runtime.GOOS)
b.SetOS(currentPlatformSpecification.OS)
}
}
if b.Architecture() == "" {
if sys != nil && sys.ArchitectureChoice != "" {
b.SetArchitecture(sys.ArchitectureChoice)
} else {
b.SetArchitecture(runtime.GOARCH)
}
// in case the arch string we started with was shorthand for a known arch+variant pair, normalize it
ps := internalUtil.NormalizePlatform(ociv1.Platform{OS: b.OS(), Architecture: b.Architecture(), Variant: b.Variant()})
b.SetArchitecture(ps.Architecture)
b.SetVariant(ps.Variant)
}
if b.Variant() == "" {
if sys != nil && sys.VariantChoice != "" {
b.SetVariant(sys.VariantChoice)
} else {
b.SetArchitecture(currentPlatformSpecification.Architecture)
b.SetVariant(currentPlatformSpecification.Variant)
}
// in case the arch string we started with was shorthand for a known arch+variant pair, normalize it
ps := internalUtil.NormalizePlatform(ociv1.Platform{OS: b.OS(), Architecture: b.Architecture(), Variant: b.Variant()})
@ -158,7 +171,7 @@ func (b *Builder) setupLogger() {
// Annotations returns a set of key-value pairs from the image's manifest.
func (b *Builder) Annotations() map[string]string {
return copyStringStringMap(b.ImageAnnotations)
return maps.Clone(b.ImageAnnotations)
}
// SetAnnotation adds or overwrites a key's value from the image's manifest.
@ -180,7 +193,7 @@ func (b *Builder) UnsetAnnotation(key string) {
// ClearAnnotations removes all keys and their values from the image's
// manifest.
func (b *Builder) ClearAnnotations() {
b.ImageAnnotations = map[string]string{}
b.ImageAnnotations = nil
}
// CreatedBy returns a description of how this image was built.
@ -223,7 +236,7 @@ func (b *Builder) SetOSVersion(version string) {
// OSFeatures returns a list of OS features which the container, or a container
// built using an image built from this container, depends on the OS supplying.
func (b *Builder) OSFeatures() []string {
return copyStringSlice(b.OCIv1.OSFeatures)
return slices.Clone(b.OCIv1.OSFeatures)
}
// SetOSFeature adds a feature of the OS which the container, or a container
@ -327,7 +340,7 @@ func (b *Builder) SetUser(spec string) {
// OnBuild returns the OnBuild value from the container.
func (b *Builder) OnBuild() []string {
return copyStringSlice(b.Docker.Config.OnBuild)
return slices.Clone(b.Docker.Config.OnBuild)
}
// ClearOnBuild removes all values from the OnBuild structure
@ -363,7 +376,7 @@ func (b *Builder) SetWorkDir(there string) {
// Shell returns the default shell for running commands in the
// container, or in a container built using an image built from this container.
func (b *Builder) Shell() []string {
return copyStringSlice(b.Docker.Config.Shell)
return slices.Clone(b.Docker.Config.Shell)
}
// SetShell sets the default shell for running
@ -376,13 +389,13 @@ func (b *Builder) SetShell(shell []string) {
b.Logger.Warnf("SHELL is not supported for OCI image format, %s will be ignored. Must use `docker` format", shell)
}
b.Docker.Config.Shell = copyStringSlice(shell)
b.Docker.Config.Shell = slices.Clone(shell)
}
// Env returns a list of key-value pairs to be set when running commands in the
// container, or in a container built using an image built from this container.
func (b *Builder) Env() []string {
return copyStringSlice(b.OCIv1.Config.Env)
return slices.Clone(b.OCIv1.Config.Env)
}
// SetEnv adds or overwrites a value to the set of environment strings which
@ -432,22 +445,22 @@ func (b *Builder) ClearEnv() {
// set, to use when running a container built from an image built from this
// container.
func (b *Builder) Cmd() []string {
return copyStringSlice(b.OCIv1.Config.Cmd)
return slices.Clone(b.OCIv1.Config.Cmd)
}
// SetCmd sets the default command, or command parameters if an Entrypoint is
// set, to use when running a container built from an image built from this
// container.
func (b *Builder) SetCmd(cmd []string) {
b.OCIv1.Config.Cmd = copyStringSlice(cmd)
b.Docker.Config.Cmd = copyStringSlice(cmd)
b.OCIv1.Config.Cmd = slices.Clone(cmd)
b.Docker.Config.Cmd = slices.Clone(cmd)
}
// Entrypoint returns the command to be run for containers built from images
// built from this container.
func (b *Builder) Entrypoint() []string {
if len(b.OCIv1.Config.Entrypoint) > 0 {
return copyStringSlice(b.OCIv1.Config.Entrypoint)
return slices.Clone(b.OCIv1.Config.Entrypoint)
}
return nil
}
@ -455,14 +468,14 @@ func (b *Builder) Entrypoint() []string {
// SetEntrypoint sets the command to be run for in containers built from images
// built from this container.
func (b *Builder) SetEntrypoint(ep []string) {
b.OCIv1.Config.Entrypoint = copyStringSlice(ep)
b.Docker.Config.Entrypoint = copyStringSlice(ep)
b.OCIv1.Config.Entrypoint = slices.Clone(ep)
b.Docker.Config.Entrypoint = slices.Clone(ep)
}
// Labels returns a set of key-value pairs from the image's runtime
// configuration.
func (b *Builder) Labels() map[string]string {
return copyStringStringMap(b.OCIv1.Config.Labels)
return maps.Clone(b.OCIv1.Config.Labels)
}
// SetLabel adds or overwrites a key's value from the image's runtime
@ -669,11 +682,12 @@ func (b *Builder) Healthcheck() *docker.HealthConfig {
return nil
}
return &docker.HealthConfig{
Test: copyStringSlice(b.Docker.Config.Healthcheck.Test),
Interval: b.Docker.Config.Healthcheck.Interval,
Timeout: b.Docker.Config.Healthcheck.Timeout,
StartPeriod: b.Docker.Config.Healthcheck.StartPeriod,
Retries: b.Docker.Config.Healthcheck.Retries,
Test: slices.Clone(b.Docker.Config.Healthcheck.Test),
Interval: b.Docker.Config.Healthcheck.Interval,
Timeout: b.Docker.Config.Healthcheck.Timeout,
StartPeriod: b.Docker.Config.Healthcheck.StartPeriod,
StartInterval: b.Docker.Config.Healthcheck.StartInterval,
Retries: b.Docker.Config.Healthcheck.Retries,
}
}
@ -690,11 +704,12 @@ func (b *Builder) SetHealthcheck(config *docker.HealthConfig) {
b.Logger.Warnf("HEALTHCHECK is not supported for OCI image format and will be ignored. Must use `docker` format")
}
b.Docker.Config.Healthcheck = &docker.HealthConfig{
Test: copyStringSlice(config.Test),
Interval: config.Interval,
Timeout: config.Timeout,
StartPeriod: config.StartPeriod,
Retries: config.Retries,
Test: slices.Clone(config.Test),
Interval: config.Interval,
Timeout: config.Timeout,
StartPeriod: config.StartPeriod,
StartInterval: config.StartInterval,
Retries: config.Retries,
}
}
}
@ -745,3 +760,62 @@ func (b *Builder) AddAppendedEmptyLayer(created *time.Time, createdBy, author, c
func (b *Builder) ClearAppendedEmptyLayers() {
b.AppendedEmptyLayers = nil
}
// AddPrependedLinkedLayer adds an item to the history that we'll create when
// committing the image, optionally with a layer, after any history we inherit
// from the base image, but before the history item that we'll use to describe
// the new layer that we're adding.
// The blobPath can be either the location of an uncompressed archive, or a
// directory whose contents will be archived to use as a layer blob. Leaving
// blobPath empty is functionally similar to calling AddPrependedEmptyLayer().
func (b *Builder) AddPrependedLinkedLayer(created *time.Time, createdBy, author, comment, blobPath string) {
if created != nil {
copiedTimestamp := *created
created = &copiedTimestamp
}
b.PrependedLinkedLayers = append(b.PrependedLinkedLayers, LinkedLayer{
BlobPath: blobPath,
History: ociv1.History{
Created: created,
CreatedBy: createdBy,
Author: author,
Comment: comment,
EmptyLayer: blobPath == "",
},
})
}
// ClearPrependedLinkedLayers clears the list of history entries that we'll add
// the committed image before the layer that we're adding (if we're adding it).
func (b *Builder) ClearPrependedLinkedLayers() {
b.PrependedLinkedLayers = nil
}
// AddAppendedLinkedLayer adds an item to the history that we'll create when
// committing the image, optionally with a layer, after the history item that
// we'll use to describe the new layer that we're adding.
// The blobPath can be either the location of an uncompressed archive, or a
// directory whose contents will be archived to use as a layer blob. Leaving
// blobPath empty is functionally similar to calling AddAppendedEmptyLayer().
func (b *Builder) AddAppendedLinkedLayer(created *time.Time, createdBy, author, comment, blobPath string) {
if created != nil {
copiedTimestamp := *created
created = &copiedTimestamp
}
b.AppendedLinkedLayers = append(b.AppendedLinkedLayers, LinkedLayer{
BlobPath: blobPath,
History: ociv1.History{
Created: created,
CreatedBy: createdBy,
Author: author,
Comment: comment,
EmptyLayer: blobPath == "",
},
})
}
// ClearAppendedLinkedLayers clears the list of linked layers that we'll add to
// the committed image after the layer that we're adding (if we're adding it).
func (b *Builder) ClearAppendedLinkedLayers() {
b.AppendedLinkedLayers = nil
}

View File

@ -1,113 +0,0 @@
# [stable|testing|upstream]/Containerfile
#
# Build a Buildah container image from the latest version
# of Fedora.
#
# FLAVOR defaults to stable if unset
#
# FLAVOR=stable acquires a stable version of Buildah
# from the Fedoras Updates System.
# FLAVOR=testing acquires a testing version of Buildah
# from the Fedoras Updates System.
# FLAVOR=upstream acquires a testing version of Buildah
# from the Fedora Copr Buildsystem.
# https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/
#
# https://bodhi.fedoraproject.org/updates/?search=buildah
#
# This image can be used to create a secured container
# that runs safely with privileges within the container.
#
FROM registry.fedoraproject.org/fedora:latest
ARG FLAVOR=stable
label "io.containers.capabilities"="CHOWN,DAC_OVERRIDE,FOWNER,FSETID,KILL,NET_BIND_SERVICE,SETFCAP,SETGID,SETPCAP,SETUID,CHOWN,DAC_OVERRIDE,FOWNER,FSETID,KILL,NET_BIND_SERVICE,SETFCAP,SETGID,SETPCAP,SETUID,SYS_CHROOT"
# When building for multiple-architectures in parallel using emulation
# it's really easy for one/more dnf processes to timeout or mis-count
# the minimum download rates. Bump both to be extremely forgiving of
# an overworked host.
RUN echo -e "\n\n# Added during image build" >> /etc/dnf/dnf.conf && \
echo -e "minrate=100\ntimeout=60\n" >> /etc/dnf/dnf.conf
# Don't include container-selinux and remove
# directories used by dnf that are just taking
# up space.
# TODO: rpm --setcaps... needed due to Fedora (base) image builds
# being (maybe still?) affected by
# https://bugzilla.redhat.com/show_bug.cgi?id=1995337#c3
RUN dnf -y makecache && \
dnf -y update && \
rpm --setcaps shadow-utils 2>/dev/null && \
case "${FLAVOR}" in \
stable) \
dnf -y install buildah fuse-overlayfs cpp --exclude container-selinux \
;; \
testing) \
dnf -y install --enablerepo=updates-testing buildah fuse-overlayfs cpp \
--exclude container-selinux \
;; \
upstream) \
dnf -y install 'dnf-command(copr)' --enablerepo=updates-testing && \
dnf -y copr enable rhcontainerbot/podman-next && \
dnf -y install buildah fuse-overlayfs \
--exclude container-selinux \
--enablerepo=updates-testing \
;; \
*) \
printf "\\nFLAVOR argument must be set and valid, currently: '${FLAVOR}'\\n\\n" 1>&2 && \
exit 1 \
;; \
esac && \
dnf -y clean all && \
rm -rf /var/cache /var/log/dnf* /var/log/yum.*
ADD ./containers.conf /etc/containers/
# Setup internal Buildah to pass secrets/subscriptions down from host to internal container
RUN printf '/run/secrets/etc-pki-entitlement:/run/secrets/etc-pki-entitlement\n/run/secrets/rhsm:/run/secrets/rhsm\n' > /etc/containers/mounts.conf
# Copy & modify the defaults to provide reference if runtime changes needed.
# Changes here are required for running with fuse-overlay storage inside container.
RUN sed -e 's|^#mount_program|mount_program|g' \
-e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
/usr/share/containers/storage.conf \
> /etc/containers/storage.conf && \
chmod 644 /etc/containers/storage.conf && \
chmod 644 /etc/containers/containers.conf
RUN mkdir -p /var/lib/shared/overlay-images \
/var/lib/shared/overlay-layers \
/var/lib/shared/vfs-images \
/var/lib/shared/vfs-layers && \
touch /var/lib/shared/overlay-images/images.lock && \
touch /var/lib/shared/overlay-layers/layers.lock && \
touch /var/lib/shared/vfs-images/images.lock && \
touch /var/lib/shared/vfs-layers/layers.lock
# Define uid/gid ranges for our user https://github.com/containers/buildah/issues/3053
RUN useradd build && \
echo -e "build:1:999\nbuild:1001:64535" > /etc/subuid && \
echo -e "build:1:999\nbuild:1001:64535" > /etc/subgid && \
mkdir -p /home/build/.local/share/containers && \
mkdir -p /home/build/.config/containers && \
chown -R build:build /home/build
# See: https://github.com/containers/buildah/issues/4669
# Copy & modify the config for the `build` user and remove the global
# `runroot` and `graphroot` which current `build` user cannot access,
# in such case storage will choose a runroot in `/var/tmp`.
RUN sed -e 's|^#mount_program|mount_program|g' \
-e 's|^graphroot|#graphroot|g' \
-e 's|^runroot|#runroot|g' \
/etc/containers/storage.conf \
> /home/build/.config/containers/storage.conf && \
chown build:build /home/build/.config/containers/storage.conf
VOLUME /var/lib/containers
VOLUME /home/build/.local/share/containers
# Set an environment variable to default to chroot isolation for RUN
# instructions and "buildah run".
ENV BUILDAH_ISOLATION=chroot

View File

@ -1,86 +1,2 @@
[comment]: <> (***ATTENTION*** ***WARNING*** ***ALERT*** ***CAUTION*** ***DANGER***)
[comment]: <> ()
[comment]: <> (ANY changes made to this file, once committed/merged must)
[comment]: <> (be manually copy/pasted -in markdown- into the description)
[comment]: <> (field on Quay at the following locations:)
[comment]: <> ()
[comment]: <> (https://quay.io/repository/containers/buildah)
[comment]: <> (https://quay.io/repository/buildah/stable)
[comment]: <> (https://quay.io/repository/buildah/testing)
[comment]: <> (https://quay.io/repository/buildah/upstream)
[comment]: <> ()
[comment]: <> (***ATTENTION*** ***WARNING*** ***ALERT*** ***CAUTION*** ***DANGER***)
![buildah logo](https://cdn.rawgit.com/containers/buildah/main/logos/buildah-logo_large.png)
# buildahimage
## Overview
This directory contains the Dockerfiles necessary to create the buildahimage container
images that are housed on quay.io under the buildah account. All repositories where
the images live are public and can be pulled without credentials. These container images are secured and the
resulting containers can run safely with privileges within the container.
The container images are built using the latest Fedora and then Buildah is installed into them.
The PATH in the container images is set to the default PATH provided by Fedora. Also, the
ENTRYPOINT and the WORKDIR variables are not set within these container images, as such they
default to `/`.
The container images are:
* `quay.io/containers/buildah:<version>` and `quay.io/buildah/stable:<version>` -
These images are built daily. They are intended to contain an unchanging
and stable version of buildah. For the most recent `<version>` tags (`vX`,
`vX.Y`, and `vX.Y.Z`) the image contents will be updated daily to incorporate
(especially) security upgrades. For build details, please [see the
configuration file](stable/Dockerfile).
* `quay.io/containers/buildah:latest` and `quay.io/buildah/stable:latest` -
Built daily using the same Dockerfile as above. The buildah version
will remain the "latest" available in Fedora, however the other image
contents may vary compared to the version-tagged images.
* `quay.io/buildah/testing:latest` - This image is built daily, using the
latest version of Buildah that was in the Fedora `updates-testing` repository.
The image is Built with [the testing Dockerfile](testing/Dockerfile).
* `quay.io/buildah/upstream:latest` - This image is built daily using the latest
code found in this GitHub repository. Due to the image changing frequently,
it's not guaranteed to be stable or even executable. The image is built with
[the upstream Dockerfile](upstream/Dockerfile). Note: The actual compilation
of upstream buildah [occurs continuously in
COPR](https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/).
## Sample Usage
Although not required, it is suggested that [Podman](https://github.com/containers/podman) be used with these container images.
```
podman pull docker://quay.io/buildah/stable:latest
podman run stable buildah version
# Create a directory on the host to mount the container's
# /var/lib/container directory to so containers can be
# run within the container.
mkdir /var/lib/mycontainer
# Run the image detached using the host's network in a container name
# buildahctr, turn off label and seccomp confinement in the container
# and then do a little shell hackery to keep the container up and running.
podman run --detach --name=buildahctr --net=host --security-opt label=disable --security-opt seccomp=unconfined --device /dev/fuse:rw -v /var/lib/mycontainer:/var/lib/containers:Z stable sh -c 'while true ;do sleep 100000 ; done'
podman exec -it buildahctr /bin/sh
# Now inside of the container
buildah from alpine
buildah images
exit
```
**Note:** If you encounter a `fuse: device not found` error when running the container image, it is likely that
the fuse kernel module has not been loaded on your host system. Use the command `modprobe fuse` to load the
module and then run the container image. To enable this automatically at boot time, you can add a configuration
file to `/etc/modules.load.d`. See `man modules-load.d` for more details.
The buildah container image build context and automation have been
moved to [https://github.com/containers/image_build/tree/main/buildah](https://github.com/containers/image_build/tree/main/buildah)

View File

@ -1,2 +0,0 @@
[engine]
cgroup_manager = "cgroupfs"

View File

@ -68,6 +68,10 @@ CIRRUS_BASE_SHA=${CIRRUS_BASE_SHA:-unknown$(date +%d)} # difficult to reliably
CIRRUS_BUILD_ID=${CIRRUS_BUILD_ID:-unknown$(date +%s)} # must be short and unique enough
CIRRUS_TASK_ID=${CIRRUS_BUILD_ID:-unknown$(date +%d)} # to prevent state thrashing when
# debugging with `hack/get_ci_vm.sh`
# All CI jobs use a local registry
export CI_USE_REGISTRY_CACHE=true
# Regex defining all CI-related env. vars. necessary for all possible
# testing operations on all platforms and versions. This is necessary
# to avoid needlessly passing through global/system values across
@ -77,7 +81,7 @@ CIRRUS_TASK_ID=${CIRRUS_BUILD_ID:-unknown$(date +%d)} # to prevent state thras
# N/B: Don't include BUILDAH_ISOLATION, STORAGE_DRIVER, or CGROUP_MANAGER
# here because they will negatively affect execution of the rootless
# integration tests.
PASSTHROUGH_ENV_EXACT='DEST_BRANCH|DISTRO_NV|GOPATH|GOSRC|ROOTLESS_USER|SCRIPT_BASE|IN_PODMAN_IMAGE'
PASSTHROUGH_ENV_EXACT='BUILDAH_RUNTIME|DEST_BRANCH|DISTRO_NV|GOPATH|GOSRC|ROOTLESS_USER|SCRIPT_BASE|IN_PODMAN_IMAGE'
# List of envariable patterns which must match AT THE BEGINNING of the name.
PASSTHROUGH_ENV_ATSTART='CI|TEST'
@ -92,8 +96,8 @@ PASSTHROUGH_ENV_RE="(^($PASSTHROUGH_ENV_EXACT)\$)|(^($PASSTHROUGH_ENV_ATSTART))|
SECRET_ENV_RE='ACCOUNT|GC[EP]..|SSH|PASSWORD|SECRET|TOKEN'
# FQINs needed for testing
REGISTRY_FQIN=${REGISTRY_FQIN:-docker.io/library/registry}
ALPINE_FQIN=${ALPINE_FQIN:-docker.io/library/alpine}
REGISTRY_FQIN=${REGISTRY_FQIN:-quay.io/libpod/registry:2.8.2}
ALPINE_FQIN=${ALPINE_FQIN:-quay.io/libpod/alpine}
# for in-container testing
IN_PODMAN_NAME="in_podman_$CIRRUS_TASK_ID"
@ -189,7 +193,7 @@ in_podman() {
done <<<"$(passthrough_envars)"
showrun podman run -i --name="$IN_PODMAN_NAME" \
--net="container:registry" \
--net=host \
--privileged \
--cgroupns=host \
"${envargs[@]}" \
@ -200,7 +204,7 @@ in_podman() {
-e "CGROUP_MANAGER=cgroupfs" \
-v "$HOME/auth:$HOME/auth:ro" \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
-v /dev/fuse:/dev/fuse:rw \
--device /dev/fuse:rwm \
-v "$GOSRC:$GOSRC:z" \
--workdir "$GOSRC" \
"$@"
@ -292,11 +296,22 @@ setup_rootless() {
msg "************************************************************"
cd $GOSRC || exit 1
# Guarantee independence from specific values
rootless_uid=$[RANDOM+1000]
rootless_gid=$[RANDOM+1000]
msg "creating $rootless_uid:$rootless_gid $ROOTLESS_USER user"
rootless_uid=$((RANDOM+1000))
rootless_gid=$((RANDOM+1000))
rootless_supplemental_gid1=$((rootless_gid+1))
rootless_supplemental_gid2=$((rootless_supplemental_gid1+1))
rootless_supplemental_gid3=$((rootless_supplemental_gid2+1))
msg "creating $rootless_uid:$rootless_gid,$rootless_supplemental_gid1,$rootless_supplemental_gid2,$rootless_supplemental_gid3 $ROOTLESS_USER user"
groupadd -g $rootless_gid $ROOTLESS_USER
useradd -g $rootless_gid -u $rootless_uid --no-user-group --create-home $ROOTLESS_USER
groupadd -g $rootless_supplemental_gid1 ${ROOTLESS_USER}sg1
groupadd -g $rootless_supplemental_gid2 ${ROOTLESS_USER}sg2
groupadd -g $rootless_supplemental_gid3 ${ROOTLESS_USER}sg3
useradd -g $rootless_gid -G ${ROOTLESS_USER}sg1,${ROOTLESS_USER}sg2,${ROOTLESS_USER}sg3 -u $rootless_uid --no-user-group --create-home $ROOTLESS_USER
rootless_supplemental_gid4=$(awk 'BEGIN{FS=":"}/^rootlessuser:/{print $2+$3}' /etc/subgid)
groupadd -g $rootless_supplemental_gid4 ${ROOTLESS_USER}sg4
usermod -G ${ROOTLESS_USER}sg1,${ROOTLESS_USER}sg2,${ROOTLESS_USER}sg3,${ROOTLESS_USER}sg4 $ROOTLESS_USER
msg "running id for $ROOTLESS_USER"
id $ROOTLESS_USER
# We also set up rootless user for image-scp tests (running as root)
if [[ $PRIV_NAME = "rootless" ]]; then

View File

@ -10,6 +10,9 @@ source $(dirname $0)/lib.sh
req_env_vars OS_RELEASE_ID OS_RELEASE_VER GOSRC IN_PODMAN_IMAGE CIRRUS_CHANGE_TITLE
msg "Running df."
df -hT
msg "Disabling git repository owner-check system-wide."
# Newer versions of git bark if repo. files are unexpectedly owned.
# This mainly affects rootless and containerized testing. But
@ -84,6 +87,18 @@ echo "Configuring /etc/containers/registries.conf"
mkdir -p /etc/containers
echo -e "[registries.search]\nregistries = ['docker.io', 'registry.fedoraproject.org', 'quay.io']" | tee /etc/containers/registries.conf
# As of July 2024, CI VMs come built-in with a registry.
LCR=/var/cache/local-registry/local-cache-registry
if [[ -x $LCR ]]; then
# Images in cache registry are prepopulated at the time
# VMs are built. If any PR adds a dependency on new images,
# those must be fetched now, at VM start time. This should
# be rare, and must be fixed in next automation_images build.
while read new_image; do
$LCR cache $new_image
done < <(grep '^[^#]' tests/NEW-IMAGES || true)
fi
show_env_vars
if [[ -z "$CONTAINER" ]]; then

View File

@ -63,11 +63,17 @@ else
export GITVALIDATE_EPOCH="$CIRRUS_LAST_GREEN_CHANGE"
fi
echo "Linting & Validating from ${GITVALIDATE_EPOCH:-default EPOCH}"
showrun make lint LINTFLAGS="--deadline=20m --color=always -j1"
showrun make lint LINTFLAGS="--timeout=20m --color=always -j1"
showrun make validate
;;
unit)
showrun make test-unit
race=
if [[ -z "$CIRRUS_PR" ]]; then
# If not running on a PR then run unit tests
# with appropriate `-race` flags.
race="-race"
fi
showrun make test-unit RACEFLAGS=$race
;;
conformance)
# Typically it's undesirable to install packages at runtime.

View File

@ -16,7 +16,6 @@ import (
"github.com/containers/buildah/internal/mkcw"
mkcwtypes "github.com/containers/buildah/internal/mkcw/types"
"github.com/containers/image/v5/types"
"github.com/containers/storage"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -67,8 +66,13 @@ func (d *dummyAttestationHandler) ServeHTTP(rw http.ResponseWriter, req *http.Re
}
func TestCWConvertImage(t *testing.T) {
// This test cannot be parallelized as this uses NewBuilder()
// which eventually and indirectly accesses a global variable
// defined in `go-selinux`, this must be fixed at `go-selinux`
// or builder must enable sometime of locking mechanism i.e if
// routine is creating Builder other's must wait for it.
// Tracked here: https://github.com/containers/buildah/issues/5967
ctx := context.TODO()
systemContext := &types.SystemContext{}
for _, status := range []int{http.StatusOK, http.StatusInternalServerError} {
for _, ignoreChainRetrievalErrors := range []bool{false, true} {
for _, ignoreAttestationErrors := range []bool{false, true} {
@ -110,8 +114,9 @@ func TestCWConvertImage(t *testing.T) {
AttestationURL: "http://" + addr.String(),
IgnoreAttestationErrors: ignoreAttestationErrors,
Slop: "16MB",
SignaturePolicyPath: testSystemContext.SignaturePolicyPath,
}
id, _, _, err := CWConvertImage(ctx, systemContext, store, options)
id, _, _, err := CWConvertImage(ctx, &testSystemContext, store, options)
if status != http.StatusOK && !ignoreAttestationErrors {
assert.Error(t, err)
return

File diff suppressed because it is too large Load Diff

View File

@ -13,9 +13,9 @@ import (
"github.com/containers/storage/pkg/mount"
"github.com/containers/storage/pkg/reexec"
"github.com/moby/sys/capability"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/syndtr/gocapability/capability"
"golang.org/x/sys/unix"
)
@ -117,17 +117,17 @@ func TestGetPermissionErrorChroot(t *testing.T) {
func testGetPermissionError(t *testing.T) {
dropCaps := []capability.Cap{capability.CAP_DAC_OVERRIDE, capability.CAP_DAC_READ_SEARCH}
tmp := t.TempDir()
err := os.Mkdir(filepath.Join(tmp, "unreadable-directory"), 0000)
err := os.Mkdir(filepath.Join(tmp, "unreadable-directory"), 0o000)
require.NoError(t, err, "error creating an unreadable directory")
err = os.Mkdir(filepath.Join(tmp, "readable-directory"), 0755)
err = os.Mkdir(filepath.Join(tmp, "readable-directory"), 0o755)
require.NoError(t, err, "error creating a readable directory")
err = os.Mkdir(filepath.Join(tmp, "readable-directory", "unreadable-subdirectory"), 0000)
err = os.Mkdir(filepath.Join(tmp, "readable-directory", "unreadable-subdirectory"), 0o000)
require.NoError(t, err, "error creating an unreadable subdirectory")
err = os.WriteFile(filepath.Join(tmp, "unreadable-file"), []byte("hi, i'm a file that you can't read"), 0000)
err = os.WriteFile(filepath.Join(tmp, "unreadable-file"), []byte("hi, i'm a file that you can't read"), 0o000)
require.NoError(t, err, "error creating an unreadable file")
err = os.WriteFile(filepath.Join(tmp, "readable-file"), []byte("hi, i'm also a file, and you can read me"), 0644)
err = os.WriteFile(filepath.Join(tmp, "readable-file"), []byte("hi, i'm also a file, and you can read me"), 0o644)
require.NoError(t, err, "error creating a readable file")
err = os.WriteFile(filepath.Join(tmp, "readable-directory", "unreadable-file"), []byte("hi, i'm also a file that you can't read"), 0000)
err = os.WriteFile(filepath.Join(tmp, "readable-directory", "unreadable-file"), []byte("hi, i'm also a file that you can't read"), 0o000)
require.NoError(t, err, "error creating an unreadable file in a readable directory")
for _, ignore := range []bool{false, true} {
t.Run(fmt.Sprintf("ignore=%v", ignore), func(t *testing.T) {
@ -163,7 +163,7 @@ func TestGetNoCrossDevice(t *testing.T) {
require.NoError(t, err, "error creating new mount namespace")
subdir := filepath.Join(tmpdir, "subdir")
err = os.Mkdir(subdir, 0755)
err = os.Mkdir(subdir, 0o755)
require.NoErrorf(t, err, "error creating %q", subdir)
err = mount.Mount("tmpfs", subdir, "tmpfs", "rw")
@ -174,7 +174,7 @@ func TestGetNoCrossDevice(t *testing.T) {
}()
skipped := filepath.Join(subdir, "skipped.txt")
err = os.WriteFile(skipped, []byte("this file should have been skipped\n"), 0644)
err = os.WriteFile(skipped, []byte("this file should have been skipped\n"), 0o644)
require.NoErrorf(t, err, "error writing file at %q", skipped)
var buf bytes.Buffer

View File

@ -13,6 +13,7 @@ import (
"path"
"path/filepath"
"reflect"
"slices"
"sort"
"strconv"
"strings"
@ -48,7 +49,7 @@ func makeContents(length int64) io.ReadCloser {
for count < length {
if _, err := buffered.Write([]byte{"0123456789abcdef"[count%16]}); err != nil {
buffered.Flush()
pipeWriter.CloseWithError(err) // nolint:errcheck
pipeWriter.CloseWithError(err)
return
}
count++
@ -111,7 +112,7 @@ func makeArchive(headers []tar.Header, contents map[string][]byte) io.ReadCloser
tw.Close()
buffered.Flush()
if err != nil {
pipeWriter.CloseWithError(err) // nolint:errcheck
pipeWriter.CloseWithError(err)
} else {
pipeWriter.Close()
}
@ -176,14 +177,15 @@ type enumeratedFile struct {
}
var (
testDate = time.Unix(1485449953, 0)
testDate = time.Unix(1485449953, 0)
secondTestDate = time.Unix(1485449953*2, 0)
uid = os.Getuid()
testArchiveSlice = makeArchiveSlice([]tar.Header{
{Name: "item-0", Typeflag: tar.TypeReg, Size: 123, Mode: 0600, ModTime: testDate},
{Name: "item-1", Typeflag: tar.TypeReg, Size: 456, Mode: 0600, ModTime: testDate},
{Name: "item-2", Typeflag: tar.TypeReg, Size: 789, Mode: 0600, ModTime: testDate},
{Name: "item-0", Typeflag: tar.TypeReg, Size: 123, Mode: 0o600, ModTime: testDate},
{Name: "item-1", Typeflag: tar.TypeReg, Size: 456, Mode: 0o600, ModTime: testDate},
{Name: "item-2", Typeflag: tar.TypeReg, Size: 789, Mode: 0o600, ModTime: testDate},
})
testArchives = []struct {
@ -204,38 +206,38 @@ var (
name: "regular",
rootOnly: false,
headers: []tar.Header{
{Name: "file-0", Typeflag: tar.TypeReg, Size: 123456789, Mode: 0600, ModTime: testDate},
{Name: "file-a", Typeflag: tar.TypeReg, Size: 23, Mode: 0600, ModTime: testDate},
{Name: "file-b", Typeflag: tar.TypeReg, Size: 23, Mode: 0600, ModTime: testDate},
{Name: "file-c", Typeflag: tar.TypeLink, Linkname: "file-a", Mode: 0600, ModTime: testDate},
{Name: "file-u", Typeflag: tar.TypeReg, Size: 23, Mode: cISUID | 0755, ModTime: testDate},
{Name: "file-g", Typeflag: tar.TypeReg, Size: 23, Mode: cISGID | 0755, ModTime: testDate},
{Name: "file-t", Typeflag: tar.TypeReg, Size: 23, Mode: cISVTX | 0755, ModTime: testDate},
{Name: "link-0", Typeflag: tar.TypeSymlink, Linkname: "../file-0", Size: 123456789, Mode: 0777, ModTime: testDate},
{Name: "link-a", Typeflag: tar.TypeSymlink, Linkname: "file-a", Size: 23, Mode: 0777, ModTime: testDate},
{Name: "link-b", Typeflag: tar.TypeSymlink, Linkname: "../file-a", Size: 23, Mode: 0777, ModTime: testDate},
{Name: "hlink-0", Typeflag: tar.TypeLink, Linkname: "file-0", Size: 123456789, Mode: 0600, ModTime: testDate},
{Name: "hlink-a", Typeflag: tar.TypeLink, Linkname: "/file-a", Size: 23, Mode: 0600, ModTime: testDate},
{Name: "hlink-b", Typeflag: tar.TypeLink, Linkname: "../file-b", Size: 23, Mode: 0600, ModTime: testDate},
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0700, ModTime: testDate},
{Name: "subdir-a/file-n", Typeflag: tar.TypeReg, Size: 108, Mode: 0660, ModTime: testDate},
{Name: "subdir-a/file-o", Typeflag: tar.TypeReg, Size: 34, Mode: 0660, ModTime: testDate},
{Name: "subdir-a/file-a", Typeflag: tar.TypeSymlink, Linkname: "../file-a", Size: 23, Mode: 0777, ModTime: testDate},
{Name: "subdir-a/file-b", Typeflag: tar.TypeSymlink, Linkname: "../../file-b", Size: 23, Mode: 0777, ModTime: testDate},
{Name: "subdir-a/file-c", Typeflag: tar.TypeSymlink, Linkname: "/file-c", Size: 23, Mode: 0777, ModTime: testDate},
{Name: "subdir-b", Typeflag: tar.TypeDir, Mode: 0700, ModTime: testDate},
{Name: "subdir-b/file-n", Typeflag: tar.TypeReg, Size: 216, Mode: 0660, ModTime: testDate},
{Name: "subdir-b/file-o", Typeflag: tar.TypeReg, Size: 45, Mode: 0660, ModTime: testDate},
{Name: "subdir-c", Typeflag: tar.TypeDir, Mode: 0700, ModTime: testDate},
{Name: "subdir-c/file-n", Typeflag: tar.TypeReg, Size: 432, Mode: 0666, ModTime: testDate},
{Name: "subdir-c/file-o", Typeflag: tar.TypeReg, Size: 56, Mode: 0666, ModTime: testDate},
{Name: "subdir-d", Typeflag: tar.TypeDir, Mode: 0700, ModTime: testDate},
{Name: "subdir-d/hlink-0", Typeflag: tar.TypeLink, Linkname: "../file-0", Size: 123456789, Mode: 0600, ModTime: testDate},
{Name: "subdir-d/hlink-a", Typeflag: tar.TypeLink, Linkname: "/file-a", Size: 23, Mode: 0600, ModTime: testDate},
{Name: "subdir-d/hlink-b", Typeflag: tar.TypeLink, Linkname: "../../file-b", Size: 23, Mode: 0600, ModTime: testDate},
{Name: "archive-a", Typeflag: tar.TypeReg, Size: 0, Mode: 0600, ModTime: testDate},
{Name: "subdir-e", Typeflag: tar.TypeDir, Mode: 0500, ModTime: testDate},
{Name: "subdir-e/file-p", Typeflag: tar.TypeReg, Size: 890, Mode: 0600, ModTime: testDate},
{Name: "file-0", Typeflag: tar.TypeReg, Size: 123456789, Mode: 0o600, ModTime: testDate},
{Name: "file-a", Typeflag: tar.TypeReg, Size: 23, Mode: 0o600, ModTime: testDate},
{Name: "file-b", Typeflag: tar.TypeReg, Size: 23, Mode: 0o600, ModTime: testDate},
{Name: "file-c", Typeflag: tar.TypeLink, Linkname: "file-a", Mode: 0o600, ModTime: testDate},
{Name: "file-u", Typeflag: tar.TypeReg, Size: 23, Mode: cISUID | 0o755, ModTime: testDate},
{Name: "file-g", Typeflag: tar.TypeReg, Size: 23, Mode: cISGID | 0o755, ModTime: testDate},
{Name: "file-t", Typeflag: tar.TypeReg, Size: 23, Mode: cISVTX | 0o755, ModTime: testDate},
{Name: "link-0", Typeflag: tar.TypeSymlink, Linkname: "../file-0", Size: 123456789, Mode: 0o777, ModTime: testDate},
{Name: "link-a", Typeflag: tar.TypeSymlink, Linkname: "file-a", Size: 23, Mode: 0o777, ModTime: testDate},
{Name: "link-b", Typeflag: tar.TypeSymlink, Linkname: "../file-a", Size: 23, Mode: 0o777, ModTime: testDate},
{Name: "hlink-0", Typeflag: tar.TypeLink, Linkname: "file-0", Size: 123456789, Mode: 0o600, ModTime: testDate},
{Name: "hlink-a", Typeflag: tar.TypeLink, Linkname: "/file-a", Size: 23, Mode: 0o600, ModTime: testDate},
{Name: "hlink-b", Typeflag: tar.TypeLink, Linkname: "../file-b", Size: 23, Mode: 0o600, ModTime: testDate},
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0o700, ModTime: testDate},
{Name: "subdir-a/file-n", Typeflag: tar.TypeReg, Size: 108, Mode: 0o660, ModTime: testDate},
{Name: "subdir-a/file-o", Typeflag: tar.TypeReg, Size: 34, Mode: 0o660, ModTime: testDate},
{Name: "subdir-a/file-a", Typeflag: tar.TypeSymlink, Linkname: "../file-a", Size: 23, Mode: 0o777, ModTime: testDate},
{Name: "subdir-a/file-b", Typeflag: tar.TypeSymlink, Linkname: "../../file-b", Size: 23, Mode: 0o777, ModTime: testDate},
{Name: "subdir-a/file-c", Typeflag: tar.TypeSymlink, Linkname: "/file-c", Size: 23, Mode: 0o777, ModTime: testDate},
{Name: "subdir-b", Typeflag: tar.TypeDir, Mode: 0o700, ModTime: testDate},
{Name: "subdir-b/file-n", Typeflag: tar.TypeReg, Size: 216, Mode: 0o660, ModTime: testDate},
{Name: "subdir-b/file-o", Typeflag: tar.TypeReg, Size: 45, Mode: 0o660, ModTime: testDate},
{Name: "subdir-c", Typeflag: tar.TypeDir, Mode: 0o700, ModTime: testDate},
{Name: "subdir-c/file-n", Typeflag: tar.TypeReg, Size: 432, Mode: 0o666, ModTime: testDate},
{Name: "subdir-c/file-o", Typeflag: tar.TypeReg, Size: 56, Mode: 0o666, ModTime: testDate},
{Name: "subdir-d", Typeflag: tar.TypeDir, Mode: 0o700, ModTime: testDate},
{Name: "subdir-d/hlink-0", Typeflag: tar.TypeLink, Linkname: "../file-0", Size: 123456789, Mode: 0o600, ModTime: testDate},
{Name: "subdir-d/hlink-a", Typeflag: tar.TypeLink, Linkname: "/file-a", Size: 23, Mode: 0o600, ModTime: testDate},
{Name: "subdir-d/hlink-b", Typeflag: tar.TypeLink, Linkname: "../../file-b", Size: 23, Mode: 0o600, ModTime: testDate},
{Name: "archive-a", Typeflag: tar.TypeReg, Size: 0, Mode: 0o600, ModTime: testDate},
{Name: "subdir-e", Typeflag: tar.TypeDir, Mode: 0o500, ModTime: testDate},
{Name: "subdir-e/file-p", Typeflag: tar.TypeReg, Size: 890, Mode: 0o600, ModTime: testDate},
},
contents: map[string][]byte{
"archive-a": testArchiveSlice,
@ -412,8 +414,8 @@ var (
name: "devices",
rootOnly: true,
headers: []tar.Header{
{Name: "char-dev", Typeflag: tar.TypeChar, Devmajor: 0, Devminor: 0, Mode: 0600, ModTime: testDate},
{Name: "blk-dev", Typeflag: tar.TypeBlock, Devmajor: 0, Devminor: 0, Mode: 0600, ModTime: testDate},
{Name: "char-dev", Typeflag: tar.TypeChar, Devmajor: 0, Devminor: 0, Mode: 0o600, ModTime: testDate},
{Name: "blk-dev", Typeflag: tar.TypeBlock, Devmajor: 0, Devminor: 0, Mode: 0o600, ModTime: testDate},
},
},
}
@ -505,7 +507,7 @@ func testPut(t *testing.T) {
require.NoErrorf(t, err, "error extracting archive %q to directory %q", testArchives[i].name, tmp)
var found []string
err = filepath.WalkDir(tmp, func(path string, d fs.DirEntry, err error) error {
err = filepath.WalkDir(tmp, func(path string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}
@ -534,13 +536,13 @@ func testPut(t *testing.T) {
for _, typeFlag := range []byte{tar.TypeReg, tar.TypeLink, tar.TypeSymlink, tar.TypeChar, tar.TypeBlock, tar.TypeFifo} {
t.Run(fmt.Sprintf("overwrite (dir)=%v,type=%c", overwrite, typeFlag), func(t *testing.T) {
archive := makeArchiveSlice([]tar.Header{
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeReg, Size: 123, Mode: 0755, ModTime: testDate},
{Name: "test", Typeflag: tar.TypeDir, Size: 0, Mode: 0755, ModTime: testDate},
{Name: "test/content", Typeflag: tar.TypeReg, Size: 0, Mode: 0755, ModTime: testDate},
{Name: "test", Typeflag: typeFlag, Size: 0, Mode: 0755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0o755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0o755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeReg, Size: 123, Mode: 0o755, ModTime: testDate},
{Name: "test", Typeflag: tar.TypeDir, Size: 0, Mode: 0o755, ModTime: testDate},
{Name: "test/content", Typeflag: tar.TypeReg, Size: 0, Mode: 0o755, ModTime: testDate},
{Name: "test", Typeflag: typeFlag, Size: 0, Mode: 0o755, Linkname: "target", ModTime: testDate},
})
tmp := t.TempDir()
err := Put(tmp, tmp, PutOptions{UIDMap: uidMap, GIDMap: gidMap, NoOverwriteDirNonDir: !overwrite}, bytes.NewReader(archive))
@ -560,13 +562,13 @@ func testPut(t *testing.T) {
for _, typeFlag := range []byte{tar.TypeReg, tar.TypeLink, tar.TypeSymlink, tar.TypeChar, tar.TypeBlock, tar.TypeFifo} {
t.Run(fmt.Sprintf("overwrite (non-dir)=%v,type=%c", overwrite, typeFlag), func(t *testing.T) {
archive := makeArchiveSlice([]tar.Header{
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeReg, Mode: 0755, ModTime: testDate},
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeReg, Size: 123, Mode: 0755, ModTime: testDate},
{Name: "test", Typeflag: typeFlag, Size: 0, Mode: 0755, Linkname: "target", ModTime: testDate},
{Name: "test", Typeflag: tar.TypeDir, Size: 0, Mode: 0755, ModTime: testDate},
{Name: "test/content", Typeflag: tar.TypeReg, Size: 0, Mode: 0755, ModTime: testDate},
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0o755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeReg, Mode: 0o755, ModTime: testDate},
{Name: "target", Typeflag: tar.TypeSymlink, Mode: 0o755, Linkname: "target", ModTime: testDate},
{Name: "target", Typeflag: tar.TypeReg, Size: 123, Mode: 0o755, ModTime: testDate},
{Name: "test", Typeflag: typeFlag, Size: 0, Mode: 0o755, Linkname: "target", ModTime: testDate},
{Name: "test", Typeflag: tar.TypeDir, Size: 0, Mode: 0o755, ModTime: testDate},
{Name: "test/content", Typeflag: tar.TypeReg, Size: 0, Mode: 0o755, ModTime: testDate},
})
tmp := t.TempDir()
err := Put(tmp, tmp, PutOptions{UIDMap: uidMap, GIDMap: gidMap, NoOverwriteNonDirDir: !overwrite}, bytes.NewReader(archive))
@ -587,9 +589,9 @@ func testPut(t *testing.T) {
t.Skip("can only test !IgnoreDevices with root privileges, skipping")
}
archive := makeArchiveSlice([]tar.Header{
{Name: "test", Typeflag: typeFlag, Size: 0, Mode: 0600, ModTime: testDate, Devmajor: 0, Devminor: 0},
{Name: "link", Typeflag: tar.TypeLink, Size: 0, Mode: 0600, ModTime: testDate, Linkname: "test"},
{Name: "unrelated", Typeflag: tar.TypeReg, Size: 0, Mode: 0600, ModTime: testDate},
{Name: "test", Typeflag: typeFlag, Size: 0, Mode: 0o600, ModTime: testDate, Devmajor: 0, Devminor: 0},
{Name: "link", Typeflag: tar.TypeLink, Size: 0, Mode: 0o600, ModTime: testDate, Linkname: "test"},
{Name: "unrelated", Typeflag: tar.TypeReg, Size: 0, Mode: 0o600, ModTime: testDate},
})
tmp := t.TempDir()
err := Put(tmp, tmp, PutOptions{UIDMap: uidMap, GIDMap: gidMap, IgnoreDevices: ignoreDevices}, bytes.NewReader(archive))
@ -888,8 +890,10 @@ func testGetMultiple(t *testing.T) {
keepDirectoryNames bool
renames map[string]string
noDerefSymlinks bool
parents bool
timestamp *time.Time
}
var getTestArchives = []struct {
getTestArchives := []struct {
name string
headers []tar.Header
contents map[string][]byte
@ -899,32 +903,32 @@ func testGetMultiple(t *testing.T) {
{
name: "regular",
headers: []tar.Header{
{Name: "file-0", Typeflag: tar.TypeReg, Size: 123456789, Mode: 0600},
{Name: "file-a", Typeflag: tar.TypeReg, Size: 23, Mode: 0600},
{Name: "file-b", Typeflag: tar.TypeReg, Size: 23, Mode: 0600},
{Name: "link-a", Typeflag: tar.TypeSymlink, Linkname: "file-a", Size: 23, Mode: 0600},
{Name: "link-c", Typeflag: tar.TypeSymlink, Linkname: "subdir-c", Mode: 0700, ModTime: testDate},
{Name: "archive-a", Typeflag: tar.TypeReg, Size: 0, Mode: 0600},
{Name: "non-archive-a", Typeflag: tar.TypeReg, Size: 1199, Mode: 0600},
{Name: "hlink-0", Typeflag: tar.TypeLink, Linkname: "file-0", Size: 123456789, Mode: 0600},
{Name: "something-a", Typeflag: tar.TypeReg, Size: 34, Mode: 0600},
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0700},
{Name: "subdir-a/file-n", Typeflag: tar.TypeReg, Size: 108, Mode: 0660},
{Name: "subdir-a/file-o", Typeflag: tar.TypeReg, Size: 45, Mode: 0660},
{Name: "subdir-a/file-a", Typeflag: tar.TypeSymlink, Linkname: "../file-a", Size: 23, Mode: 0600},
{Name: "subdir-a/file-b", Typeflag: tar.TypeSymlink, Linkname: "../../file-b", Size: 23, Mode: 0600},
{Name: "subdir-a/file-c", Typeflag: tar.TypeReg, Size: 56, Mode: 0600},
{Name: "subdir-b", Typeflag: tar.TypeDir, Mode: 0700},
{Name: "subdir-b/file-n", Typeflag: tar.TypeReg, Size: 216, Mode: 0660},
{Name: "subdir-b/file-o", Typeflag: tar.TypeReg, Size: 67, Mode: 0660},
{Name: "subdir-c", Typeflag: tar.TypeDir, Mode: 0700},
{Name: "subdir-c/file-p", Typeflag: tar.TypeReg, Size: 432, Mode: 0666},
{Name: "subdir-c/file-q", Typeflag: tar.TypeReg, Size: 78, Mode: 0666},
{Name: "subdir-d", Typeflag: tar.TypeDir, Mode: 0700},
{Name: "subdir-d/hlink-0", Typeflag: tar.TypeLink, Linkname: "../file-0", Size: 123456789, Mode: 0600},
{Name: "subdir-e", Typeflag: tar.TypeDir, Mode: 0700},
{Name: "subdir-e/subdir-f", Typeflag: tar.TypeDir, Mode: 0700},
{Name: "subdir-e/subdir-f/hlink-b", Typeflag: tar.TypeLink, Linkname: "../../file-b", Size: 23, Mode: 0600},
{Name: "file-0", Typeflag: tar.TypeReg, Size: 123456789, Mode: 0o600},
{Name: "file-a", Typeflag: tar.TypeReg, Size: 23, Mode: 0o600},
{Name: "file-b", Typeflag: tar.TypeReg, Size: 23, Mode: 0o600},
{Name: "link-a", Typeflag: tar.TypeSymlink, Linkname: "file-a", Size: 23, Mode: 0o600},
{Name: "link-c", Typeflag: tar.TypeSymlink, Linkname: "subdir-c", Mode: 0o700, ModTime: testDate},
{Name: "archive-a", Typeflag: tar.TypeReg, Size: 0, Mode: 0o600},
{Name: "non-archive-a", Typeflag: tar.TypeReg, Size: 1199, Mode: 0o600},
{Name: "hlink-0", Typeflag: tar.TypeLink, Linkname: "file-0", Size: 123456789, Mode: 0o600},
{Name: "something-a", Typeflag: tar.TypeReg, Size: 34, Mode: 0o600},
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0o700},
{Name: "subdir-a/file-n", Typeflag: tar.TypeReg, Size: 108, Mode: 0o660},
{Name: "subdir-a/file-o", Typeflag: tar.TypeReg, Size: 45, Mode: 0o660},
{Name: "subdir-a/file-a", Typeflag: tar.TypeSymlink, Linkname: "../file-a", Size: 23, Mode: 0o600},
{Name: "subdir-a/file-b", Typeflag: tar.TypeSymlink, Linkname: "../../file-b", Size: 23, Mode: 0o600},
{Name: "subdir-a/file-c", Typeflag: tar.TypeReg, Size: 56, Mode: 0o600},
{Name: "subdir-b", Typeflag: tar.TypeDir, Mode: 0o700},
{Name: "subdir-b/file-n", Typeflag: tar.TypeReg, Size: 216, Mode: 0o660},
{Name: "subdir-b/file-o", Typeflag: tar.TypeReg, Size: 67, Mode: 0o660},
{Name: "subdir-c", Typeflag: tar.TypeDir, Mode: 0o700},
{Name: "subdir-c/file-p", Typeflag: tar.TypeReg, Size: 432, Mode: 0o666},
{Name: "subdir-c/file-q", Typeflag: tar.TypeReg, Size: 78, Mode: 0o666},
{Name: "subdir-d", Typeflag: tar.TypeDir, Mode: 0o700},
{Name: "subdir-d/hlink-0", Typeflag: tar.TypeLink, Linkname: "../file-0", Size: 123456789, Mode: 0o600},
{Name: "subdir-e", Typeflag: tar.TypeDir, Mode: 0o700},
{Name: "subdir-e/subdir-f", Typeflag: tar.TypeDir, Mode: 0o700},
{Name: "subdir-e/subdir-f/hlink-b", Typeflag: tar.TypeLink, Linkname: "../../file-b", Size: 23, Mode: 0o600},
},
contents: map[string][]byte{
"archive-a": testArchiveSlice,
@ -995,6 +999,16 @@ func testGetMultiple(t *testing.T) {
"subdir-f/hlink-b", // from subdir-e
},
},
{
name: "timestamped",
pattern: "file*",
items: []string{
"file-0",
"file-a",
"file-b",
},
timestamp: &secondTestDate,
},
{
name: "dot-with-wildcard-includes-and-excludes",
pattern: ".",
@ -1364,6 +1378,124 @@ func testGetMultiple(t *testing.T) {
"file-q", // from link-c -> subdir-c
},
},
{
name: "wildcard and parents",
pattern: "*",
parents: true,
items: []string{
"file-0",
"file-a",
"file-b",
"link-a",
"hlink-0",
"something-a",
"archive-a",
"non-archive-a",
"subdir-a",
"subdir-b",
"subdir-c",
"subdir-d",
"subdir-e",
"subdir-a/file-n",
"subdir-a/file-o",
"subdir-a/file-a",
"subdir-a/file-b",
"subdir-a/file-c",
"subdir-b/file-n",
"subdir-b/file-o",
"subdir-c/file-p",
"subdir-c/file-p",
"subdir-c/file-q",
"subdir-c/file-q",
"subdir-d/hlink-0",
"subdir-e/subdir-f",
"subdir-e/subdir-f/hlink-b",
},
},
{
name: "everything-with-wildcard-includes-and-excludes-parents",
pattern: "*",
parents: true,
exclude: []string{"**/*-a", "!**/*-c"},
items: []string{
"file-0",
"file-b",
"subdir-a",
"subdir-b",
"subdir-c",
"subdir-d",
"subdir-e",
"subdir-a/file-c",
"subdir-b/file-n",
"subdir-b/file-o",
"subdir-c/file-p",
"subdir-c/file-p",
"subdir-c/file-q",
"subdir-c/file-q",
"hlink-0",
"subdir-d/hlink-0",
"subdir-e/subdir-f",
"subdir-e/subdir-f/hlink-b",
},
},
{
name: "file-and-dir-wildcard-parents",
pattern: "*-a",
parents: true,
items: []string{
"file-a",
"link-a",
"something-a",
"archive-a",
"non-archive-a",
"subdir-a",
"subdir-a/file-n",
"subdir-a/file-o",
"subdir-a/file-a",
"subdir-a/file-b",
"subdir-a/file-c",
},
},
{
name: "root-wildcard-parents",
pattern: "/subdir-b/*",
parents: true,
items: []string{
"subdir-b",
"subdir-b/file-n",
"subdir-b/file-o",
},
},
{
name: "dotdot-wildcard-parents",
pattern: "../../subdir-b/*",
parents: true,
items: []string{
"subdir-b",
"subdir-b/file-n",
"subdir-b/file-o",
},
},
{
name: "dir-with-parents",
pattern: "subdir-e/subdir-f",
parents: true,
items: []string{
"subdir-e",
"subdir-e/subdir-f",
"subdir-e/subdir-f/hlink-b",
},
},
{
name: "hlink-with-parents",
pattern: "subdir-e/subdir-f/hlink-b",
parents: true,
items: []string{
"subdir-e",
"subdir-e/subdir-f",
"subdir-e/subdir-f/hlink-b",
},
},
},
},
}
@ -1399,6 +1531,8 @@ func testGetMultiple(t *testing.T) {
KeepDirectoryNames: testCase.keepDirectoryNames,
Rename: testCase.renames,
NoDerefSymlinks: testCase.noDerefSymlinks,
Parents: testCase.parents,
Timestamp: testCase.timestamp,
}
t.Run(fmt.Sprintf("topdir=%s,archive=%s,case=%s,pattern=%s", topdir, testArchive.name, testCase.name, testCase.pattern), func(t *testing.T) {
@ -1414,15 +1548,18 @@ func testGetMultiple(t *testing.T) {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
getErr = Get(root, topdir, getOptions, []string{testCase.pattern}, pipeWriter)
pipeWriter.Close()
wg.Done()
}()
tr := tar.NewReader(pipeReader)
hdr, err := tr.Next()
actualContents := []string{}
for err == nil {
actualContents = append(actualContents, filepath.FromSlash(hdr.Name))
if testCase.timestamp != nil {
assert.Truef(t, testCase.timestamp.Equal(hdr.ModTime), "timestamp was supposed to be forced for %q", hdr.Name)
}
hdr, err = tr.Next()
}
pipeReader.Close()
@ -1518,9 +1655,9 @@ func testMkdir(t *testing.T) {
{
name: "regular",
headers: []tar.Header{
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-b", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-b", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-b/dangle1", Typeflag: tar.TypeSymlink, Linkname: "dangle1-target", ModTime: testDate},
{Name: "subdir-a/subdir-b/dangle2", Typeflag: tar.TypeSymlink, Linkname: "../dangle2-target", ModTime: testDate},
{Name: "subdir-a/subdir-b/dangle3", Typeflag: tar.TypeSymlink, Linkname: "../../dangle3-target", ModTime: testDate},
@ -1607,7 +1744,7 @@ func testMkdir(t *testing.T) {
root := dir
options := MkdirOptions{ChownNew: &idtools.IDPair{UID: os.Getuid(), GID: os.Getgid()}}
var beforeNames, afterNames []string
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}
@ -1621,7 +1758,7 @@ func testMkdir(t *testing.T) {
require.NoErrorf(t, err, "error walking directory to catalog pre-Mkdir contents: %v", err)
err = Mkdir(root, testCase.create, options)
require.NoErrorf(t, err, "error creating directory %q under %q with Mkdir: %v", testCase.create, root, err)
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}
@ -1633,7 +1770,7 @@ func testMkdir(t *testing.T) {
return nil
})
require.NoErrorf(t, err, "error walking directory to catalog post-Mkdir contents: %v", err)
expected := append([]string{}, beforeNames...)
expected := slices.Clone(beforeNames)
for _, expect := range testCase.expect {
expected = append(expected, filepath.FromSlash(expect))
}
@ -1713,17 +1850,17 @@ func testRemove(t *testing.T) {
{
name: "regular",
headers: []tar.Header{
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/file-a", Typeflag: tar.TypeReg, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/file-b", Typeflag: tar.TypeReg, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-b", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/file-a", Typeflag: tar.TypeReg, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/file-b", Typeflag: tar.TypeReg, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-b", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c/parent", Typeflag: tar.TypeSymlink, Linkname: "..", ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c/link-b", Typeflag: tar.TypeSymlink, Linkname: "../../file-b", ModTime: testDate},
{Name: "subdir-a/subdir-b/subdir-c/root", Typeflag: tar.TypeSymlink, Linkname: "/", ModTime: testDate},
{Name: "subdir-a/subdir-d", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-e", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-e/subdir-f", Typeflag: tar.TypeDir, Mode: 0755, ModTime: testDate},
{Name: "subdir-a/subdir-d", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-e", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
{Name: "subdir-a/subdir-e/subdir-f", Typeflag: tar.TypeDir, Mode: 0o755, ModTime: testDate},
},
testCases: []testCase{
{
@ -1822,7 +1959,7 @@ func testRemove(t *testing.T) {
root := dir
options := RemoveOptions{All: testCase.all}
beforeNames := make(map[string]struct{})
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}
@ -1841,7 +1978,7 @@ func testRemove(t *testing.T) {
}
require.NoErrorf(t, err, "error removing item %q under %q with Remove: %v", testCase.remove, root, err)
afterNames := make(map[string]struct{})
err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
err = filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}
@ -1871,3 +2008,351 @@ func testRemove(t *testing.T) {
})
}
}
func TestExtendedGlob(t *testing.T) {
tmpdir := t.TempDir()
buf := []byte("buffer")
var expected1, expected2 []string
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "a"), 0o700))
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "a", "b"), 0o700))
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "a", "b", "a.dat"), buf, 0o600))
expected1 = append(expected1, filepath.Join(tmpdir, "a", "b", "a.dat"))
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "b"), 0o700))
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "b", "c"), 0o700))
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "c"), 0o700))
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "c", "d"), 0o700))
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "c", "d", "c.dat"), buf, 0o600))
expected1 = append(expected1, filepath.Join(tmpdir, "c", "d", "c.dat"))
expected2 = append(expected2, filepath.Join(tmpdir, "c", "d", "c.dat"))
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, "d"), 0o700))
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "d", "d.dat"), buf, 0o600))
expected1 = append(expected1, filepath.Join(tmpdir, "d", "d.dat"))
expected2 = append(expected2, filepath.Join(tmpdir, "d", "d.dat"))
matched, err := extendedGlob(filepath.Join(tmpdir, "**", "*.dat"))
require.NoError(t, err, "globbing")
require.ElementsMatchf(t, expected1, matched, "**/*.dat")
matched, err = extendedGlob(filepath.Join(tmpdir, "**", "d", "*.dat"))
require.NoError(t, err, "globbing")
require.ElementsMatch(t, expected2, matched, "**/d/*.dat")
matched, err = extendedGlob(filepath.Join(tmpdir, "**", "**", "d", "*.dat"))
require.NoError(t, err, "globbing")
require.ElementsMatch(t, expected2, matched, "**/**/d/*.dat")
matched, err = extendedGlob(filepath.Join(tmpdir, "**", "d", "**", "*.dat"))
require.NoError(t, err, "globbing")
require.ElementsMatch(t, expected2, matched, "**/d/**/*.dat")
}
func testEnsure(t *testing.T) {
zero := time.Unix(0, 0)
worldReadable := os.FileMode(0o644)
testCases := []struct {
description string
subdir string
options EnsureOptions
expected []string
}{
{
description: "base",
subdir: "subdir",
options: EnsureOptions{
Paths: []EnsurePath{
{
Path: filepath.Join(string(os.PathSeparator), "a", "b", "a"),
Typeflag: tar.TypeReg,
Chmod: &worldReadable,
},
{
Path: filepath.Join("a", "b", "b"),
Typeflag: tar.TypeReg,
ModTime: &zero,
},
{
Path: filepath.Join(string(os.PathSeparator), "a", "b", "c"),
Typeflag: tar.TypeDir,
ModTime: &zero,
},
{
Path: filepath.Join("a", "b", "d"),
Typeflag: tar.TypeDir,
},
},
},
expected: []string{
"subdir",
"subdir/a",
"subdir/a/b",
"subdir/a/b/a",
"subdir/a/b/b",
"subdir/a/b/c",
"subdir/a/b/d",
},
},
{
description: "nosubdir",
options: EnsureOptions{
Paths: []EnsurePath{
{
Path: filepath.Join(string(os.PathSeparator), "a", "b", "c"),
Typeflag: tar.TypeDir,
ModTime: &zero,
},
{
Path: filepath.Join("a", "b", "d"),
Typeflag: tar.TypeDir,
},
},
},
expected: []string{
"a",
"a/b",
"a/b/c",
"a/b/d",
},
},
}
for i := range testCases {
t.Run(testCases[i].description, func(t *testing.T) {
testStarted := time.Now()
tmpdir := t.TempDir()
created, err := Ensure(tmpdir, testCases[i].subdir, testCases[i].options)
require.NoError(t, err, "unexpected error ensuring")
require.EqualValues(t, testCases[i].expected, created, "did not expect these")
for _, item := range testCases[i].options.Paths {
target := filepath.Join(tmpdir, testCases[i].subdir, item.Path)
st, err := os.Stat(target)
require.NoError(t, err, "we supposedly created %q", item.Path)
if item.Chmod != nil {
assert.Equalf(t, *item.Chmod, st.Mode().Perm(), "permissions look wrong on %q", item.Path)
}
if item.Chown != nil {
uid, gid, err := owner(st)
require.NoErrorf(t, err, "expected to be able to read uid:gid for %q", item.Path)
assert.Equalf(t, item.Chown.UID, uid, "user looks wrong on %q", item.Path)
assert.Equalf(t, item.Chown.GID, gid, "group looks wrong on %q", item.Path)
}
if item.ModTime != nil {
assert.Equalf(t, item.ModTime.Unix(), st.ModTime().Unix(), "datestamp looks wrong on %q", item.Path)
} else {
assert.True(t, !testStarted.After(st.ModTime()), "datestamp is too old on %q: %v < %v", st.ModTime(), testStarted)
}
}
})
}
}
func TestEnsureNoChroot(t *testing.T) {
couldChroot := canChroot
canChroot = false
testEnsure(t)
canChroot = couldChroot
}
func testConditionalRemove(t *testing.T) {
mode, mismatchedMode := os.FileMode(0o751), os.FileMode(0o755)
now := time.Now()
then := time.Unix(now.Unix()/2, 0)
type create struct {
path string
typeFlag byte
mtime *time.Time
mode *os.FileMode
}
testCases := []struct {
description string
subdir string
create []create
remove ConditionalRemoveOptions
expectedRemoved []string
expectedRemain []string
}{
{
description: "withoutsubdir",
create: []create{
{path: "/a", typeFlag: tar.TypeDir},
{path: "b", typeFlag: tar.TypeReg},
{path: "c/d", typeFlag: tar.TypeReg},
{path: "c/e", typeFlag: tar.TypeReg},
},
remove: ConditionalRemoveOptions{
Paths: []ConditionalRemovePath{
{Path: "a"},
{Path: "b"},
{Path: "c"},
{Path: "c/e"},
},
},
expectedRemoved: []string{"a", "b", "c/e"},
expectedRemain: []string{"c/d", "c"},
},
{
description: "withsubdir",
subdir: "subdir",
create: []create{
{path: "/a", typeFlag: tar.TypeDir},
{path: "b", typeFlag: tar.TypeReg},
{path: "c/d", typeFlag: tar.TypeReg},
{path: "c/e", typeFlag: tar.TypeReg},
},
remove: ConditionalRemoveOptions{
Paths: []ConditionalRemovePath{
{Path: "a"},
{Path: "b"},
{Path: "c"},
{Path: "c/e"},
},
},
expectedRemoved: []string{"a", "b", "c/e"},
expectedRemain: []string{"c/d", "c"},
},
{
description: "withsubdir",
subdir: "subdir",
create: []create{
{path: "/a", typeFlag: tar.TypeDir},
{path: "b", typeFlag: tar.TypeReg},
{path: "c/d", typeFlag: tar.TypeReg},
{path: "c/e", typeFlag: tar.TypeReg},
},
remove: ConditionalRemoveOptions{
Paths: []ConditionalRemovePath{
{Path: "a"},
{Path: "b"},
{Path: "c"},
{Path: "c/e"},
},
},
expectedRemoved: []string{"a", "b", "c/e"},
expectedRemain: []string{"c/d", "c"},
},
{
description: "unconditional",
create: []create{
{path: "/a", typeFlag: tar.TypeDir, mtime: &then, mode: &mode},
{path: "b", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
{path: "c/d", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
{path: "c/e", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
},
remove: ConditionalRemoveOptions{
Paths: []ConditionalRemovePath{
{Path: "a"},
{Path: "b"},
{Path: "c"},
{Path: "c/e"},
},
},
expectedRemoved: []string{"a", "b", "c/e"},
expectedRemain: []string{"c/d", "c"},
},
{
description: "conditions-not-met",
create: []create{
{path: "/a", typeFlag: tar.TypeDir, mtime: &then, mode: &mode},
{path: "b", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
{path: "c/d", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
{path: "c/e", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
},
remove: ConditionalRemoveOptions{
Paths: []ConditionalRemovePath{
{Path: "a", Mode: &mismatchedMode},
{Path: "b", Mode: &mismatchedMode},
{Path: "c", Mode: &mismatchedMode},
{Path: "c/e", Mode: &mismatchedMode},
{Path: "a", ModTime: &now},
{Path: "b", ModTime: &now},
{Path: "c", ModTime: &now},
{Path: "c/e", ModTime: &now},
},
},
expectedRemain: []string{"a", "b", "c/e", "c/d", "c"},
},
{
description: "conditions-met",
create: []create{
{path: "/a", typeFlag: tar.TypeDir, mtime: &then, mode: &mode},
{path: "b", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
{path: "c/d", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
{path: "c/e", typeFlag: tar.TypeReg, mtime: &then, mode: &mode},
},
remove: ConditionalRemoveOptions{
Paths: []ConditionalRemovePath{
{Path: "a", ModTime: &then, Mode: &mode},
{Path: "b", ModTime: &then, Mode: &mode},
{Path: "c"},
{Path: "c/d", ModTime: &then, Mode: &mode},
},
},
expectedRemoved: []string{"a", "b", "c/d"},
expectedRemain: []string{"c", "c/e"},
},
}
for i := range testCases {
t.Run(testCases[i].description, func(t *testing.T) {
tmpdir := t.TempDir()
var create EnsureOptions
for _, what := range testCases[i].create {
create.Paths = append(create.Paths, EnsurePath{
Path: what.path,
Typeflag: what.typeFlag,
ModTime: what.mtime,
Chmod: what.mode,
})
}
created, err := Ensure(tmpdir, testCases[i].subdir, create)
require.NoErrorf(t, err, "unexpected error creating %#v", create)
remove := testCases[i].remove
for _, what := range created {
remove.Paths = append(remove.Paths, ConditionalRemovePath{
Path: what,
})
}
removed, err := ConditionalRemove(tmpdir, testCases[i].subdir, testCases[i].remove)
require.NoError(t, err, "unexpected error removing")
expectedRemoved := slices.Clone(testCases[i].expectedRemoved)
slices.Sort(expectedRemoved)
require.EqualValues(t, expectedRemoved, removed, "did not expect these to be removed")
var remain []string
err = filepath.Walk(filepath.Join(tmpdir, testCases[i].subdir), func(path string, _ fs.FileInfo, err error) error {
if err != nil {
return err
}
rel, err := filepath.Rel(filepath.Join(tmpdir, testCases[i].subdir), path)
if err != nil {
return fmt.Errorf("computing path of %q relative to %q: %w", path, filepath.Join(tmpdir, testCases[i].subdir), err)
}
if rel != "" && rel == "." {
return nil
}
remain = append(remain, rel)
return nil
})
slices.Sort(remain)
expectedRemain := slices.Clone(testCases[i].expectedRemain)
slices.Sort(expectedRemain)
require.NoError(t, err, "unexpected error checking what's left")
require.EqualValues(t, expectedRemain, remain, "did not expect these to be left behind")
})
}
}
func TestConditionalRemoveNoChroot(t *testing.T) {
couldChroot := canChroot
canChroot = false
testConditionalRemove(t)
canChroot = couldChroot
}
func TestSortedExtendedGlob(t *testing.T) {
tmpdir := t.TempDir()
buf := []byte("buffer")
expect := []string{}
for _, name := range []string{"z", "y", "x", "a", "b", "c", "d", "e", "f"} {
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, name), buf, 0o600))
expect = append(expect, filepath.Join(tmpdir, name))
}
sort.Strings(expect)
matched, err := extendedGlob(filepath.Join(tmpdir, "*"))
require.NoError(t, err, "globbing")
require.ElementsMatch(t, expect, matched, "sorted globbing")
}

View File

@ -1,11 +1,17 @@
// +build !windows
//go:build !windows
package copier
import (
"os"
"testing"
)
const (
testModeMask = int64(os.ModePerm)
testIgnoreSymlinkDates = false
)
func TestPutChroot(t *testing.T) {
if uid != 0 {
t.Skip("chroot() requires root privileges, skipping")
@ -75,3 +81,23 @@ func TestRemoveChroot(t *testing.T) {
testRemove(t)
canChroot = couldChroot
}
func TestEnsureChroot(t *testing.T) {
if uid != 0 {
t.Skip("chroot() requires root privileges, skipping")
}
couldChroot := canChroot
canChroot = true
testEnsure(t)
canChroot = couldChroot
}
func TestConditionalRemoveChroot(t *testing.T) {
if uid != 0 {
t.Skip("chroot() requires root privileges, skipping")
}
couldChroot := canChroot
canChroot = true
testConditionalRemove(t)
canChroot = couldChroot
}

View File

@ -0,0 +1,8 @@
//go:build windows
package copier
const (
testModeMask = int64(0o600)
testIgnoreSymlinkDates = true
)

View File

@ -1,5 +1,4 @@
//go:build darwin || (linux && mips) || (linux && mipsle) || (linux && mips64) || (linux && mips64le)
// +build darwin linux,mips linux,mipsle linux,mips64 linux,mips64le
package copier

View File

@ -1,5 +1,4 @@
//go:build (linux && !mips && !mipsle && !mips64 && !mips64le) || freebsd
// +build linux,!mips,!mipsle,!mips64,!mips64le freebsd
//go:build (linux && !mips && !mipsle && !mips64 && !mips64le) || freebsd || netbsd
package copier

View File

@ -1,5 +1,4 @@
//go:build linux || darwin || freebsd
// +build linux darwin freebsd
//go:build !windows
package copier
@ -25,6 +24,7 @@ func (h *hardlinkChecker) Check(fi os.FileInfo) string {
}
return ""
}
func (h *hardlinkChecker) Add(fi os.FileInfo, name string) {
if st, ok := fi.Sys().(*syscall.Stat_t); ok && fi.Mode().IsRegular() && st.Nlink > 1 {
h.hardlinks.Store(makeHardlinkDeviceAndInode(st), name)

View File

@ -1,5 +1,4 @@
//go:build !linux && !darwin
// +build !linux,!darwin
package copier
@ -7,11 +6,11 @@ import (
"os"
)
type hardlinkChecker struct {
}
type hardlinkChecker struct{}
func (h *hardlinkChecker) Check(fi os.FileInfo) string {
return ""
}
func (h *hardlinkChecker) Add(fi os.FileInfo, name string) {
}

Some files were not shown because too many files have changed in this diff Show More