From ca8e2085f3d99ececcbf68d8776db951b1353c11 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 5 Mar 2015 12:37:13 -0800 Subject: [PATCH] command/push: archiving --- command/push.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/command/push.go b/command/push.go index dbc4989910..cee61b7f6f 100644 --- a/command/push.go +++ b/command/push.go @@ -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 }