Commit Graph

4 Commits

Author SHA1 Message Date
Lars Lehtonen 822a98a0b4
Fix swallowed tests in terraform package tests 2017-07-20 02:23:43 -07:00
James Bardin cdb80f68a8 Ensure better state normalization
Fix checksum issue with remote state

If we read a state file with "null" objects in a module and they become
initialized to an empty map the state file may be written out with empty
objects rather than "null", changing the checksum. If we can detect
this, increment the serial number to prevent a conflict in atlas.

Our fakeAtlas test server now needs to decode the state directly rather
than using the ReadState function, so as to be able to read the state
unaltered.

The terraform.State data structures have initialization spread out
throughout the package. More thoroughly initialize State during
ReadState, and add a call to init() during WriteState as another
normalization safeguard.

Expose State.init through an exported Init() method, so that a new State
can be completely realized outside of the terraform package.
Additionally, the internal init now completely walks all internal state
structures ensuring that all maps and slices are initialized.  While it
was mentioned before that the `init()` methods are problematic with too
many call sites, expanding this out better exposes the entry points that
will need to be refactored later for improved concurrency handling.

The State structures had a mix of `omitempty` fields. Remove omitempty
for all maps and slices as part of this normalization process. Make
Lineage mandatory, which is now explicitly set in some tests.
2016-08-12 11:09:50 -04:00
James Bardin 1b75c51ed7 Don't nil module maps during state upgrade
The Outputs and Resources maps in the state modules are expected to be
non-nil, and initialized that way when a new module is added to the
state.  The V1->V2 upgrade was setting the maps to nil if the len == 0.
2016-06-29 09:17:25 -04:00
James Nugent 9554d54116 core: Add test for V2->V3 state upgrade 2016-06-09 11:16:34 +01:00