From 6ce957d4b1aca69619bbb88a614634edd4264aad Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 30 Sep 2014 15:39:24 -0700 Subject: [PATCH] terraform: State helpers --- terraform/state.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/terraform/state.go b/terraform/state.go index ac7269bc2..86a164a89 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -42,6 +42,13 @@ type State struct { Modules []*ModuleState `json:"modules"` } +// NewState is used to initialize a blank state +func NewState() *State { + s := &State{} + s.init() + return s +} + // Children returns the ModuleStates that are direct children of // the given path. If the path is "root", for example, then children // returned might be "root.child", but not "root.child.grandchild". @@ -204,6 +211,19 @@ func (r *RemoteState) Empty() bool { return (r.Name == "" && r.Server == "" && r.AuthToken == "") } +func (r *RemoteState) Equals(other *RemoteState) bool { + if r.Name != other.Name { + return false + } + if r.Server != other.Server { + return false + } + if r.AuthToken != other.AuthToken { + return false + } + return true +} + // ModuleState is used to track all the state relevant to a single // module. Previous to Terraform 0.3, all state belonged to the "root" // module.