Skip to content

Commit 6362450

Browse files
committed
libartifact: use pointer receivers
Signed-off-by: Byounguk Lee <nimdrak@gmail.com>
1 parent a61bb36 commit 6362450

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

common/pkg/libartifact/store.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (as *ArtifactStore) EventChannel() chan *Event {
9797
// lookupArtifactLocked looks up an artifact by fully qualified name,
9898
// or name@digest, full ID, or partial ID.
9999
// note: lookupArtifactLocked must be called while under a store lock
100-
func (as ArtifactStore) lookupArtifactLocked(ctx context.Context, asr ArtifactStoreReference) (*Artifact, error) {
100+
func (as *ArtifactStore) lookupArtifactLocked(ctx context.Context, asr ArtifactStoreReference) (*Artifact, error) {
101101
artifacts, err := as.getArtifacts(ctx, nil)
102102
if err != nil {
103103
return nil, err
@@ -159,7 +159,7 @@ func (as ArtifactStore) lookupArtifactLocked(ctx context.Context, asr ArtifactSt
159159
}
160160

161161
// Remove an artifact from the local artifact store.
162-
func (as ArtifactStore) Remove(ctx context.Context, asr ArtifactStoreReference) (_ *digest.Digest, removeErr error) {
162+
func (as *ArtifactStore) Remove(ctx context.Context, asr ArtifactStoreReference) (_ *digest.Digest, removeErr error) {
163163
as.lock.Lock()
164164
defer as.lock.Unlock()
165165

@@ -191,23 +191,23 @@ func (as ArtifactStore) Remove(ctx context.Context, asr ArtifactStoreReference)
191191
}
192192

193193
// Inspect an artifact in a local store.
194-
func (as ArtifactStore) Inspect(ctx context.Context, asr ArtifactStoreReference) (*Artifact, error) {
194+
func (as *ArtifactStore) Inspect(ctx context.Context, asr ArtifactStoreReference) (*Artifact, error) {
195195
as.lock.RLock()
196196
defer as.lock.Unlock()
197197

198198
return as.lookupArtifactLocked(ctx, asr)
199199
}
200200

201201
// List artifacts in the local store.
202-
func (as ArtifactStore) List(ctx context.Context) (ArtifactList, error) {
202+
func (as *ArtifactStore) List(ctx context.Context) (ArtifactList, error) {
203203
as.lock.RLock()
204204
defer as.lock.Unlock()
205205

206206
return as.getArtifacts(ctx, nil)
207207
}
208208

209209
// Pull an artifact from an image registry to a local store.
210-
func (as ArtifactStore) Pull(ctx context.Context, ref ArtifactReference, opts libimage.CopyOptions) (_ digest.Digest, pullErr error) {
210+
func (as *ArtifactStore) Pull(ctx context.Context, ref ArtifactReference, opts libimage.CopyOptions) (_ digest.Digest, pullErr error) {
211211
if as.eventChannel != nil {
212212
defer func() {
213213
if pullErr != nil {
@@ -247,7 +247,7 @@ func (as ArtifactStore) Pull(ctx context.Context, ref ArtifactReference, opts li
247247
}
248248

249249
// Push an artifact to an image registry.
250-
func (as ArtifactStore) Push(ctx context.Context, src, dest ArtifactReference, opts libimage.CopyOptions) (_ digest.Digest, pushErr error) {
250+
func (as *ArtifactStore) Push(ctx context.Context, src, dest ArtifactReference, opts libimage.CopyOptions) (_ digest.Digest, pushErr error) {
251251
if as.eventChannel != nil {
252252
defer func() {
253253
if pushErr != nil {
@@ -308,7 +308,7 @@ func createNewArtifactManifest(options *libartTypes.AddOptions) specV1.Manifest
308308
}
309309

310310
// cleanupAfterAppend removes previous image when doing an append.
311-
func cleanupAfterAppend(ctx context.Context, oldDigest digest.Digest, as ArtifactStore) error {
311+
func cleanupAfterAppend(ctx context.Context, oldDigest digest.Digest, as *ArtifactStore) error {
312312
lrs, err := layout.List(as.storePath)
313313
if err != nil {
314314
return err
@@ -331,7 +331,7 @@ func cleanupAfterAppend(ctx context.Context, oldDigest digest.Digest, as Artifac
331331

332332
// Add takes one or more artifact blobs and add them to the local artifact store. The empty
333333
// string input is for possible custom artifact types.
334-
func (as ArtifactStore) Add(ctx context.Context, dest ArtifactReference, artifactBlobs []libartTypes.ArtifactBlob, options *libartTypes.AddOptions) (_ *digest.Digest, addErr error) {
334+
func (as *ArtifactStore) Add(ctx context.Context, dest ArtifactReference, artifactBlobs []libartTypes.ArtifactBlob, options *libartTypes.AddOptions) (_ *digest.Digest, addErr error) {
335335
if as.eventChannel != nil {
336336
defer func() {
337337
if addErr != nil {
@@ -514,7 +514,7 @@ func (as ArtifactStore) Add(ctx context.Context, dest ArtifactReference, artifac
514514
return &artifactManifestDigest, nil
515515
}
516516

517-
func getArtifactAndImageSource(ctx context.Context, as ArtifactStore, asr ArtifactStoreReference, options *libartTypes.FilterBlobOptions) (*Artifact, types.ImageSource, error) {
517+
func getArtifactAndImageSource(ctx context.Context, as *ArtifactStore, asr ArtifactStoreReference, options *libartTypes.FilterBlobOptions) (*Artifact, types.ImageSource, error) {
518518
if len(options.Digest) > 0 && len(options.Title) > 0 {
519519
return nil, nil, errors.New("cannot specify both digest and title")
520520
}
@@ -535,7 +535,7 @@ func getArtifactAndImageSource(ctx context.Context, as ArtifactStore, asr Artifa
535535
}
536536

537537
// BlobMountPaths allows the caller to access the file names from the store and how they should be mounted.
538-
func (as ArtifactStore) BlobMountPaths(ctx context.Context, asr ArtifactStoreReference, options *libartTypes.BlobMountPathOptions) ([]libartTypes.BlobMountPath, error) {
538+
func (as *ArtifactStore) BlobMountPaths(ctx context.Context, asr ArtifactStoreReference, options *libartTypes.BlobMountPathOptions) ([]libartTypes.BlobMountPath, error) {
539539
// FIX ME
540540
// LOCKING BUG: getArtifactAndImageSource assumes a locked ArtifactStore
541541
arty, imgSrc, err := getArtifactAndImageSource(ctx, as, asr, &options.FilterBlobOptions)
@@ -594,7 +594,7 @@ func (as ArtifactStore) BlobMountPaths(ctx context.Context, asr ArtifactStoreRef
594594
}
595595

596596
// Extract an artifact to local file or directory.
597-
func (as ArtifactStore) Extract(ctx context.Context, nameOrDigest ArtifactStoreReference, target string, options *libartTypes.ExtractOptions) error {
597+
func (as *ArtifactStore) Extract(ctx context.Context, nameOrDigest ArtifactStoreReference, target string, options *libartTypes.ExtractOptions) error {
598598
// FIX ME
599599
// LOCKING BUG: getArtifactAndImageSource assumes a locked ArtifactStore
600600
arty, imgSrc, err := getArtifactAndImageSource(ctx, as, nameOrDigest, &options.FilterBlobOptions)
@@ -663,7 +663,7 @@ func (as ArtifactStore) Extract(ctx context.Context, nameOrDigest ArtifactStoreR
663663
}
664664

665665
// Extract an artifact to tar stream.
666-
func (as ArtifactStore) ExtractTarStream(ctx context.Context, w io.Writer, asr ArtifactStoreReference, options *libartTypes.ExtractOptions) error {
666+
func (as *ArtifactStore) ExtractTarStream(ctx context.Context, w io.Writer, asr ArtifactStoreReference, options *libartTypes.ExtractOptions) error {
667667
if options == nil {
668668
options = &libartTypes.ExtractOptions{}
669669
}
@@ -862,7 +862,7 @@ func copyTrustedImageBlobToTarStream(ctx context.Context, imgSrc types.ImageSour
862862
return nil
863863
}
864864

865-
func (as ArtifactStore) createEmptyManifest() error {
865+
func (as *ArtifactStore) createEmptyManifest() error {
866866
as.lock.Lock()
867867
defer as.lock.Unlock()
868868
index := specV1.Index{
@@ -877,13 +877,13 @@ func (as ArtifactStore) createEmptyManifest() error {
877877
return os.WriteFile(as.indexPath(), rawData, 0o644)
878878
}
879879

880-
func (as ArtifactStore) indexPath() string {
880+
func (as *ArtifactStore) indexPath() string {
881881
return filepath.Join(as.storePath, specV1.ImageIndexFile)
882882
}
883883

884884
// getArtifacts returns an ArtifactList based on the artifact's store. The return error and
885885
// unused opts is meant for future growth like filters, etc so the API does not change.
886-
func (as ArtifactStore) getArtifacts(ctx context.Context, _ *libartTypes.GetArtifactOptions) (ArtifactList, error) {
886+
func (as *ArtifactStore) getArtifacts(ctx context.Context, _ *libartTypes.GetArtifactOptions) (ArtifactList, error) {
887887
var al ArtifactList
888888

889889
lrs, err := layout.List(as.storePath)

0 commit comments

Comments
 (0)