@@ -19,10 +19,8 @@ import (
19
19
"encoding/json"
20
20
"errors"
21
21
"fmt"
22
- "io"
23
22
"os"
24
23
"path/filepath"
25
- "reflect"
26
24
"strings"
27
25
28
26
"github.com/opencontainers/image-spec/specs-go"
@@ -182,52 +180,6 @@ func (p *Pusher) Push(ctx context.Context, artifactType oci.ArtifactType,
182
180
}, nil
183
181
}
184
182
185
- func (p * Pusher ) retrieveIndex (ctx context.Context , repo * remote.Repository ) (* v1.Index , error ) {
186
- var indexBytes []byte
187
- var index v1.Index
188
-
189
- ref := repo .Reference .String ()
190
- indexDesc , reader , err := repo .FetchReference (ctx , repo .Reference .Reference )
191
- if err != nil {
192
- if strings .Contains (err .Error (), fmt .Sprintf ("%s: not found" , repo .Reference .Reference )) {
193
- return nil , fmt .Errorf ("unable to download image index for ref %s, %w" , ref , ErrNotFound )
194
- }
195
- return nil , fmt .Errorf ("unable to download image index for ref %s: %w" , ref , err )
196
- }
197
-
198
- // Check if the descriptor has media type image index.
199
- if indexDesc .MediaType != v1 .MediaTypeImageIndex {
200
- return nil , fmt .Errorf ("the pulled descriptor for ref %q has media type %q while expecting %q" ,
201
- ref , indexDesc .MediaType , v1 .MediaTypeImageIndex )
202
- }
203
-
204
- if indexBytes , err = io .ReadAll (reader ); err != nil {
205
- return nil , fmt .Errorf ("unable to read index from reader for ref %q: %w" , ref , err )
206
- }
207
-
208
- if err = json .Unmarshal (indexBytes , & index ); err != nil {
209
- return nil , fmt .Errorf ("unable to unmarshal index for ref %q: %w" , ref , err )
210
- }
211
- return & index , nil
212
- }
213
-
214
- func (p * Pusher ) updateIndex (indexDesc * v1.Index , manifestDesc * v1.Descriptor ) * v1.Index {
215
- // Check if the index already contains the manifest for the given platform.
216
- for i , m := range indexDesc .Manifests {
217
- // If we find a manifest in the index that has the same platform as the artifact that we are currently
218
- // processing it means that we are going to overwrite it with the current version. Only if the digests are
219
- // different.
220
- if reflect .DeepEqual (m .Platform , manifestDesc .Platform ) {
221
- // Remove manifest from the index.
222
- indexDesc .Manifests = append (indexDesc .Manifests [:i ], indexDesc .Manifests [i + 1 :]... )
223
- break
224
- }
225
- }
226
-
227
- indexDesc .Manifests = append (indexDesc .Manifests , * manifestDesc )
228
- return indexDesc
229
- }
230
-
231
183
func (p * Pusher ) storeMainLayer (ctx context.Context , fileStore * file.Store ,
232
184
artifactType oci.ArtifactType , artifactPath string ) (* v1.Descriptor , error ) {
233
185
var layerMediaType string
0 commit comments