Skip to content

Commit 8d76059

Browse files
committed
Refactor handling of import paths in ProcessImportSection
1 parent 362e979 commit 8d76059

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/exec/stack_processor_utils.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,10 +1744,10 @@ func FindComponentDependenciesLegacy(
17441744
}
17451745

17461746
// ProcessImportSection processes the `import` section in stack manifests
1747-
// The `import` section` can be of the following types:
1748-
// 1. list of `StackImport` structs
1749-
// 2. list of strings
1750-
// 3. List of strings and `StackImport` structs in the same file
1747+
// The `import` section can contain:
1748+
// 1. Project-relative paths (e.g. "mixins/region/us-east-2")
1749+
// 2. Paths relative to the current file (starting with "./" or "../")
1750+
// 3. StackImport structs containing either of the above path types
17511751
func ProcessImportSection(stackMap map[string]any, filePath string) ([]schema.StackImport, error) {
17521752
stackImports, ok := stackMap[cfg.ImportSectionName]
17531753

@@ -1773,7 +1773,7 @@ func ProcessImportSection(stackMap map[string]any, filePath string) ([]schema.St
17731773
var importObj schema.StackImport
17741774
err := mapstructure.Decode(imp, &importObj)
17751775
if err == nil {
1776-
// Handle relative paths in StackImport.Path
1776+
// Handle paths relative to current file (starting with ./ or ../)
17771777
if strings.HasPrefix(importObj.Path, "./") || strings.HasPrefix(importObj.Path, "../") {
17781778
// Get the directory of the current file
17791779
baseDir := filepath.Dir(filePath)
@@ -1795,7 +1795,7 @@ func ProcessImportSection(stackMap map[string]any, filePath string) ([]schema.St
17951795
return nil, fmt.Errorf("invalid empty import in the file '%s'", filePath)
17961796
}
17971797

1798-
// Handle relative paths in string imports
1798+
// Handle paths relative to current file (starting with ./ or ../)
17991799
if strings.HasPrefix(s, "./") || strings.HasPrefix(s, "../") {
18001800
baseDir := filepath.Dir(filePath)
18011801
s = filepath.Join(baseDir, s)

0 commit comments

Comments
 (0)