2017-03-20 18:22:29 -04:00
|
|
|
package remotecontext
|
2015-09-06 13:26:40 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2017-03-20 18:22:29 -04:00
|
|
|
"github.com/docker/docker/builder"
|
2015-09-06 13:26:40 -04:00
|
|
|
"github.com/docker/docker/pkg/archive"
|
2015-12-14 05:17:51 -05:00
|
|
|
"github.com/docker/docker/pkg/gitutils"
|
2015-09-06 13:26:40 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// MakeGitContext returns a Context from gitURL that is cloned in a temporary directory.
|
2017-03-20 18:22:29 -04:00
|
|
|
func MakeGitContext(gitURL string) (builder.Source, error) {
|
2015-12-14 05:17:51 -05:00
|
|
|
root, err := gitutils.Clone(gitURL)
|
2015-09-06 13:26:40 -04:00
|
|
|
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 MakeTarSumContext(c)
|
|
|
|
}
|