Skip to content

Commit

Permalink
nydus: support with_referrer option
Browse files Browse the repository at this point in the history
With `with_referrer: true`, we can track all nydus images associated with
an OCI image. For example, in Harbor we can cascade to show nydus
images linked to an OCI image, deleting the OCI image can also delete
the corresponding nydus images. At runtime, nydus snapshotter can also
automatically upgrade an OCI image run to nydus image.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
  • Loading branch information
imeoer committed Jul 31, 2023
1 parent 03885a3 commit 8b36f1f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions misc/config/config.nydus.ref.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ converter:

# convert to OCI-referenced nydus zran image.
oci_ref: true

# with this option, we can track all nydus images associated with
# an OCI image. For example, in Harbor we can cascade to show nydus
# images linked to an OCI image, deleting the OCI image can also delete
# the corresponding nydus images. At runtime, nydus snapshotter can also
# automatically upgrade an OCI image run to nydus image.
with_referrer: true
rules:
# add suffix to tag of source image reference as target image reference
- tag_suffix: -nydus-oci-ref
7 changes: 7 additions & 0 deletions misc/config/config.nydus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ converter:
# convert to OCI-referenced nydus zran image.
# oci_ref: false

# with this option, we can track all nydus images associated with
# an OCI image. For example, in Harbor we can cascade to show nydus
# images linked to an OCI image, deleting the OCI image can also delete
# the corresponding nydus images. At runtime, nydus snapshotter can also
# automatically upgrade an OCI image run to nydus image.
with_referrer: true

# specify nydus format version, possible values: `5`, `6` (EROFS-compatible), default is `6`
# fs_version: 6

Expand Down
8 changes: 8 additions & 0 deletions pkg/driver/nydus/nydus.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type Driver struct {
backend backend.Backend
platformMC platforms.MatchComparer
encryptRecipients []string
withReferrer bool
}

func detectBuilderVersion(ctx context.Context, builder string) string {
Expand Down Expand Up @@ -175,6 +176,11 @@ func New(cfg map[string]string, platformMC platforms.MatchComparer) (*Driver, er
return nil, errors.Wrap(err, "invalid oci_ref option")
}

withReferrer, err := parseBool(cfg["with_referrer"])
if err != nil {
return nil, errors.Wrap(err, "invalid with_referrer option")
}

encryptRecipients := []string{}
if cfg["encrypt_recipients"] != "" {
encryptRecipients = strings.Split(cfg["encrypt_recipients"], ",")
Expand All @@ -201,6 +207,7 @@ func New(cfg map[string]string, platformMC platforms.MatchComparer) (*Driver, er
backend: _backend,
platformMC: platformMC,
encryptRecipients: encryptRecipients,
withReferrer: withReferrer,
}, nil
}

Expand Down Expand Up @@ -263,6 +270,7 @@ func (d *Driver) convert(ctx context.Context, provider accelcontent.Provider, so
OCI: d.docker2oci,
OCIRef: packOpt.OCIRef,
EncryptRecipients: d.encryptRecipients,
WithReferrer: d.withReferrer,
}
convertHookFunc := func(
ctx context.Context, cs content.Store, orgDesc ocispec.Descriptor, newDesc *ocispec.Descriptor,
Expand Down

0 comments on commit 8b36f1f

Please sign in to comment.