@ -21,21 +21,21 @@ const (
stateFormatVersion byte = 1
)
// StateV 1 is used to represent the state of Terraform files before
// StateV 0 is used to represent the state of Terraform files before
// 0.3. It is automatically upgraded to a modern State representation
// on start.
type StateV 1 struct {
type StateV 0 struct {
Outputs map [ string ] string
Resources map [ string ] * ResourceStateV 1
Resources map [ string ] * ResourceStateV 0
Tainted map [ string ] struct { }
once sync . Once
}
func ( s * StateV 1 ) init ( ) {
func ( s * StateV 0 ) init ( ) {
s . once . Do ( func ( ) {
if s . Resources == nil {
s . Resources = make ( map [ string ] * ResourceStateV 1 )
s . Resources = make ( map [ string ] * ResourceStateV 0 )
}
if s . Tainted == nil {
@ -44,8 +44,8 @@ func (s *StateV1) init() {
} )
}
func ( s * StateV 1) deepcopy ( ) * StateV1 {
result := new ( StateV 1 )
func ( s * StateV 0) deepcopy ( ) * StateV0 {
result := new ( StateV 0 )
result . init ( )
if s != nil {
for k , v := range s . Resources {
@ -61,7 +61,7 @@ func (s *StateV1) deepcopy() *StateV1 {
// prune is a helper that removes any empty IDs from the state
// and cleans it up in general.
func ( s * StateV 1 ) prune ( ) {
func ( s * StateV 0 ) prune ( ) {
for k , v := range s . Resources {
if v . ID == "" {
delete ( s . Resources , k )
@ -72,7 +72,7 @@ func (s *StateV1) prune() {
// Orphans returns a list of keys of resources that are in the State
// but aren't present in the configuration itself. Hence, these keys
// represent the state of resources that are orphans.
func ( s * StateV 1 ) Orphans ( c * config . Config ) [ ] string {
func ( s * StateV 0 ) Orphans ( c * config . Config ) [ ] string {
keys := make ( map [ string ] struct { } )
for k , _ := range s . Resources {
keys [ k ] = struct { } { }
@ -96,7 +96,7 @@ func (s *StateV1) Orphans(c *config.Config) []string {
return result
}
func ( s * StateV 1 ) String ( ) string {
func ( s * StateV 0 ) String ( ) string {
if len ( s . Resources ) == 0 {
return "<no state>"
}
@ -175,7 +175,7 @@ func (s *StateV1) String() string {
//
// Extra is just extra data that a provider can return that we store
// for later, but is not exposed in any way to the user.
type ResourceStateV 1 struct {
type ResourceStateV 0 struct {
// This is filled in and managed by Terraform, and is the resource
// type itself such as "mycloud_instance". If a resource provider sets
// this value, it won't be persisted.
@ -228,8 +228,8 @@ type ResourceStateV1 struct {
// If the diff attribute requires computing the value, and hence
// won't be available until apply, the value is replaced with the
// computeID.
func ( s * ResourceStateV 1 ) MergeDiff ( d * InstanceDiff ) * ResourceStateV 1 {
var result ResourceStateV 1
func ( s * ResourceStateV 0 ) MergeDiff ( d * InstanceDiff ) * ResourceStateV 0 {
var result ResourceStateV 0
if s != nil {
result = * s
}
@ -258,7 +258,7 @@ func (s *ResourceStateV1) MergeDiff(d *InstanceDiff) *ResourceStateV1 {
return & result
}
func ( s * ResourceStateV 1 ) GoString ( ) string {
func ( s * ResourceStateV 0 ) GoString ( ) string {
return fmt . Sprintf ( "*%#v" , * s )
}
@ -270,10 +270,10 @@ type ResourceDependency struct {
ID string
}
// ReadStateV 1 reads a state structure out of a reader in the format that
// ReadStateV 0 reads a state structure out of a reader in the format that
// was written by WriteState.
func ReadStateV 1( src io . Reader ) ( * StateV1 , error ) {
var result * StateV 1
func ReadStateV 0( src io . Reader ) ( * StateV0 , error ) {
var result * StateV 0
var err error
n := 0