From a75b65bb7bc4812b0967c9965ab6f5fd86bfd9e7 Mon Sep 17 00:00:00 2001 From: Yan Song Date: Fri, 14 Jul 2023 01:54:45 +0000 Subject: [PATCH] converter: allow controlling referrer with option Some registry implementations like Docker Hub don't support the OCI reference type (aka referrer) yet, we shouldn't enable it by default, instead, provide a `WithReferrer` option to control it. 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. Signed-off-by: Yan Song --- pkg/converter/convert_unix.go | 10 ++++++---- pkg/converter/types.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/converter/convert_unix.go b/pkg/converter/convert_unix.go index e0bbd05561..7e7c503f2e 100644 --- a/pkg/converter/convert_unix.go +++ b/pkg/converter/convert_unix.go @@ -1009,10 +1009,12 @@ func convertManifest(ctx context.Context, cs content.Store, oldDesc ocispec.Desc // Update the config gc label manifestLabels[configGCLabelKey] = newConfigDesc.Digest.String() - // Associate a reference to the original OCI manifest. - // See the `subject` field description in - // https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest-property-descriptions - manifest.Subject = &oldDesc + if opt.WithReferrer { + // Associate a reference to the original OCI manifest. + // See the `subject` field description in + // https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest-property-descriptions + manifest.Subject = &oldDesc + } // Update image manifest in content store. newManifestDesc, err := writeJSON(ctx, cs, manifest, manifestDesc, manifestLabels) diff --git a/pkg/converter/types.go b/pkg/converter/types.go index c9795d946c..eb26bf0f86 100644 --- a/pkg/converter/types.go +++ b/pkg/converter/types.go @@ -105,6 +105,16 @@ type MergeOption struct { OCI bool // OCIRef enables converting OCI tar(.gz) blob to nydus referenced blob. OCIRef bool + // WithReferrer associates a reference to the original OCI manifest. + // See the `subject` field description in + // https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest-property-descriptions + // + // With this association, 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. + WithReferrer bool // Backend uploads blobs generated by nydus-image builder to a backend storage. Backend Backend // Timeout cancels execution once exceed the specified time.