Skip to content

Commit 037953b

Browse files
Merge pull request #528 from tchap/drop-schema1
WRKLDS-1599: Drop support for image manifest schema 1
2 parents 08d9c6d + 99e8cd6 commit 037953b

File tree

17 files changed

+812
-925
lines changed

17 files changed

+812
-925
lines changed

pkg/image/apis/image/docker10/conversion.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,9 @@ package docker10
33
import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
55

6-
"github.com/openshift/api/image/docker10"
7-
86
"github.com/openshift/openshift-apiserver/pkg/image/apis/image"
97
)
108

11-
// Convert_DockerV1CompatibilityImage_to_DockerImageConfig takes a container image registry digest
12-
// (schema 2.1) and converts it to the external API version of Image.
13-
func Convert_DockerV1CompatibilityImage_to_DockerImageConfig(in *DockerV1CompatibilityImage, out *DockerImageConfig) error {
14-
*out = DockerImageConfig{
15-
ID: in.ID,
16-
Parent: in.Parent,
17-
Comment: in.Comment,
18-
Created: in.Created,
19-
Container: in.Container,
20-
DockerVersion: in.DockerVersion,
21-
Author: in.Author,
22-
Architecture: in.Architecture,
23-
Size: in.Size,
24-
OS: "linux",
25-
ContainerConfig: in.ContainerConfig,
26-
}
27-
if in.Config != nil {
28-
out.Config = &docker10.DockerConfig{}
29-
*out.Config = *in.Config
30-
}
31-
return nil
32-
}
33-
34-
// Convert_DockerV1CompatibilityImage_to_image_DockerImage takes a container
35-
// image registry digest (schema 2.1) and converts it to the internal API
36-
// version of Image.
37-
func Convert_DockerV1CompatibilityImage_to_image_DockerImage(in *DockerV1CompatibilityImage, out *image.DockerImage) error {
38-
*out = image.DockerImage{
39-
ID: in.ID,
40-
Parent: in.Parent,
41-
Comment: in.Comment,
42-
Created: metav1.Time{Time: in.Created},
43-
Container: in.Container,
44-
DockerVersion: in.DockerVersion,
45-
Author: in.Author,
46-
Architecture: in.Architecture,
47-
Size: in.Size,
48-
}
49-
if err := Convert_docker10_DockerConfig_To_image_DockerConfig(&in.ContainerConfig, &out.ContainerConfig, nil); err != nil {
50-
return err
51-
}
52-
if in.Config != nil {
53-
out.Config = &image.DockerConfig{}
54-
if err := Convert_docker10_DockerConfig_To_image_DockerConfig(in.Config, out.Config, nil); err != nil {
55-
return err
56-
}
57-
}
58-
return nil
59-
}
60-
619
// Convert_DockerImageConfig_to_image_DockerImage takes a container image
6210
// registry digest (schema 2.2) and converts it to the internal API version of
6311
// Image.

pkg/image/apis/image/docker10/types.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,11 @@ type DockerImageManifest struct {
2828
SchemaVersion int `json:"schemaVersion"`
2929
MediaType string `json:"mediaType,omitempty"`
3030

31-
// schema1
32-
Name string `json:"name"`
33-
Tag string `json:"tag"`
34-
Architecture string `json:"architecture"`
35-
FSLayers []DockerFSLayer `json:"fsLayers"`
36-
History []DockerHistory `json:"history"`
37-
3831
// schema2
3932
Layers []Descriptor `json:"layers"`
4033
Config Descriptor `json:"config"`
4134
}
4235

43-
// DockerFSLayer is a container struct for BlobSums defined in an image manifest
44-
type DockerFSLayer struct {
45-
// DockerBlobSum is the tarsum of the referenced filesystem image layer
46-
// TODO make this digest.Digest once distribution/distribution/v3 is in Godeps
47-
DockerBlobSum string `json:"blobSum"`
48-
}
49-
50-
// DockerHistory stores unstructured v1 compatibility information
51-
type DockerHistory struct {
52-
// DockerV1Compatibility is the raw v1 compatibility information
53-
DockerV1Compatibility string `json:"v1Compatibility"`
54-
}
55-
56-
// DockerV1CompatibilityImage represents the structured v1
57-
// compatibility information.
58-
type DockerV1CompatibilityImage struct {
59-
ID string `json:"id"`
60-
Parent string `json:"parent,omitempty"`
61-
Comment string `json:"comment,omitempty"`
62-
Created time.Time `json:"created"`
63-
Container string `json:"container,omitempty"`
64-
ContainerConfig docker10.DockerConfig `json:"container_config,omitempty"`
65-
DockerVersion string `json:"docker_version,omitempty"`
66-
Author string `json:"author,omitempty"`
67-
Config *docker10.DockerConfig `json:"config,omitempty"`
68-
Architecture string `json:"architecture,omitempty"`
69-
Size int64 `json:"size,omitempty"`
70-
}
71-
72-
// DockerV1CompatibilityImageSize represents the structured v1
73-
// compatibility information for size
74-
type DockerV1CompatibilityImageSize struct {
75-
Size int64 `json:"size,omitempty"`
76-
}
77-
7836
// DockerImageConfig stores the image configuration
7937
type DockerImageConfig struct {
8038
ID string `json:"id"`

pkg/image/apiserver/admission/limitrange/admission_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
imagev1 "github.com/openshift/api/image/v1"
2020
"github.com/openshift/openshift-apiserver/pkg/api/legacy"
2121
imageapi "github.com/openshift/openshift-apiserver/pkg/image/apis/image"
22-
"github.com/openshift/openshift-apiserver/pkg/image/apiserver/testutil"
22+
"github.com/openshift/openshift-apiserver/pkg/image/apiserver/internal/testutil"
2323
)
2424

2525
func TestAdmitImageStreamMapping(t *testing.T) {
@@ -36,7 +36,7 @@ func TestAdmitImageStreamMapping(t *testing.T) {
3636
},
3737
"new ism, under limit range": {
3838
imageStreamMapping: getImageStreamMapping(),
39-
limitRange: getLimitRange("1Ki"),
39+
limitRange: getLimitRange("2Mi"),
4040
operation: admission.Create,
4141
shouldAdmit: true,
4242
},
@@ -246,6 +246,7 @@ func getBaseImageWith1Layer() imageapi.Image {
246246
},
247247
DockerImageReference: fmt.Sprintf("registry.example.org/%s/%s", "test", testutil.BaseImageWith1LayerDigest),
248248
DockerImageManifest: testutil.BaseImageWith1Layer,
249+
DockerImageConfig: testutil.BaseImageWith1LayerConfig,
249250
}
250251
}
251252

pkg/image/apiserver/admission/limitrange/imagestream_limits_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/openshift/library-go/pkg/quota/quotautil"
1414

1515
imageapi "github.com/openshift/openshift-apiserver/pkg/image/apis/image"
16-
imagetest "github.com/openshift/openshift-apiserver/pkg/image/apiserver/testutil"
16+
imagetest "github.com/openshift/openshift-apiserver/pkg/image/apiserver/internal/testutil"
1717
)
1818

1919
func TestGetMaxLimits(t *testing.T) {

pkg/image/apiserver/admission/limitrange/usage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
imagev1 "github.com/openshift/api/image/v1"
1414
"github.com/openshift/library-go/pkg/image/imageutil"
1515
imageapi "github.com/openshift/openshift-apiserver/pkg/image/apis/image"
16-
imagetest "github.com/openshift/openshift-apiserver/pkg/image/apiserver/testutil"
16+
imagetest "github.com/openshift/openshift-apiserver/pkg/image/apiserver/internal/testutil"
1717
)
1818

1919
func TestGetImageReferenceForObjectReference(t *testing.T) {

pkg/image/apiserver/importer/image.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/distribution/distribution/v3"
88
"github.com/distribution/distribution/v3/manifest/manifestlist"
9-
"github.com/distribution/distribution/v3/manifest/schema1"
109
"github.com/distribution/distribution/v3/registry/api/errcode"
1110
godigest "github.com/opencontainers/go-digest"
1211

@@ -18,41 +17,6 @@ import (
1817
imagedockerpre012 "github.com/openshift/openshift-apiserver/pkg/image/apis/image/dockerpre012"
1918
)
2019

21-
func schema1ToImage(manifest *schema1.SignedManifest, d godigest.Digest) (*imageapi.Image, error) {
22-
if len(manifest.History) == 0 {
23-
return nil, fmt.Errorf("image has no v1Compatibility history and cannot be used")
24-
}
25-
dockerImage, err := unmarshalDockerImage([]byte(manifest.History[0].V1Compatibility))
26-
if err != nil {
27-
return nil, err
28-
}
29-
mediatype, payload, err := manifest.Payload()
30-
if err != nil {
31-
return nil, err
32-
}
33-
34-
if len(manifest.Canonical) == 0 {
35-
return nil, fmt.Errorf("unable to load canonical representation from schema1 manifest")
36-
}
37-
payloadDigest := godigest.FromBytes(manifest.Canonical)
38-
if len(d) > 0 && payloadDigest != d {
39-
return nil, fmt.Errorf("content integrity error: the schema 1 manifest retrieved with digest %s does not match the digest calculated from the content %s", d, payloadDigest)
40-
}
41-
dockerImage.ID = payloadDigest.String()
42-
43-
image := &imageapi.Image{
44-
ObjectMeta: metav1.ObjectMeta{
45-
Name: dockerImage.ID,
46-
},
47-
DockerImageMetadata: *dockerImage,
48-
DockerImageManifest: string(payload),
49-
DockerImageManifestMediaType: mediatype,
50-
DockerImageMetadataVersion: "1.0",
51-
}
52-
53-
return image, nil
54-
}
55-
5620
// schema2OrOCIToImage converts a docker schema 2 or an oci schema manifest into an Image.
5721
func schema2OrOCIToImage(manifest distribution.Manifest, imageConfig []byte, d godigest.Digest) (*imageapi.Image, error) {
5822
mediatype, payload, err := manifest.Payload()

pkg/image/apiserver/importer/importer.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/distribution/distribution/v3"
1313
"github.com/distribution/distribution/v3/manifest/manifestlist"
1414
"github.com/distribution/distribution/v3/manifest/ocischema"
15-
"github.com/distribution/distribution/v3/manifest/schema1"
1615
"github.com/distribution/distribution/v3/manifest/schema2"
1716
"github.com/distribution/distribution/v3/reference"
1817
"github.com/distribution/distribution/v3/registry/api/errcode"
@@ -743,8 +742,6 @@ func (imp *ImageStreamImporter) importManifest(
743742
if isManifestList && !legacyManifestListImport {
744743
image, err = manifestListToImage(manifestList, d)
745744
return
746-
} else if signedManifest, isSchema1 := manifest.(*schema1.SignedManifest); isSchema1 {
747-
image, err = schema1ToImage(signedManifest, d)
748745
} else if deserializedManifest, isSchema2 := manifest.(*schema2.DeserializedManifest); isSchema2 {
749746
imageConfig, getImportConfigErr := b.Get(ctx, deserializedManifest.Config.Digest)
750747
if getImportConfigErr != nil {

0 commit comments

Comments
 (0)