@@ -29,18 +29,6 @@ import (
2929 oci "github.com/opencontainers/image-spec/specs-go/v1"
3030)
3131
32- func isMediaTypeValid (mt string ) bool {
33- return strings .HasPrefix (mt , "application/vnd.docker." ) || strings .HasPrefix (mt , "application/vnd.oci." )
34- }
35-
36- func isMediaTypeImageManifest (mt string ) bool {
37- return strings .EqualFold (mt , oci .MediaTypeImageManifest ) || strings .EqualFold (mt , "application/vnd.docker.distribution.manifest.v2+json" )
38- }
39-
40- func isMediaTypeImageIndex (mt string ) bool {
41- return strings .EqualFold (mt , oci .MediaTypeImageIndex ) || strings .EqualFold (mt , "application/vnd.docker.distribution.manifest.list.v2+json" )
42- }
43-
4432// manifestCreationInfo describes a manifest to create
4533type manifestCreationInfo struct {
4634 MediaType string
@@ -66,16 +54,16 @@ func processManifest(ctx context.Context, mci *manifestCreationInfo, buf *packag
6654 return "" , err
6755 }
6856
69- if ! isMediaTypeValid (mci .MediaType ) {
57+ if ! container_module . IsMediaTypeValid (mci .MediaType ) {
7058 mci .MediaType = index .MediaType
71- if ! isMediaTypeValid (mci .MediaType ) {
59+ if ! container_module . IsMediaTypeValid (mci .MediaType ) {
7260 return "" , errManifestInvalid .WithMessage ("MediaType not recognized" )
7361 }
7462 }
7563
76- if isMediaTypeImageManifest (mci .MediaType ) {
64+ if container_module . IsMediaTypeImageManifest (mci .MediaType ) {
7765 return processOciImageManifest (ctx , mci , buf )
78- } else if isMediaTypeImageIndex (mci .MediaType ) {
66+ } else if container_module . IsMediaTypeImageIndex (mci .MediaType ) {
7967 return processOciImageIndex (ctx , mci , buf )
8068 }
8169 return "" , errManifestInvalid
@@ -201,7 +189,7 @@ func processOciImageIndex(ctx context.Context, mci *manifestCreationInfo, buf *p
201189 }
202190
203191 for _ , manifest := range index .Manifests {
204- if ! isMediaTypeImageManifest (manifest .MediaType ) {
192+ if ! container_module . IsMediaTypeImageManifest (manifest .MediaType ) {
205193 return errManifestInvalid
206194 }
207195
@@ -336,7 +324,7 @@ func createPackageAndVersion(ctx context.Context, mci *manifestCreationInfo, met
336324 return nil , err
337325 }
338326
339- if isMediaTypeImageIndex (mci .MediaType ) {
327+ if container_module . IsMediaTypeImageIndex (mci .MediaType ) {
340328 if pv .CreatedUnix .AsTime ().Before (time .Now ().Add (- 24 * time .Hour )) {
341329 if err = packages_service .DeletePackageVersionAndReferences (ctx , pv ); err != nil {
342330 return nil , err
0 commit comments