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:
parent
3aecc52bf3
commit
a650455ed6
|
@ -203,20 +203,24 @@ func (c *PushCommand) Run(args []string) int {
|
|||
// Build the archiving options, which includes everything it can
|
||||
// by default according to VCS rules but forcing the data directory.
|
||||
archiveOpts := &archive.ArchiveOpts{
|
||||
VCS: archiveVCS,
|
||||
Extra: map[string]string{
|
||||
DefaultDataDir: dataDirAbs,
|
||||
},
|
||||
VCS: archiveVCS,
|
||||
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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue