Commit Graph

12 Commits

Author SHA1 Message Date
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
Philip Dubé 53c65dd360 Replace strings.SplitN with strings.Cut
Introduced in go 1.18: https://github.com/golang/go/issues/46336

[NO NEW TESTS NEEDED]

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-02 17:15:12 +00:00
Miloslav Trmač 62d4057718 Add a missing .Close() call on an ImageSource
[NO NEW TESTS NEEDED]

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-31 23:57:38 +02:00
Miloslav Trmač e588986fa6 Create only a reference when that's all we need
Don't create an ImageDestination only to call .Reference() on it. copy.Image
manages its own ImageSource/ImageDestination instances.

- On the pull path, this causes two ImageDestination objects to exist concurrently
  for the same directory. That's not really expected to work (because the implementation
  caches a modified top-level index in memory); luckily it currently doesn't matter
  because we don't make any writes through the manually-managed object, but it's
  a risk for future changes.
- On the push path, this creates a local object when the thing to push just doesn't exist.

Note that the code calls the input "sourcePath" but it can contain a tag, and that
seems to be intentional.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-31 23:57:38 +02:00
Miloslav Trmač fe947ed9cc Add a missing .Close() call on an ImageDestination
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-31 23:57:38 +02:00
Chris Evich 46eea31588
Replace io/ioutil calls with os calls
In golang 1.19, `io/ioutil` is fully deprecated preventing Buildah from
compiling.  Replace all calls with equivalent calls from the `os`
package.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-12-06 14:29:32 -05:00
Daniel J Walsh 8d5d763213
Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-19 07:11:44 -04:00
Sascha Grunert ce384684c0
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 11:41:47 +02:00
Daniel J Walsh 0986de4036
Fix codespell errors
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-05-25 05:51:47 -04:00
Valentin Rothberg 73e0ad7129 buildah source pull/push: show progress bar
Render the progress bar on stdout by default.  Add a --quiet/-q option
to re-silence if desired.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-17 14:00:28 +02:00
Nalin Dahyabhai 785b3bf30a image: set MediaType in OCI manifests
In image-spec 1.0.2, the MediaType field is now available in OCI
manifests, so set it.

Update the imgtype helper to output the MediaType field as-is from OCI
image manifests instead of just always supplying the expected value.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-11-29 20:04:09 -05:00
Valentin Rothberg 8696bfc7ad buildah source - create and manage source images
Add new `buildah source {create,add,push,pull}` commands.  All commands
are marked as experimental.  None of it is meant to be officially
supported at the time of writing.  All code resides in `internal/source`
and is hence not visible to external consumers of Buildah; just to be
on the safe side.

A source container or source image is an OCI artifact, that is an OCI
image with custom config (media type).  There is a longer history behind
source images which are intended to ship the source artifacts of an
ordinary "executable" container image.  Until now, source images at
Red Hat are built with github.com/containers/BuildSourceImage.  We had a
growing desire (and always the long-term plan) to eventually replace
BuildSurceImage with something else, in this case Buildah.

This commit adds the initial base functionality along with tests to make
sure we're not regressing.  The new commands do the following:

* `create` - creates an empty and initialized source image
* `add` - tar up a local path and add it as a layer to the souce image
* `push/pull` - intentionally separate commands from `buildah push/pull`
                to allow for an easier usage and prevent the
                implementations from undesired (future) interference

Further note: also vendor in c/image@master which ships a required fix.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-13 13:48:48 +02:00