Skip to content

Commit

Permalink
refactor: normal creator
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <[email protected]>
  • Loading branch information
phillebaba committed Jan 8, 2025
1 parent 4cec60d commit 92132d9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/internal/packager2/layout/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ func resolveImports(ctx context.Context, pkg v1alpha1.ZarfPackage, packagePath,
var importedPkg v1alpha1.ZarfPackage
if component.Import.Path != "" {
importPath := filepath.Join(packagePath, component.Import.Path)
importKey := fmt.Sprintf("%s-%s", component.Name, importPath)
absImportPath, err := filepath.Abs(importPath)
if err != nil {
return v1alpha1.ZarfPackage{}, err
}
importKey := fmt.Sprintf("%s-%s", component.Name, absImportPath)
if _, ok := seenImports[importKey]; ok {
return v1alpha1.ZarfPackage{}, fmt.Errorf("package %s imported in cycle by %s", filepath.ToSlash(importPath), filepath.ToSlash(packagePath))
return v1alpha1.ZarfPackage{}, fmt.Errorf("package %s imported in cycle by %s in component %s", filepath.ToSlash(importPath), filepath.ToSlash(packagePath), component.Name)
}
seenImports[importKey] = nil
seenImports[absImportPath] = nil
b, err := os.ReadFile(filepath.Join(importPath, layout.ZarfYAML))
if err != nil {
return v1alpha1.ZarfPackage{}, err
Expand Down

0 comments on commit 92132d9

Please sign in to comment.