Browse code

c8d: Rename readConfig to readJSON

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2024/08/14 20:51:16
Showing 4 changed files
... ...
@@ -84,7 +84,7 @@ func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
84 84
 			}
85 85
 
86 86
 			var config container.Config
87
-			if err := readConfig(ctx, c.is.content, configDesc, &config); err != nil {
87
+			if err := readJSON(ctx, c.is.content, configDesc, &config); err != nil {
88 88
 				if !errdefs.IsNotFound(err) {
89 89
 					log.G(ctx).WithFields(log.Fields{
90 90
 						"configDigest": dgst,
... ...
@@ -474,7 +474,7 @@ func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore con
474 474
 		return nil, err
475 475
 	}
476 476
 	var cfg configLabels
477
-	if err := readConfig(ctx, contentStore, cfgDesc, &cfg); err != nil {
477
+	if err := readJSON(ctx, contentStore, cfgDesc, &cfg); err != nil {
478 478
 		return nil, err
479 479
 	}
480 480
 
... ...
@@ -676,7 +676,7 @@ func setupLabelFilter(ctx context.Context, store content.Store, fltrs filters.Ar
676 676
 				return nil, nil
677 677
 			}
678 678
 			var cfg configLabels
679
-			if err := readConfig(ctx, store, desc, &cfg); err != nil {
679
+			if err := readJSON(ctx, store, desc, &cfg); err != nil {
680 680
 				if errdefs.IsNotFound(err) {
681 681
 					return nil, nil
682 682
 				}
... ...
@@ -751,8 +751,8 @@ func computeSharedSize(chainIDs []digest.Digest, layers map[digest.Digest]int, s
751 751
 	return sharedSize, nil
752 752
 }
753 753
 
754
-// readConfig reads content pointed by the descriptor and unmarshals it into a specified output.
755
-func readConfig(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
754
+// readJSON reads content pointed by the descriptor and unmarshals it into a specified output.
755
+func readJSON(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
756 756
 	data, err := content.ReadBlob(ctx, store, desc)
757 757
 	if err != nil {
758 758
 		err = errors.Wrapf(err, "failed to read config content")
... ...
@@ -125,8 +125,8 @@ func TestImageListCheckTotalSize(t *testing.T) {
125 125
 	amd64ManifestSize := blobSize(t, ctx, cs, mfstAmd64.Digest)
126 126
 
127 127
 	var arm64Mfst, amd64Mfst ocispec.Manifest
128
-	assert.NilError(t, readConfig(ctx, cs, mfstArm64, &arm64Mfst))
129
-	assert.NilError(t, readConfig(ctx, cs, mfstAmd64, &amd64Mfst))
128
+	assert.NilError(t, readJSON(ctx, cs, mfstArm64, &arm64Mfst))
129
+	assert.NilError(t, readJSON(ctx, cs, mfstAmd64, &amd64Mfst))
130 130
 
131 131
 	// MultiPlatform should produce a single layer. If these fail, the test needs to be adjusted.
132 132
 	assert.Assert(t, is.Len(arm64Mfst.Layers, 1))
... ...
@@ -236,5 +236,5 @@ func (m *ImageManifest) ReadConfig(ctx context.Context, outConfig interface{}) e
236 236
 		return err
237 237
 	}
238 238
 
239
-	return readConfig(ctx, m.ContentStore(), configDesc, outConfig)
239
+	return readJSON(ctx, m.ContentStore(), configDesc, outConfig)
240 240
 }