1
0
mirror of https://github.com/containers/image.git synced 2025-04-18 19:44:05 +03:00

39 Commits

Author SHA1 Message Date
Miloslav Trmač
8dabf442db Remove obsolete build tag syntax
per (go fix ./...).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-03-12 20:20:16 +01:00
Miloslav Trmač
cebe64776a Quote various strings coming from untrusted sources
Typically, use %q instead of %s (or instead of "%s"), to expose
various control characters and the like without interpreting them.

This is not really comprehensive; the codebase makes no _general_
guarantee that any returned string values are free of control
characters or other malicious/misleading metadata. Not even
in returned "error" values (which can legitimately contain newlines,
if nothing else).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-05-09 19:22:23 +02:00
Miloslav Trmač
3591919b74 Reorganize alltransports imports a bit
- Separate the code imports from transport-registration imports
- Improve the comment about updating documentation
- Add a missing comment about docker-daemon
- Sort transports, and transport comments alphabetically.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-07-19 20:25:45 +02:00
Miloslav Trmač
f43fe85e9e Remove duplicate words in comments
golangci-lint linter: dupword

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-06 21:22:09 +01:00
Miloslav Trmač
7797bbcafb Add internal/set, use it
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 18:33:53 +01:00
Miloslav Trmač
546a218a9c Use strings.Cut instead of strings.SplitN
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 18:33:20 +01:00
Miloslav Trmač
6accca5e04 Remove uses of errors.Errorf
This means we won't save the stack, which is cheaper
(and possibly might break callers' format strings that
want to print the stack, but we never promised the stack
to be available).

Use either fmt.Errorf, or errors.New (usually as a local
edit, not carring about errors.new vs. pkg/errors.New;
that's going to be cleaned up later).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-30 21:45:07 +02:00
Miloslav Trmač
71dfda12c9 Allow building the SIF transport on non-Linux systems
It probabaly doesn't _work_ right now, at least macOS is
missing a working fakeroot. We do intend to avoid the use of
fakeroot eventually.

(Adventurous experimenting developers might provide a no-op
"fakeroot" script on most platforms.)

Also, having the code compile on macOS significantly helps
development.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-01-12 23:51:01 +01:00
Miloslav Trmač
67c18a6477 Update build directives
> gofmt -s -w .

fixes build.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-01-12 23:29:45 +01:00
Yannick Cote
1757663cc4 sif: limit platform to linux
Signed-off-by: Yannick Cote <ycote@redhat.com>
2022-01-12 23:29:45 +01:00
Yannick Cote
13f7888b59 sif: initial sif transport implementation
Signed-off-by: Yannick Cote <ycote@redhat.com>
2022-01-12 23:29:45 +01:00
Miloslav Trmač
1e7020d1d7 Run (gofmt -s -w)
Go 1.17 introduces a much more reasonable build constraint format,
and gofmt now fails without using it.

Sadly we still need the old format _as well_, to support <1.17 builds.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-08-21 05:29:39 +02:00
Miloslav Trmač
7d9cde7252 Update to major version v5
> gomove github.com/containers/image/v4 github.com/containers/image/v5
+ a manual edit of go.mod

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-25 22:27:45 +02:00
Miloslav Trmač
e568c94ef3 Correctly use a c/image/v4 module namespace
... so that major-version-aware Go module import
(as opposed to vX.Y.Z+incompatible, which does not allow different
packages to use different versions) works right.

Also requires adding some more GO111MODULE=on options to Makefile.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-03 22:54:27 +02:00
W. Trevor King
8ed6527e91
*: Fix policy.json.md -> containers-policy.json.5.md references
Catching up with be91505 (docs: rename manpages to *.5.md, 2019-03-01, #594).

Generated with:

  $ sed -i 's/policy.json.md/containers-policy.json.5.md/g' $(git grep -l policy.json.md)

Looking to carry this over the finish line for Wking.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-21 04:02:18 -04:00
Silvano Cirujano Cuesta
9b902d0a70 use 'containers_image_ostree' as build tag
Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
2019-07-11 20:39:11 +02:00
Silvano Cirujano Cuesta
b46ef148a5 ostree: default is no OStree support
Since only Skopeo uses the OStree transport for fetching images from
OStree repositories, making default no support for OStree. It
simplifies building on other components like libpod and buildah.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
2019-07-11 20:39:11 +02:00
Tristan Cacqueray
2d92e2533d Add TransportFromImageName procedure
This change adds a new alltransports.TransportFromImageName procedure
to get the transport's name of an image without parsing the store
reference.

Signed-off-by: Tristan Cacqueray <tdecacqu@redhat.com>
2019-05-18 01:17:31 +00:00
Nalin Dahyabhai
1a08fe2e47 Make the docker-daemon transport stubbable
Make the docker-daemon transport something that can be stubbed out by
supplying the "containers_image_docker_daemon_stub" build tag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-07-23 12:59:22 -04:00
Vincent Batts
dedd21660c
alltransports: ostree is linux only
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2018-02-27 17:05:55 -05:00
Nalin Dahyabhai
a2d99a4f7d Stub out the right transport name for storage
We never did rename the containers-storage: transport, but the stub
thought that we had.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-11-03 16:25:53 -04:00
Nalin Dahyabhai
32b40fc540 Add a "tarball" transport for importing tarballs
Add a "tarball" transport which can be used to import tarballs of root
filesystem as images by treating each tarball as a single layer,
supplying a default OCI configuration (or one passed to the image from
which the ImageSource or Image was initialized), and generating an OCI
manifest to describe it all.

A tarball named "-" is buffered in memory using the contents of stdin.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-11-02 09:58:05 -04:00
Hardy Ferentschik
c8c830f886 Issue #361 Making storage transport pluggable
Signed-off-by: Hardy Ferentschik <hardy@hibernate.org>
2017-10-31 17:50:03 +01:00
umohnani8
1bac6726d6 Add oci-archive transport that creates a tar archive of an image
Signed-off-by: umohnani8 <umohnani@redhat.com>
2017-08-31 14:27:01 -04:00
umohnani8
4eb8db31f0 Fix oci to save the full image name
Fix oci to save the full image name "image:tag" instead of just the tag in index.json.
Add function to retrieve the image name from index.json when loading or pulling image from oci directory.

Signed-off-by: umohnani8 <umohnani@redhat.com>
2017-08-31 09:45:24 -04:00
Daniel J Walsh
c21049eb0e Deprecate atomic transport
We don't want transports/ListNames to return deprecated
transports, since we don't want to present them to the
users.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-08-02 13:48:53 +00:00
Miloslav Trmač
c5e371bcc8 Add a containers_image_ostree_stub build tag to make the libostree dependency optional
If this tag is defined, transports/alltransports registers a stub
instead of the real package.

Also updates README, adding the ostree-devel dependency to the dnf
command and restructuring it to have a list of build tags.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2017-06-19 16:48:36 +02:00
Miloslav Trmač
5d6fbfcbc8 Add transports/StubTransport
This is useful primarily so that we can use build tags to remove transports
from transports/alltransports, while giving users more hints about what
to do instead of a bland “unknown transport”.

Tests can also use this instead of their own mocks.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2017-06-19 16:30:58 +02:00
Daniel J Walsh
cd150088f2 Interface to return list of transport names
This interface can be used by callers in their Usage statements, to
guide users to all potential transports.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-06-16 20:50:36 +00:00
Giuseppe Scrivano
740cc0e309 ostree: new transport
skopeo copy docker://busybox ostree:foo:latest@/ostree/repo

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2017-04-20 23:17:10 +02:00
Aleksa Sarai
996e2d0936
docker: add docker-archive transport
This archive allows you to export a docker-load-friendly archive without
needing a Docker daemon to facilitate the exporting. Effectively this is
just an on-disk version of the docker-daemon transport (they both use
docker/tarfile).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-04-08 18:51:36 +10:00
Antonio Murdaca
29da2bc6d1
*: pluggable transports
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-03-02 12:25:17 +01:00
George Lestaris
bda6e4b37f Replace fmt.Errorf with pkg/errors.Wrap
Signed-off-by: George Lestaris <glestaris@pivotal.io>
2016-12-19 14:13:16 +00:00
Nalin Dahyabhai
346966324a Add support for containers/storage
Add containers/storage as a backend type called 'storage'.

The image's blobs are stored either as storage layers (if they look like
archived layers) or (alongside the manifest and signatures) as named big
data items associated with the image.

Inspection data and record-keeping (so that we can remember which blobs
were layers and which weren't) are encoded as a JSON object which is
stored in the storage image's metadata field.

When importing blobs, layer IDs are generated by concatenating the
parent's layer ID (if there is one) with the hex string representation
of the expected digest of the content blob, if one is known.  If there
is no expected digest, the ID is randomly generated.

If we find ourselves importing a layer with the same ID as a layer that
we already have, we digest the incoming stream and compare it to the
cached digest of the already-present layer, and return an error only if
they don't match.  If an expected blob digest is provided, the actual
digest of the blob is compared with it, and if they don't match, an
error is returned.

If we find ourselves importing a blob more than once, we track the IDs
of each of the resulting layers.

If we find ourselves importing an image that wants to be tagged with a
name that is already in use, the name is then assigned to the new image
and the old image remains otherwise unmodified.  If that incoming image
claims to have the same ID as an image which we already have, the import
will fail.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-12-13 12:19:39 -05:00
Miloslav Trmač
d742d1caa4 Finish daemonReference
Allow either a !NameOnly named reference, or a sha256:hex digest.  Both
forms can be used for an ImageSource; ImageDestination accepts only a
name:tag value.

Because the sha256:hex reference values make it impossible to create
a reasonable policy hierarchy, only support a trivial namespace with
a single per-transport policy.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2016-11-22 19:12:22 +01:00
Miloslav Trmač
33feb34580
Add docker-daemon ImageTransport
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-10-21 16:37:27 +02:00
Miloslav Trmač
dd0bf87c52 Add documentation for the signature verification policy files
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2016-10-11 19:06:28 +02:00
Antonio Murdaca
c775912f8c
oci: mv to oci-layout
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-09-07 18:33:27 +02:00
Miloslav Trmač
f30e521673 Add containers/image/transports subpackage
This package maintains the list of all known transports, and provides
helpers to convert between strings and types.ImageReference ; this
should be the primary entrypoint for callers who want to just provide an
UI without dealing with the underlying ImageReference structures or
specific transports.

This makes the skopeo/cmd/skopeo/utils.go transport:transport-specific
string format a containers/image -defined feature.

This would fit nicely into containers/image/image, but the individual
transports depend on that package for creating a types.Image instance,
so we would have a circular dependency.  And containers/image/signature
will need to depend on the list of transports maintained by this, so
maintaining it at the top containers/image level would be a bad fit as
well.

So, sadly, another small subpackage.

Though perhaps it should be called /reference instead of /transports?
Either way, one half of the API will feel a bit off.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2016-07-16 05:08:38 +02:00