command/push: archiving
This commit is contained in:
parent
c4dc9af120
commit
ca8e2085f3
|
@ -4,7 +4,10 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/atlas-go/archive"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PushCommand struct {
|
type PushCommand struct {
|
||||||
|
@ -76,6 +79,27 @@ func (c *PushCommand) Run(args []string) int {
|
||||||
return 1
|
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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue