From 73f7c0415967c36e3386d690f8fe311491510556 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 24 Aug 2016 18:44:54 -0700 Subject: [PATCH] terraform: clear docs for devs --- terraform/state.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/terraform/state.go b/terraform/state.go index 5d77f60d04..155e4af269 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -254,6 +254,14 @@ func (s *State) IsRemote() bool { func (s *State) Validate() error { var result error + // !!!! FOR DEVELOPERS !!!! + // + // Any errors returned from this Validate function will BLOCK TERRAFORM + // from loading a state file. Therefore, this should only contain checks + // that are only resolvable through manual intervention. + // + // !!!! FOR DEVELOPERS !!!! + // Make sure there are no duplicate module states. We open a new // block here so we can use basic variable names and future validations // can do the same. @@ -1607,6 +1615,11 @@ func ReadState(src io.Reader) (*State, error) { panic("resulting state in load not set, assertion failed") } + // Validate the state file is valid + if err := result.Validate(); err != nil { + return nil, err + } + return result, nil }