Skip to content

Commit 21f962e

Browse files
committed
libimage: pass UID/GID mappings through the pull path
Add UIDMap/GIDMap fields to CopyOptions and pass them to the storage transport reference when pulling an image. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 4244440 commit 21f962e

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

common/libimage/copier.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.podman.io/common/pkg/config"
2020
"go.podman.io/common/pkg/retry"
2121
"go.podman.io/image/v5/copy"
22+
"go.podman.io/storage/pkg/idtools"
2223
"go.podman.io/image/v5/docker/reference"
2324
"go.podman.io/image/v5/pkg/compression"
2425
"go.podman.io/image/v5/signature"
@@ -150,6 +151,13 @@ type CopyOptions struct {
150151
// an access token for the registry.
151152
IdentityToken string `json:"identitytoken,omitempty"`
152153

154+
// ----- ID Mapping ---------------------------------------------------
155+
156+
// UIDMap and GIDMap are used for setting up image layers with the
157+
// correct UID/GID mappings when pulling into storage.
158+
UIDMap []idtools.IDMap
159+
GIDMap []idtools.IDMap
160+
153161
// ----- internal -----------------------------------------------------
154162

155163
// Additional tags when creating or copying a docker-archive.

common/libimage/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
623623
if err != nil {
624624
return nil, err
625625
}
626+
if len(options.UIDMap) > 0 || len(options.GIDMap) > 0 {
627+
destRef.SetIDMappingOptions(options.UIDMap, options.GIDMap)
628+
}
626629

627630
if err := writeDesc(); err != nil {
628631
return nil, err

0 commit comments

Comments
 (0)