github.com/YousefHaggyHeroku/pack@v1.5.5/internal/image/factory.go (about)

     1  package image
     2  
     3  import (
     4  	"github.com/buildpacks/imgutil"
     5  	"github.com/buildpacks/imgutil/local"
     6  	"github.com/buildpacks/imgutil/remote"
     7  	"github.com/docker/docker/client"
     8  	"github.com/google/go-containerregistry/pkg/authn"
     9  )
    10  
    11  type DefaultImageFactory struct {
    12  	dockerClient client.CommonAPIClient
    13  	keychain     authn.Keychain
    14  }
    15  
    16  func NewFactory(dockerClient client.CommonAPIClient, keychain authn.Keychain) *DefaultImageFactory {
    17  	return &DefaultImageFactory{
    18  		dockerClient: dockerClient,
    19  		keychain:     keychain,
    20  	}
    21  }
    22  
    23  func (f *DefaultImageFactory) NewImage(repoName string, daemon bool) (imgutil.Image, error) {
    24  	if daemon {
    25  		return local.NewImage(repoName, f.dockerClient)
    26  	}
    27  
    28  	return remote.NewImage(repoName, f.keychain)
    29  }