command/push: only explicitly include the state

modify the module include flag to flag whether we explicitly include or
exclude modules
This commit is contained in:
Mitchell Hashimoto 2016-08-23 23:12:52 -07:00
parent 3aecc52bf3
commit a650455ed6
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 14 additions and 20 deletions

View File

@ -204,19 +204,23 @@ func (c *PushCommand) Run(args []string) int {
// by default according to VCS rules but forcing the data directory.
archiveOpts := &archive.ArchiveOpts{
VCS: archiveVCS,
Extra: map[string]string{
DefaultDataDir: dataDirAbs,
},
Extra: make(map[string]string),
}
if !moduleUpload {
// If we're not uploading modules, then exclude the modules dir.
// Always store the state file in here so we can find state
statePathKey := fmt.Sprintf("%s/%s", DefaultDataDir, DefaultStateFilename)
archiveOpts.Extra[statePathKey] = filepath.Join(dataDirAbs, DefaultStateFilename)
if moduleUpload {
// If we're uploading modules, explicitly add that
moduleKey := fmt.Sprintf("%s/%s", DefaultDataDir, "modules")
archiveOpts.Extra[moduleKey] = filepath.Join(dataDirAbs, "modules")
} else {
// If we're not uploading modules, explicitly exclude add that
archiveOpts.Exclude = append(
archiveOpts.Exclude,
filepath.Join(c.DataDir(), "modules"))
}
println(fmt.Sprintf("%#v", archiveOpts))
archiveR, err := archive.CreateArchive(configPath, archiveOpts)
if err != nil {
c.Ui.Error(fmt.Sprintf(
@ -225,16 +229,6 @@ func (c *PushCommand) Run(args []string) int {
return 1
}
/*
f, err := os.Create("ARCHIVE.tar.gz")
if err != nil {
panic(err)
}
io.Copy(f, archiveR)
f.Close()
return 12
*/
// List of the vars we're uploading to display to the user.
// We always upload all vars from atlas, but only report them if they are overwritten.
var setVars []string

View File

@ -117,9 +117,9 @@ func TestPush_noUploadModules(t *testing.T) {
actual := testArchiveStr(t, archivePath)
expected := []string{
".gitignore",
".terraform/",
".terraform/terraform.tfstate",
"child/",
"child/main.tf",
"main.tf",
}
if !reflect.DeepEqual(actual, expected) {