{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package builder\n\nPackage builder defines interfaces for any Docker builder to implement.\n\nHistorically, only server-side Dockerfile interpreters existed. This package allows for other implementations of Docker builders.\n\n## Types\n\n```go\ntype Backend interface {\n\n\t// GetImage looks up a Docker image referenced by `name`.\n\tGetImageOnBuild(name string) (Image, error)\n\t// Tag an image with newTag\n\tTagImage(newTag reference.Named, imageName string) error\n\t// Pull tells Docker to pull image referenced by `name`.\n\tPullOnBuild(name string, authConfigs map[string]types.AuthConfig, output io.Writer) (Image, error)\n\t// ContainerAttach attaches to container.\n\tContainerAttachOnBuild(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error\n\t// ContainerCreate creates a new Docker container and returns potential warnings\n\tContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error)\n\t// ContainerRm removes a container specified by `id`.\n\tContainerRm(name string, config *types.ContainerRmConfig) error\n\t// Commit creates a new Docker image from an existing Docker container.\n\tCommit(string, *types.ContainerCommitConfig) (string, error)\n\t// Kill stops the container execution abruptly.\n\tContainerKill(containerID string, sig uint64) error\n\t// Start starts a new container\n\tContainerStart(containerID string, hostConfig *container.HostConfig) error\n\t// ContainerWait stops processing until the given container is stopped.\n\tContainerWait(containerID string, timeout time.Duration) (int, error)\n\t// ContainerUpdateCmd updates container.Path and container.Args\n\tContainerUpdateCmdOnBuild(containerID string, cmd []string) error\n\n\t// ContainerCopy copies/extracts a source FileInfo to a destination path inside a container\n\t// specified by a container object.\n\t// TODO: make an Extract method instead of passing `decompress`\n\t// TODO: do not pass a FileInfo, instead refactor the archive package to export a Walk function that can be used\n\t// with Context.Walk\n\t//ContainerCopy(name string, res string) (io.ReadCloser, error)\n\t// TODO: use copyBackend api\n\tCopyOnBuild(containerID string, destPath string, src FileInfo, decompress bool) error\n}\n```\nBackend abstracts calls to a Docker Daemon.\n\n```go\ntype Context interface {\n\t// Close allows to signal that the filesystem tree won't be used anymore.\n\t// For Context implementations using a temporary directory, it is recommended to\n\t// delete the temporary directory in Close().\n\tClose() error\n\t// Stat returns an entry corresponding to path if any.\n\t// It is recommended to return an error if path was not found.\n\t// If path is a symlink it also returns the path to the target file.\n\tStat(path string) (string, FileInfo, error)\n\t// Open opens path from the context and returns a readable stream of it.\n\tOpen(path string) (io.ReadCloser, error)\n\t// Walk walks the tree of the context with the function passed to it.\n\tWalk(root string, walkFn WalkFunc) error\n}\n```\nContext represents a file system tree.\n\n```go\ntype DockerIgnoreContext struct {\n\tModifiableContext\n}\n```\nDockerIgnoreContext wraps a ModifiableContext to add a method for handling the .dockerignore file at the root of the context.\n\n```go\nfunc (c DockerIgnoreContext) Process(filesToRemove []string) error\n```\nProcess reads the .dockerignore file at the root of the embedded context. If .dockerignore does not exist in the context, then nil is returned.\n\nIt can take a list of files to be removed after .dockerignore is removed. This is used for server-side implementations of builders that need to send the .dockerignore file as well as the special files specified in filesToRemove, but expect them to be excluded from the context after they were processed.\n\nFor example, server-side Dockerfile builders are expected to pass in the name of the Dockerfile to be removed after it was parsed.\n\nTODO: Don't require a ModifiableContext (use Context instead) and don't remove files, instead handle a list of files to be excluded from the context.\n\n```go\ntype FileInfo interface {\n\tos.FileInfo\n\tPath() string\n}\n```\nFileInfo extends os.FileInfo to allow retrieving an absolute path to the file. TODO: remove this interface once pkg/archive exposes a walk function that Context can use.\n\n```go\ntype Hashed interface {\n\t// Hash returns the hash of a file.\n\tHash() string\n\tSetHash(string)\n}\n```\nHashed defines an extra method intended for implementations of os.FileInfo.\n\n```go\ntype HashedFileInfo struct {\n\tFileInfo\n\t// FileHash represents the hash of a file.\n\tFileHash string\n}\n```\nHashedFileInfo is a convenient struct that augments FileInfo with a field.\n\n```go\nfunc (fi HashedFileInfo) Hash() string\n```\nHash returns the hash of a file.\n\n```go\nfunc (fi *HashedFileInfo) SetHash(h string)\n```\nSetHash sets the hash of a file.\n\n```go\ntype Image interface {\n\tImageID() string\n\tRunConfig() *container.Config\n}\n```\nImage represents a Docker image used by the builder.\n\n```go\ntype ImageCache interface {\n\t// GetCachedImage returns a reference to a cached image whose parent equals `parent`\n\t// and runconfig equals `cfg`. A cache miss is expected to return an empty ID and a nil error.\n\tGetCachedImageOnBuild(parentID string, cfg *container.Config) (imageID string, err error)\n}\n```\nImageCache abstracts an image cache store. (parent image, child runconfig) -\u003e child image\n\n```go\ntype ModifiableContext interface {\n\tContext\n\t// Remove deletes the entry specified by `path`.\n\t// It is usual for directory entries to delete all its subentries.\n\tRemove(path string) error\n}\n```\nModifiableContext represents a modifiable Context. TODO: remove this interface once we can get rid of Remove()\n\n```go\nfunc DetectContextFromRemoteURL(r io.ReadCloser, remoteURL string, createProgressReader func(in io.ReadCloser) io.ReadCloser) (context ModifiableContext, dockerfileName string, err error)\n```\nDetectContextFromRemoteURL returns a context and in certain cases the name of the dockerfile to be used irrespective of user input. progressReader is only used if remoteURL is actually a URL (not empty, and not a Git endpoint).\n\n```go\nfunc MakeGitContext(gitURL string) (ModifiableContext, error)\n```\nMakeGitContext returns a Context from gitURL that is cloned in a temporary directory.\n\n```go\nfunc MakeRemoteContext(remoteURL string, contentTypeHandlers map[string]func(io.ReadCloser) (io.ReadCloser, error)) (ModifiableContext, error)\n```\nMakeRemoteContext downloads a context from remoteURL and returns it.\n\nIf contentTypeHandlers is non-nil, then the Content-Type header is read along with a maximum of maxPreambleLength bytes from the body to help detecting the MIME type. Look at acceptableRemoteMIME for more details.\n\nIf a match is found, then the body is sent to the contentType handler and a (potentially compressed) tar stream is expected to be returned. If no match is found, it is assumed the body is a tar stream (compressed or not). In either case, an (assumed) tar stream is passed to MakeTarSumContext whose result is returned.\n\n```go\nfunc MakeTarSumContext(tarStream io.Reader) (ModifiableContext, error)\n```\nMakeTarSumContext returns a build Context from a tar stream.\n\nIt extracts the tar stream to a temporary folder that is deleted as soon as the Context is closed. As the extraction happens, a tarsum is calculated for every file, and the set of all those sums then becomes the source of truth for all operations on this Context.\n\nClosing tarStream has to be done by the caller.\n\n```go\ntype PathFileInfo struct {\n\tos.FileInfo\n\t// FilePath holds the absolute path to the file.\n\tFilePath string\n\t// Name holds the basename for the file.\n\tFileName string\n}\n```\nPathFileInfo is a convenience struct that implements the FileInfo interface.\n\n```go\nfunc (fi PathFileInfo) Name() string\n```\nName returns the basename of the file.\n\n```go\nfunc (fi PathFileInfo) Path() string\n```\nPath returns the absolute path to the file.\n\n```go\ntype WalkFunc func(path string, fi FileInfo, err error) error\n```\nWalkFunc is the type of the function called for each file or directory visited by Context.Walk().\n\n","path":"github.com/hyperhq/hypercli/builder","name":"builder","synopsis":"Package builder defines interfaces for any Docker builder to implement.","isRedistributable":true}
