@@ -387,7 +387,7 @@ func String(c *component.Component) string {
387387// ContainsDependencyInAncestry returns true if the Component or any of 
388388// its dependencies contains the given path as a dependency. 
389389func  ContainsDependencyInAncestry (c  * component.Component , path  string ) bool  {
390- 	for  _ , dep  :=  range  c .Dependencies  {
390+ 	for  _ , dep  :=  range  c .Dependencies ()  {
391391		if  dep .Path  ==  path  {
392392			return  true 
393393		}
@@ -965,7 +965,7 @@ func (d *Discovery) Discover(
965965				l .Debugf ("Errors: %w" , err )
966966			}
967967
968- 			components  =  dependencyDiscovery .cfgs 
968+ 			components  =  dependencyDiscovery .components 
969969
970970			return  nil 
971971		})
@@ -1017,7 +1017,7 @@ func (d *Discovery) Discover(
10171017// DependencyDiscovery is the configuration for a DependencyDiscovery. 
10181018type  DependencyDiscovery  struct  {
10191019	discoveryContext     * component.DiscoveryContext 
1020- 	cfgs                  component.Components 
1020+ 	components           component.Components 
10211021	parserOptions        []hclparse.Option 
10221022	depthRemaining       int 
10231023	discoverExternal     bool 
@@ -1028,9 +1028,9 @@ type DependencyDiscovery struct {
10281028// DependencyDiscoveryOption is a function that modifies a DependencyDiscovery. 
10291029type  DependencyDiscoveryOption  func (* DependencyDiscovery )
10301030
1031- func  NewDependencyDiscovery (cfgs  component.Components , depthRemaining  int ) * DependencyDiscovery  {
1031+ func  NewDependencyDiscovery (components  component.Components , depthRemaining  int ) * DependencyDiscovery  {
10321032	return  & DependencyDiscovery {
1033- 		cfgs :            cfgs ,
1033+ 		components :     components ,
10341034		depthRemaining : depthRemaining ,
10351035	}
10361036}
@@ -1070,7 +1070,7 @@ func (d *DependencyDiscovery) WithDiscoveryContext(discoveryContext *component.D
10701070func  (d  * DependencyDiscovery ) DiscoverAllDependencies (ctx  context.Context , l  log.Logger , opts  * options.TerragruntOptions ) error  {
10711071	errs  :=  []error {}
10721072
1073- 	for  _ , cfg  :=  range  d .cfgs  {
1073+ 	for  _ , cfg  :=  range  d .components  {
10741074		if  cfg .Kind  ==  component .Stack  {
10751075			continue 
10761076		}
@@ -1088,7 +1088,12 @@ func (d *DependencyDiscovery) DiscoverAllDependencies(ctx context.Context, l log
10881088	return  nil 
10891089}
10901090
1091- func  (d  * DependencyDiscovery ) DiscoverDependencies (ctx  context.Context , l  log.Logger , opts  * options.TerragruntOptions , dCfg  * component.Component ) error  {
1091+ func  (d  * DependencyDiscovery ) DiscoverDependencies (
1092+ 	ctx  context.Context ,
1093+ 	l  log.Logger ,
1094+ 	opts  * options.TerragruntOptions ,
1095+ 	dComponent  * component.Component ,
1096+ ) error  {
10921097	if  d .depthRemaining  <=  0  {
10931098		return  errors .New ("max dependency depth reached while discovering dependencies" )
10941099	}
@@ -1099,19 +1104,19 @@ func (d *DependencyDiscovery) DiscoverDependencies(ctx context.Context, l log.Lo
10991104
11001105	// Stack configs don't have dependencies (at least for now), 
11011106	// so we can return early. 
1102- 	if  dCfg .Kind  ==  component .Stack  {
1107+ 	if  dComponent .Kind  ==  component .Stack  {
11031108		return  nil 
11041109	}
11051110
11061111	// This should only happen if we're discovering an ancestor dependency. 
1107- 	if  dCfg .Parsed  ==  nil  {
1108- 		err  :=  Parse (dCfg , ctx , l , opts , d .suppressParseErrors , d .parserOptions )
1112+ 	if  dComponent .Parsed  ==  nil  {
1113+ 		err  :=  Parse (dComponent , ctx , l , opts , d .suppressParseErrors , d .parserOptions )
11091114		if  err  !=  nil  {
11101115			return  errors .New (err )
11111116		}
11121117	}
11131118
1114- 	dependencyBlocks  :=  dCfg .Parsed .TerragruntDependencies 
1119+ 	dependencyBlocks  :=  dComponent .Parsed .TerragruntDependencies 
11151120
11161121	depPaths  :=  make ([]string , 0 , len (dependencyBlocks ))
11171122
@@ -1127,16 +1132,16 @@ func (d *DependencyDiscovery) DiscoverDependencies(ctx context.Context, l log.Lo
11271132		depPath  :=  dependency .ConfigPath .AsString ()
11281133
11291134		if  ! filepath .IsAbs (depPath ) {
1130- 			depPath  =  filepath .Join (dCfg .Path , depPath )
1135+ 			depPath  =  filepath .Join (dComponent .Path , depPath )
11311136		}
11321137
11331138		depPaths  =  append (depPaths , depPath )
11341139	}
11351140
1136- 	if  dCfg .Parsed .Dependencies  !=  nil  {
1137- 		for  _ , dependency  :=  range  dCfg .Parsed .Dependencies .Paths  {
1141+ 	if  dComponent .Parsed .Dependencies  !=  nil  {
1142+ 		for  _ , dependency  :=  range  dComponent .Parsed .Dependencies .Paths  {
11381143			if  ! filepath .IsAbs (dependency ) {
1139- 				dependency  =  filepath .Join (dCfg .Path , dependency )
1144+ 				dependency  =  filepath .Join (dComponent .Path , dependency )
11401145			}
11411146
11421147			depPaths  =  append (depPaths , dependency )
@@ -1160,11 +1165,11 @@ func (d *DependencyDiscovery) DiscoverDependencies(ctx context.Context, l log.Lo
11601165	for  depPath  :=  range  deduped  {
11611166		external  :=  true 
11621167
1163- 		for  _ , c  :=  range  d .cfgs  {
1168+ 		for  _ , c  :=  range  d .components  {
11641169			if  c .Path  ==  depPath  {
11651170				external  =  false 
11661171
1167- 				dCfg . Dependencies   =   append ( dCfg . Dependencies ,  c )
1172+ 				dComponent . AddDependency ( c )
11681173
11691174				continue 
11701175			}
@@ -1186,10 +1191,10 @@ func (d *DependencyDiscovery) DiscoverDependencies(ctx context.Context, l log.Lo
11861191				ext .DiscoveryContext  =  d .discoveryContext 
11871192			}
11881193
1189- 			dCfg . Dependencies   =   append ( dCfg . Dependencies ,  ext )
1194+ 			dComponent . AddDependency ( ext )
11901195
11911196			if  d .discoverExternal  {
1192- 				d .cfgs  =  append (d .cfgs , ext )
1197+ 				d .components  =  append (d .components , ext )
11931198
11941199				err  :=  d .DiscoverDependencies (ctx , l , opts , ext )
11951200				if  err  !=  nil  {
0 commit comments