...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package types
17
18
19 type MediaType string
20
21
22 const (
23 OCIContentDescriptor MediaType = "application/vnd.oci.descriptor.v1+json"
24 OCIImageIndex MediaType = "application/vnd.oci.image.index.v1+json"
25 OCIManifestSchema1 MediaType = "application/vnd.oci.image.manifest.v1+json"
26 OCIConfigJSON MediaType = "application/vnd.oci.image.config.v1+json"
27 OCILayer MediaType = "application/vnd.oci.image.layer.v1.tar+gzip"
28 OCILayerZStd MediaType = "application/vnd.oci.image.layer.v1.tar+zstd"
29 OCIRestrictedLayer MediaType = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip"
30 OCIUncompressedLayer MediaType = "application/vnd.oci.image.layer.v1.tar"
31 OCIUncompressedRestrictedLayer MediaType = "application/vnd.oci.image.layer.nondistributable.v1.tar"
32
33 DockerManifestSchema1 MediaType = "application/vnd.docker.distribution.manifest.v1+json"
34 DockerManifestSchema1Signed MediaType = "application/vnd.docker.distribution.manifest.v1+prettyjws"
35 DockerManifestSchema2 MediaType = "application/vnd.docker.distribution.manifest.v2+json"
36 DockerManifestList MediaType = "application/vnd.docker.distribution.manifest.list.v2+json"
37 DockerLayer MediaType = "application/vnd.docker.image.rootfs.diff.tar.gzip"
38 DockerConfigJSON MediaType = "application/vnd.docker.container.image.v1+json"
39 DockerPluginConfig MediaType = "application/vnd.docker.plugin.v1+json"
40 DockerForeignLayer MediaType = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"
41 DockerUncompressedLayer MediaType = "application/vnd.docker.image.rootfs.diff.tar"
42
43 OCIVendorPrefix = "vnd.oci"
44 DockerVendorPrefix = "vnd.docker"
45 )
46
47
48
49 func (m MediaType) IsDistributable() bool {
50 switch m {
51 case DockerForeignLayer, OCIRestrictedLayer, OCIUncompressedRestrictedLayer:
52 return false
53 }
54 return true
55 }
56
57
58 func (m MediaType) IsImage() bool {
59 switch m {
60 case OCIManifestSchema1, DockerManifestSchema2:
61 return true
62 }
63 return false
64 }
65
66
67 func (m MediaType) IsIndex() bool {
68 switch m {
69 case OCIImageIndex, DockerManifestList:
70 return true
71 }
72 return false
73 }
74
75
76 func (m MediaType) IsConfig() bool {
77 switch m {
78 case OCIConfigJSON, DockerConfigJSON:
79 return true
80 }
81 return false
82 }
83
84 func (m MediaType) IsSchema1() bool {
85 switch m {
86 case DockerManifestSchema1, DockerManifestSchema1Signed:
87 return true
88 }
89 return false
90 }
91
92 func (m MediaType) IsLayer() bool {
93 switch m {
94 case DockerLayer, DockerUncompressedLayer, OCILayer, OCILayerZStd, OCIUncompressedLayer, DockerForeignLayer, OCIRestrictedLayer, OCIUncompressedRestrictedLayer:
95 return true
96 }
97 return false
98 }
99
View as plain text