github.com/jdolitsky/cnab-go@v0.7.1-beta1/imagestore/remote/remote.go (about)

     1  package remote
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/pivotal/image-relocation/pkg/image"
     7  	"github.com/pivotal/image-relocation/pkg/registry"
     8  	"github.com/pivotal/image-relocation/pkg/registry/ggcr"
     9  
    10  	"github.com/deislabs/cnab-go/imagestore"
    11  )
    12  
    13  // remote is an image store which does not actually store images. It is used to represent thin bundles.
    14  type remote struct {
    15  	registryClient registry.Client
    16  }
    17  
    18  func Create(...imagestore.Option) (imagestore.Store, error) {
    19  	return &remote{
    20  		registryClient: ggcr.NewRegistryClient(),
    21  	}, nil
    22  }
    23  
    24  func (r *remote) Add(im string) (string, error) {
    25  	return "", nil
    26  }
    27  
    28  func (r *remote) Push(d image.Digest, src image.Name, dst image.Name) error {
    29  	dig, _, err := r.registryClient.Copy(src, dst)
    30  	if err != nil {
    31  		return err
    32  	}
    33  
    34  	if d != image.EmptyDigest && dig != d {
    35  		return fmt.Errorf("digest of image %s not preserved: old digest %s; new digest %s", src, d.String(), dig.String())
    36  	}
    37  	return nil
    38  }