command/push: archiving

This commit is contained in:
Mitchell Hashimoto 2015-03-05 12:37:13 -08:00
parent c4dc9af120
commit ca8e2085f3

View File

@ -4,7 +4,10 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/hashicorp/atlas-go/archive"
)
type PushCommand struct {
@ -76,6 +79,27 @@ func (c *PushCommand) Run(args []string) int {
return 1
}
// Build the archiving options, which includes everything it can
// by default according to VCS rules but forcing the data directory.
archiveOpts := &archive.ArchiveOpts{
Include: []string{filepath.Join(c.DataDir())},
VCS: true,
}
if !moduleLock {
// If we're not locking modules, then exclude the modules dir.
archiveOpts.Exclude = append(
archiveOpts.Exclude,
filepath.Join(c.DataDir(), "modules"))
}
_, err = archive.CreateArchive(configPath, archiveOpts)
if err != nil {
c.Ui.Error(fmt.Sprintf(
"An error has occurred while archiving the module for uploading:\n"+
"%s", err))
return 1
}
return 0
}