command/push: create the proper parent directory entries in tar
This commit is contained in:
parent
928fdff33e
commit
9a8209cfbd
|
@ -203,8 +203,10 @@ func (c *PushCommand) Run(args []string) int {
|
||||||
// Build the archiving options, which includes everything it can
|
// Build the archiving options, which includes everything it can
|
||||||
// by default according to VCS rules but forcing the data directory.
|
// by default according to VCS rules but forcing the data directory.
|
||||||
archiveOpts := &archive.ArchiveOpts{
|
archiveOpts := &archive.ArchiveOpts{
|
||||||
VCS: archiveVCS,
|
VCS: archiveVCS,
|
||||||
Extra: make(map[string]string),
|
Extra: map[string]string{
|
||||||
|
DefaultDataDir: archive.ExtraEntryDir,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always store the state file in here so we can find state
|
// Always store the state file in here so we can find state
|
||||||
|
|
|
@ -117,6 +117,7 @@ func TestPush_noUploadModules(t *testing.T) {
|
||||||
|
|
||||||
actual := testArchiveStr(t, archivePath)
|
actual := testArchiveStr(t, archivePath)
|
||||||
expected := []string{
|
expected := []string{
|
||||||
|
".terraform/",
|
||||||
".terraform/terraform.tfstate",
|
".terraform/terraform.tfstate",
|
||||||
"child/",
|
"child/",
|
||||||
"child/main.tf",
|
"child/main.tf",
|
||||||
|
|
|
@ -50,6 +50,12 @@ func (o *ArchiveOpts) IsSet() bool {
|
||||||
return len(o.Exclude) > 0 || len(o.Include) > 0 || o.VCS
|
return len(o.Exclude) > 0 || len(o.Include) > 0 || o.VCS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constants related to setting special values for Extra in ArchiveOpts.
|
||||||
|
const (
|
||||||
|
// ExtraEntryDir just creates the Extra key as a directory entry.
|
||||||
|
ExtraEntryDir = ""
|
||||||
|
)
|
||||||
|
|
||||||
// CreateArchive takes the given path and ArchiveOpts and archives it.
|
// CreateArchive takes the given path and ArchiveOpts and archives it.
|
||||||
//
|
//
|
||||||
// The archive will be fully completed and put into a temporary file.
|
// The archive will be fully completed and put into a temporary file.
|
||||||
|
@ -419,7 +425,29 @@ func copyConcreteEntry(
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyExtras(w *tar.Writer, extra map[string]string) error {
|
func copyExtras(w *tar.Writer, extra map[string]string) error {
|
||||||
|
var tmpDir string
|
||||||
|
defer func() {
|
||||||
|
if tmpDir != "" {
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for entry, path := range extra {
|
for entry, path := range extra {
|
||||||
|
// If the path is empty, then we set it to a generic empty directory
|
||||||
|
if path == "" {
|
||||||
|
// If tmpDir is still empty, then we create an empty dir
|
||||||
|
if tmpDir == "" {
|
||||||
|
td, err := ioutil.TempDir("", "archive")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpDir = td
|
||||||
|
}
|
||||||
|
|
||||||
|
path = tmpDir
|
||||||
|
}
|
||||||
|
|
||||||
info, err := os.Stat(path)
|
info, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1083,9 +1083,11 @@
|
||||||
"revision": "c0cf0cb802adad24252ce1307c4c896edd566870"
|
"revision": "c0cf0cb802adad24252ce1307c4c896edd566870"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"checksumSHA1": "FUiF2WLrih0JdHsUTMMDz3DRokw=",
|
||||||
"comment": "20141209094003-92-g95fa852",
|
"comment": "20141209094003-92-g95fa852",
|
||||||
"path": "github.com/hashicorp/atlas-go/archive",
|
"path": "github.com/hashicorp/atlas-go/archive",
|
||||||
"revision": "95fa852edca41c06c4ce526af4bb7dec4eaad434"
|
"revision": "8e45a6c8b2de014db767a42c3ee777f101e11624",
|
||||||
|
"revisionTime": "2016-08-24T17:34:10Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "yylO3hSRKd0T4mveT9ho2OSARwU=",
|
"checksumSHA1": "yylO3hSRKd0T4mveT9ho2OSARwU=",
|
||||||
|
|
Loading…
Reference in New Issue