Skip to content

Commit 80be6f7

Browse files
committed
fix: Better godocs
1 parent 86d3697 commit 80be6f7

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

pkg/config/parsing_context.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,16 @@ func (ctx *ParsingContext) WithIncrementedDepth() (*ParsingContext, error) {
224224
return c, nil
225225
}
226226

227-
// WithConfigPath returns a new ParsingContext with the config path updated.
228-
// It normalizes the path to an absolute path, updates WorkingDir to the directory
229-
// containing the config, and adjusts the logger's working directory field if it changed.
227+
// WithConfigPath returns a new ParsingContext targeting a different config file.
230228
//
231-
// OriginalTerragruntConfigPath is intentionally NOT updated — this is correct
232-
// when reading a config from another (e.g. read_terragrunt_config), where the
233-
// "original" caller should be preserved. For parsing a dependency as a standalone
234-
// unit, use WithDependencyConfigPath instead.
229+
// It normalizes configPath to an absolute path, sets TerragruntConfigPath and
230+
// WorkingDir accordingly, and updates the logger when the working directory changes.
231+
//
232+
// OriginalTerragruntConfigPath is preserved so that get_original_terragrunt_dir()
233+
// continues to resolve to the caller. This is the correct behavior when one config
234+
// reads another via read_terragrunt_config.
235+
//
236+
// To parse a dependency as an independent unit, use [ParsingContext.WithDependencyConfigPath].
235237
func (ctx *ParsingContext) WithConfigPath(l log.Logger, configPath string) (log.Logger, *ParsingContext, error) {
236238
configPath = filepath.Clean(configPath)
237239
if !filepath.IsAbs(configPath) {
@@ -252,9 +254,12 @@ func (ctx *ParsingContext) WithConfigPath(l log.Logger, configPath string) (log.
252254
}
253255

254256
// WithDependencyConfigPath returns a new ParsingContext for parsing a dependency
255-
// as a standalone unit. Unlike WithConfigPath, this also resets
256-
// OriginalTerragruntConfigPath so that get_original_terragrunt_dir() resolves
257-
// relative to the dependency, not the caller.
257+
// as an independent unit.
258+
//
259+
// It performs the same path and logger updates as [ParsingContext.WithConfigPath],
260+
// and additionally resets OriginalTerragruntConfigPath to the dependency's path.
261+
// This ensures that get_original_terragrunt_dir() resolves to the dependency's
262+
// own directory rather than the caller's.
258263
func (ctx *ParsingContext) WithDependencyConfigPath(l log.Logger, configPath string) (log.Logger, *ParsingContext, error) {
259264
l, c, err := ctx.WithConfigPath(l, configPath)
260265
if err != nil {

0 commit comments

Comments
 (0)