Skip to content

Commit 9f3efb2

Browse files
loresusopoiana
authored andcommitted
update: remove unused functions in the pusher
Signed-off-by: Lorenzo Susini <[email protected]>
1 parent cc11db6 commit 9f3efb2

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
662662
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
663663
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
664664
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
665-
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
666-
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
667665
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
668666
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
669667
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -992,8 +990,6 @@ k8s.io/metrics v0.24.3/go.mod h1:p1M0lhMySWfhISkSd3HEj8xIgrVnJTK3PPhFq2rA3To=
992990
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
993991
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
994992
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
995-
oras.land/oras-go/v2 v2.0.0-rc.2 h1:dks9BxPg6HQOxn5+jVNuTFl45FuYvHfLQ6wcP7hVRdE=
996-
oras.land/oras-go/v2 v2.0.0-rc.2/go.mod h1:IZRIoIJqkAH6x0pL3tVnpyPUyZgthjSyPcH2kgJvBMo=
997993
oras.land/oras-go/v2 v2.0.0-rc.3 h1:O4GeIwJ9Ge7rbCkqa/M7DLrL55ww+ZEc+Rhc63OYitU=
998994
oras.land/oras-go/v2 v2.0.0-rc.3/go.mod h1:PrY+cCglzK/DrQoJUtxbYVbL94ZHecVS3eJR01RglpE=
999995
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=

pkg/oci/pusher/pusher.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ import (
1919
"encoding/json"
2020
"errors"
2121
"fmt"
22-
"io"
2322
"os"
2423
"path/filepath"
25-
"reflect"
2624
"strings"
2725

2826
"github.com/opencontainers/image-spec/specs-go"
@@ -182,52 +180,6 @@ func (p *Pusher) Push(ctx context.Context, artifactType oci.ArtifactType,
182180
}, nil
183181
}
184182

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-
231183
func (p *Pusher) storeMainLayer(ctx context.Context, fileStore *file.Store,
232184
artifactType oci.ArtifactType, artifactPath string) (*v1.Descriptor, error) {
233185
var layerMediaType string

0 commit comments

Comments
 (0)