forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract shared interfaces to their own file
- Loading branch information
Showing
3 changed files
with
67 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package pack | ||
|
||
import ( | ||
"compress/gzip" | ||
"context" | ||
"crypto/sha256" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
"net/url" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/BurntSushi/toml" | ||
"github.com/buildpack/lifecycle" | ||
"github.com/buildpack/lifecycle/img" | ||
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/api/types/container" | ||
"github.com/docker/docker/api/types/network" | ||
"github.com/google/go-containerregistry/pkg/v1" | ||
"github.com/pkg/errors" | ||
|
||
"github.com/buildpack/pack/config" | ||
) | ||
|
||
//go:generate mockgen -package mocks -destination mocks/docker.go github.com/buildpack/pack Docker | ||
type Docker interface { | ||
PullImage(ref string) error | ||
RunContainer(ctx context.Context, id string, stdout io.Writer, stderr io.Writer) error | ||
VolumeRemove(ctx context.Context, volumeID string, force bool) error | ||
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) | ||
ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error | ||
CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options types.CopyToContainerOptions) error | ||
CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) | ||
ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) | ||
ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) | ||
} | ||
|
||
//go:generate mockgen -package mocks -destination mocks/images.go github.com/buildpack/pack Images | ||
type Images interface { | ||
ReadImage(repoName string, useDaemon bool) (v1.Image, error) | ||
RepoStore(repoName string, useDaemon bool) (img.Store, error) | ||
} | ||
|
||
//go:generate mockgen -package mocks -destination mocks/task.go github.com/buildpack/pack Task | ||
type Task interface { | ||
Run() error | ||
} | ||
|
||
//go:generate mockgen -package mocks -destination mocks/fs.go github.com/buildpack/pack FS | ||
type FS interface { | ||
CreateTGZFile(tarFile, srcDir, tarDir string, uid, gid int) error | ||
CreateTarReader(srcDir, tarDir string, uid, gid int) (io.Reader, chan error) | ||
Untar(r io.Reader, dest string) error | ||
CreateSingleFileTar(path, txt string) (io.Reader, error) | ||
} | ||
|
||
type WritableStore interface { | ||
Write(image v1.Image) error | ||
} | ||
|
||
type ImageFactory interface { | ||
NewLocal(string, bool) (image.Image, error) | ||
NewRemote(string) (image.Image, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters