File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,11 @@ func (s *State) children(path []string) []*ModuleState {
128128func (s * State ) AddModule (path []string ) * ModuleState {
129129 s .Lock ()
130130 defer s .Unlock ()
131+
132+ return s .addModule (path )
133+ }
134+
135+ func (s * State ) addModule (path []string ) * ModuleState {
131136 // check if the module exists first
132137 m := s .moduleByPath (path )
133138 if m != nil {
@@ -616,10 +621,10 @@ func (s *State) init() {
616621 if s .Version == 0 {
617622 s .Version = StateVersion
618623 }
619- if s .ModuleByPath (rootModulePath ) == nil {
620- s .AddModule (rootModulePath )
624+ if s .moduleByPath (rootModulePath ) == nil {
625+ s .addModule (rootModulePath )
621626 }
622- s .EnsureHasLineage ()
627+ s .ensureHasLineage ()
623628
624629 for _ , mod := range s .Modules {
625630 mod .init ()
@@ -634,6 +639,10 @@ func (s *State) EnsureHasLineage() {
634639 s .Lock ()
635640 defer s .Unlock ()
636641
642+ s .ensureHasLineage ()
643+ }
644+
645+ func (s * State ) ensureHasLineage () {
637646 if s .Lineage == "" {
638647 s .Lineage = uuid .NewV4 ().String ()
639648 log .Printf ("[DEBUG] New state was assigned lineage %q\n " , s .Lineage )
@@ -648,6 +657,10 @@ func (s *State) AddModuleState(mod *ModuleState) {
648657 s .Lock ()
649658 defer s .Unlock ()
650659
660+ s .addModuleState (mod )
661+ }
662+
663+ func (s * State ) addModuleState (mod * ModuleState ) {
651664 for i , m := range s .Modules {
652665 if reflect .DeepEqual (m .Path , mod .Path ) {
653666 s .Modules [i ] = mod
You can’t perform that action at this time.
0 commit comments