Skip to content

Commit

Permalink
terraform: sort dependencies of resource state [GH-928]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Feb 17, 2015
1 parent 1752c93 commit c2f3f05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ BUG FIXES:
* core: Fix crash that could occur when there are exactly zero providers
installed on a system. [GH-786]
* core: JSON TF configurations can configure provisioners. [GH-807]
* core: Sort `depends_on` in state to prevent unnecessary file changes. [GH-928]
* command/apply: Won't try to initialize modules in some cases when
no arguments are given. [GH-780]
* command/apply: Fix regression where user variables weren't asked [GH-736]
Expand Down
15 changes: 15 additions & 0 deletions terraform/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ func (s *State) prune() {
// sort sorts the modules
func (s *State) sort() {
sort.Sort(moduleStateSort(s.Modules))

// Allow modules to be sorted
for _, m := range s.Modules {
m.sort()
}
}

func (s *State) GoString() string {
Expand Down Expand Up @@ -347,6 +352,12 @@ func (m *ModuleState) prune() {
}
}

func (m *ModuleState) sort() {
for _, v := range m.Resources {
v.sort()
}
}

func (m *ModuleState) GoString() string {
return fmt.Sprintf("*%#v", *m)
}
Expand Down Expand Up @@ -515,6 +526,10 @@ func (r *ResourceState) prune() {
r.Tainted = r.Tainted[:n]
}

func (r *ResourceState) sort() {
sort.Strings(r.Dependencies)
}

func (s *ResourceState) GoString() string {
return fmt.Sprintf("*%#v", *s)
}
Expand Down

1 comment on commit c2f3f05

@phinze
Copy link
Contributor

@phinze phinze commented on c2f3f05 Feb 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.