From 06b130fee8f05d52dc37fb0511a77df6ca4a3f06 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 4 Feb 2025 14:26:38 +0000 Subject: [PATCH] make comment more sensible Signed-off-by: Austin Abro --- src/internal/packager2/layout/import.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/internal/packager2/layout/import.go b/src/internal/packager2/layout/import.go index 6735e8cdf0..ffe997591b 100644 --- a/src/internal/packager2/layout/import.go +++ b/src/internal/packager2/layout/import.go @@ -31,11 +31,11 @@ func getComponentToImportName(component v1alpha1.ZarfComponent) string { } func resolveImports(ctx context.Context, pkg v1alpha1.ZarfPackage, packagePath, arch, flavor string, importStack []string) (v1alpha1.ZarfPackage, error) { - // The oddity of Zarf imports, is that imports take in top level package objects such as - // variables and constants, but are defined at the component level. - // this means two packages can import each other without creating a cyclic dependency. - // To detect cyclic imports, the package is checked to see if it's been imported on that chain of the recursion stack - // Additionally recursive calls only include components in the pkg that can be imported. + // Zarf imports merge in the top level package objects variables and constants + // however, imports are defined at the component level. + // Two packages can both import one another as long as the importing component is on a different chain. + // To detect cyclic imports, the stack is checked to see if the package has already been imported on that chain. + // Recursive calls only include components from the imported pkg that have the name of the component to import importStack = append(importStack, packagePath) variables := pkg.Variables @@ -73,7 +73,6 @@ func resolveImports(ctx context.Context, pkg v1alpha1.ZarfPackage, packagePath, if err != nil { return v1alpha1.ZarfPackage{}, err } - // Only include components from the package that have the potential to be imported (match the name of the .import.name) var relevantComponents []v1alpha1.ZarfComponent for _, importedComponent := range importedPkg.Components { if importedComponent.Name == getComponentToImportName(component) {