git.go 546 B

12345678910111213141516171819202122232425262728
  1. package builder
  2. import (
  3. "os"
  4. "github.com/docker/docker/pkg/archive"
  5. "github.com/docker/docker/pkg/gitutils"
  6. )
  7. // MakeGitContext returns a Context from gitURL that is cloned in a temporary directory.
  8. func MakeGitContext(gitURL string) (ModifiableContext, error) {
  9. root, err := gitutils.Clone(gitURL)
  10. if err != nil {
  11. return nil, err
  12. }
  13. c, err := archive.Tar(root, archive.Uncompressed)
  14. if err != nil {
  15. return nil, err
  16. }
  17. defer func() {
  18. // TODO: print errors?
  19. c.Close()
  20. os.RemoveAll(root)
  21. }()
  22. return MakeTarSumContext(c)
  23. }