Also exposes shared cache and garbage collection/prune for the source data. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> Upstream-commit: 5c3d2d552b0430672d5f481ab2d37036f6e92166 Component: engine
30 lines
587 B
Go
30 lines
587 B
Go
package remotecontext
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/docker/docker/builder"
|
|
"github.com/docker/docker/builder/remotecontext/git"
|
|
"github.com/docker/docker/pkg/archive"
|
|
)
|
|
|
|
// MakeGitContext returns a Context from gitURL that is cloned in a temporary directory.
|
|
func MakeGitContext(gitURL string) (builder.Source, error) {
|
|
root, err := git.Clone(gitURL)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
c, err := archive.Tar(root, archive.Uncompressed)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
defer func() {
|
|
// TODO: print errors?
|
|
c.Close()
|
|
os.RemoveAll(root)
|
|
}()
|
|
return FromArchive(c)
|
|
}
|