Commit Graph

342 Commits

Author SHA1 Message Date
Matthieu MOREL
381d9d0723 fix use-errors-new from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Matthieu MOREL
6d737371b8 fix comparison rule from errorlint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-13 08:26:56 +00:00
Matthieu MOREL
20b6075380 fix badCall from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-08 09:02:11 +02:00
Sebastiaan van Stijn
7eecd04c7b image: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:13 +02:00
Matthieu MOREL
a1a789dbd0 image: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:39:34 +00:00
Sebastiaan van Stijn
114b8a4fa9 Remove unused image/v1 code
This image format is only used for docker save / docker load.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 18:00:06 +02:00
Sebastiaan van Stijn
57b27f2e9e image: use t.TempDir and rename vars that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 14:35:24 +02:00
Matthieu MOREL
f770f6c5ec fix(QF1012): Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:17:58 +02:00
Sebastiaan van Stijn
fd550344b1 vendor: github.com/moby/go-archive v0.1.0
full diff: https://github.com/moby/go-archive/compare/21f3f3385ab7...v0.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-16 13:00:13 +02:00
Derek McGowan
d0154d3e59 Update to use github.com/moby/go-archive
Update use of idtools to moby/user for archive and other deprecated uses

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 17:35:05 -07:00
Sebastiaan van Stijn
6422ff2804 deprecate pkg/atomicwriter, migrate to github.com/moby/sys/atomicwriter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 23:07:00 +02:00
Sebastiaan van Stijn
4aecdd5744 image/tarexport: fix naked returns and slight refactor
image/tarexport/load.go:429:2: naked return in func `validatedParentLinks` with 12 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:15 +01:00
Sebastiaan van Stijn
86a8bfdce4 remove redundant uses of api/types/strslice.StrSlice
The only real purpose of strslice.StrSlice is to provide a custom
json.Unmarshaler implementation for API responses. For all other purposes,
it's a regular string-slice.

This patch removes uses of this type in cases where the custom json.Unmarshaler
is irrelevant; in most cases this was in tests, where results were tested
using "DeepEquals"; for those tests, the type-assertion did not add real
value, so we can cast the values to a []string instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 18:46:48 +01:00
Derek McGowan
0aa8fe0bf9 Update to containerd v2.0.2, buildkit v0.19.0-rc2
Update buildkit version to commit which uses 2.0

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-15 14:09:30 +01:00
Sebastiaan van Stijn
bda51fe476 Merge pull request #48611 from stevvooe/sjd/stable-save-timestamps
image/save: set a stable timestamp for assets
2025-01-08 19:34:06 +01:00
Sebastiaan van Stijn
50212d215b Merge pull request #49014 from thaJeztah/eventlog_context
daemon: ImageService.LogImageEvent: pass through context
2025-01-08 17:53:00 +01:00
Stephen Day
392d33c98c image/save: set a stable timestamp for assets
When saving a docker image with `docker save`, output may have the
current timestamp, resulting in slightly changed content each time the
`save` command gets run. This patch attemtps to stabilize that effort to
clean up some spots where we've missed setting the timestamps.

It's not totally clear that setting these timestamps to 0 is the correct
behavior but it will fix the hash stability problem on output.

Signed-off-by: Stephen Day <stephen.day@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 17:49:25 +01:00
Sebastiaan van Stijn
e324df3f1b image/tarexport: patch MkDirall to accept atime, mtime
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 17:48:29 +01:00
Sebastiaan van Stijn
ca962cecfd image/tarexport: add fork of os.MkdirAll (non-buildable commit)
Fork the os.MkdirAll function, so that we can make changes to add support
for setting atime and mtime. This commit contains a 1:1 fork, but won't
build; code is taken from:
https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/os/path.go;l=19-66

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 17:24:42 +01:00
Sebastiaan van Stijn
ee1a15a970 daemon: ImageService.LogImageEvent: pass through context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 15:43:17 +01:00
Sebastiaan van Stijn
7864454792 pkg/ioutils: move atomic file-writers to a separate (pkg/atomicwriter) package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 10:36:32 +01:00
Paweł Gronowski
90fef061ec daemon/c8d: Force c8dimages alias for containerd/images
Change all github.com/containerd/containerd/images imports to be
imported as `c8dimages`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 18:39:43 +01:00
Paweł Gronowski
c452af6651 image: Remove unused Details fields
Last usage of these fields was removed by cd11843df8.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 12:14:24 +01:00
Paweł Gronowski
d9795da33e image: Remove GetImageManifest
Its only usage was in container creation, which also called `GetImage`
first.
This method is specific to the containerd image service and is largely
the same as `GetImage`, except it returns a manifest descriptor.
Instead, introduce add the descriptor as a new field in `Image.Details`
and set it in the containerd image service implementation of `GetImage`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 12:14:22 +01:00
Sebastiaan van Stijn
88e24ccda6 image/cache: remove redundant capturing of loop vars (copyloopvar)
image/cache/compare_test.go:195:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:12 +01:00
Sebastiaan van Stijn
b6398f1d4c Merge pull request #48460 from thaJeztah/remove_deprecated_image_spec
remove deprecated image/spec package
2024-09-16 14:43:29 +02:00
Sebastiaan van Stijn
2936af4c02 Merge pull request #48295 from vvoland/c8d-saveload-platform
c8d: Add `platform` parameter to history, save and load
2024-09-12 18:52:49 +02:00
Paweł Gronowski
521fa833fe images: Support platform selection on graphdrivers
Allows load to filter image manifests to load based on their platform.
For save, verify that the image platform matches the requested platform,
otherwise error out.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 19:44:36 +02:00
Sebastiaan van Stijn
7263cd226f image/tarexport: saveSession.save: inline variables
Remove some intermediate variables that were only used in a single place.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:52:48 +02:00
Sebastiaan van Stijn
2e4079ff31 image/tarexport: saveSession.save: remove redundant Platform
Commit 9160b9fda6 removed the platform from
the descriptor, but this field was still used further in the code, and now
always taking an empty platform.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:48:57 +02:00
Sebastiaan van Stijn
ab5c5df1d5 image/tarexport: rename variables that shadowed imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:48:23 +02:00
Sebastiaan van Stijn
f5cc04284d remove deprecated image/spec package
The specification moved to a separate module (github.com/moby/docker-image-spec),
and this package was deprecated in in 03a17a2887,
which is part of docker v26.0.0 and up.

This patch remove the deprecated package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:01:01 +02:00
Kir Kolyshkin
b66d4b567a image/v1: rm regexp use
Replace the regexp checking ID validity with a for loop.

The benefits are:
 - faster (up to 10x faster with less allocations);
 - no init overhead to compile the regexp.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-16 12:46:57 -07:00
Sebastiaan van Stijn
d0aa3eaccf Migrate to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 21:20:29 +02:00
Sebastiaan van Stijn
e19e6cf7f4 pkg/stringid: deprecate ValidateID
This function is only used for the legacy v1 image format.

Deprecate the function, and make image/v1 self-contained.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 15:34:38 +02:00
Paweł Gronowski
ad0f263eb5 tarexport: Plumb ctx, add OTEL spans, handle cancellation
Pass `context.Context` through `tarexport.Load` and `tarexport.Save`.
Create OTEL spans for the most time consuming operations.

Also, handle context cancellations to actually end saving/loading when
the operation is cancelled - before this PR the daemon would still be
performing the operation even though the user already cancelled it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-05-14 13:08:33 +02:00
Brian Goff
9160b9fda6 save: Remove platform from config descriptor
This was brought up by bmitch that its not expected to have a platform
object in the config descriptor.
Also checked with tianon who agreed, its not _wrong_ but is unexpected
and doesn't neccessarily make sense to have it there.

Also, while technically incorrect, ECR is throwing an error when it sees
this.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-04-02 17:15:52 +00:00
Paweł Gronowski
e8496b1ee4 imageService: Extract common code from MakeImageCache
Both containerd and graphdriver image service use the same code to
create the cache - they only supply their own `cacheAdaptor` struct.

Extract the shared code to `cache.New`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-07 15:39:42 +01:00
Paweł Gronowski
d66177591e c8d/cache: Use the same cache logic as graphdrivers
Implement the cache adaptor for containerd image store and use the same
cache logic.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-07 14:58:06 +01:00
Paweł Gronowski
bf30fee58a image/cache: Refactor backend specific code
Move image store backend specific code out of the cache code and move it
to a separate interface to allow using the same cache code with
containerd image store.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-07 14:58:04 +01:00
Sebastiaan van Stijn
03a17a2887 migrate image spec to github.com/moby/docker-image-spec
The specification was migrated to a separate module:
https://github.com/moby/docker-image-spec

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-09 19:12:18 +01:00
Sebastiaan van Stijn
b71c2792d2 image/spec: remove link to docs.docker.com "registry" specification
This spec is not directly relevant for the image spec, and the Docker
documentation no longer includes the actual specification.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-08 17:39:18 +01:00
Paweł Gronowski
2c01d53d96 image/cache: Use Platform from ocispec
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-02-06 14:26:51 +01:00
Sebastiaan van Stijn
203ffb1c09 Merge pull request #47330 from vvoland/cache-fix-older-windows
image/cache: Ignore Build and Revision on Windows
2024-02-06 13:02:00 +01:00
Sebastiaan van Stijn
2156635843 Merge pull request #47232 from vvoland/fix-save-manifests
image/save: Fix untagged images not present in index.json
2024-02-05 19:06:54 +01:00
Paweł Gronowski
91ea04089b image/cache: Ignore Build and Revision on Windows
The compatibility depends on whether `hyperv` or `process` container
isolation is used.
This fixes cache not being used when building images based on older
Windows versions on a newer Windows host.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-02-05 17:41:21 +01:00
Paweł Gronowski
d131f00fff image/save: Fix untagged images not present in index.json
Saving an image via digested reference, ID or truncated ID doesn't store
the image reference in the archive. This also causes the save code to
not add the image's manifest to the index.json.
This commit explicitly adds the untagged manifests to the index.json if
no tagged manifests were added.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-29 16:26:37 +01:00
Paweł Gronowski
877ebbe038 image/cache: Check image platform
Make sure the cache candidate platform matches the requested.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-25 16:04:05 +01:00
Paweł Gronowski
96ac22768a image/cache: Restrict cache candidates to locally built images
Restrict cache candidates only to images that were built locally.
This doesn't affect builds using `--cache-from`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-25 16:04:03 +01:00
Paweł Gronowski
c6156dc51b daemon/imageStore: Mark images built locally
Store additional image property which makes it possible to distinguish
if image was built locally.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-25 16:04:00 +01:00