Skip to content

Commit 00c3cbe

Browse files
authored
Merge pull request #639 from DataDog/fricounet/converter-push-ecr
Fix converter to be able to push manifests to ECR
2 parents 88a72d9 + 6542a89 commit 00c3cbe

File tree

1 file changed

+7
-34
lines changed

1 file changed

+7
-34
lines changed

pkg/converter/convert_unix.go

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ func ConvertHookFunc(opt MergeOption) converter.ConvertHookFunc {
913913
}
914914
switch {
915915
case images.IsIndexType(newDesc.MediaType):
916-
return convertIndex(ctx, cs, orgDesc, newDesc)
916+
return convertIndex(ctx, cs, newDesc)
917917
case images.IsManifestType(newDesc.MediaType):
918918
return convertManifest(ctx, cs, orgDesc, newDesc, opt)
919919
default:
@@ -922,49 +922,20 @@ func ConvertHookFunc(opt MergeOption) converter.ConvertHookFunc {
922922
}
923923
}
924924

925-
// convertIndex modifies the original index by appending "nydus.remoteimage.v1"
926-
// to the Platform.OSFeatures of each modified manifest descriptors.
927-
func convertIndex(ctx context.Context, cs content.Store, orgDesc ocispec.Descriptor, newDesc *ocispec.Descriptor) (*ocispec.Descriptor, error) {
928-
var orgIndex ocispec.Index
929-
if _, err := readJSON(ctx, cs, &orgIndex, orgDesc); err != nil {
930-
return nil, errors.Wrap(err, "read target image index json")
931-
}
932-
// isManifestModified is a function to check whether the manifest is modified.
933-
isManifestModified := func(manifest ocispec.Descriptor) bool {
934-
for _, oldManifest := range orgIndex.Manifests {
935-
if manifest.Digest == oldManifest.Digest {
936-
return false
937-
}
938-
}
939-
return true
940-
}
941-
925+
// convertIndex modifies the original index converting it to manifest directly if it contains only one manifest.
926+
func convertIndex(ctx context.Context, cs content.Store, newDesc *ocispec.Descriptor) (*ocispec.Descriptor, error) {
942927
var index ocispec.Index
943-
indexLabels, err := readJSON(ctx, cs, &index, *newDesc)
928+
_, err := readJSON(ctx, cs, &index, *newDesc)
944929
if err != nil {
945930
return nil, errors.Wrap(err, "read index json")
946931
}
947-
for i, manifest := range index.Manifests {
948-
if !isManifestModified(manifest) {
949-
// Skip the manifest which is not modified.
950-
continue
951-
}
952-
manifest.Platform.OSFeatures = append(manifest.Platform.OSFeatures, ManifestOSFeatureNydus)
953-
index.Manifests[i] = manifest
954-
}
955932

956933
// If the converted manifest list contains only one manifest,
957934
// convert it directly to manifest.
958935
if len(index.Manifests) == 1 {
959936
return &index.Manifests[0], nil
960937
}
961-
962-
// Update image index in content store.
963-
newIndexDesc, err := writeJSON(ctx, cs, index, *newDesc, indexLabels)
964-
if err != nil {
965-
return nil, errors.Wrap(err, "write index json")
966-
}
967-
return newIndexDesc, nil
938+
return newDesc, nil
968939
}
969940

970941
// convertManifest merges all the nydus blob layers into a
@@ -1054,6 +1025,8 @@ func convertManifest(ctx context.Context, cs content.Store, oldDesc ocispec.Desc
10541025
// See the `subject` field description in
10551026
// https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest-property-descriptions
10561027
manifest.Subject = &oldDesc
1028+
// Remove the platform field as it is not supported by certain registries like ECR.
1029+
manifest.Subject.Platform = nil
10571030
}
10581031

10591032
// Update image manifest in content store.

0 commit comments

Comments
 (0)