Skip to content

Commit

Permalink
Update value of localPath for composable packages (#1154)
Browse files Browse the repository at this point in the history
## Description

<!-- Please include a summary of the change. Any relevant motivation or
context is also helpful, as well as any dependencies that are required
for this change -->

## Related Issue

<!--- This project prefers to accept pull requests related to open
issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->

Fixes #1153

## Type of change
- [x] Bug fix (non-breaking change which fixes an issue)

---------

Co-authored-by: Megamind <[email protected]>
Co-authored-by: Jonathan Perry <[email protected]>
  • Loading branch information
3 people authored Feb 1, 2023
1 parent 10d2866 commit 5ee6398
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/zarf-registry/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ components:
charts:
- name: docker-registry
releaseName: zarf-docker-registry
localPath: packages/zarf-registry/chart
localPath: chart
version: 1.0.0
namespace: zarf
valuesFiles:
Expand All @@ -57,7 +57,7 @@ components:
charts:
- name: docker-registry
releaseName: zarf-docker-registry
localPath: packages/zarf-registry/chart
localPath: chart
version: 1.0.0
namespace: zarf
valuesFiles:
Expand Down
10 changes: 9 additions & 1 deletion src/pkg/packager/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package packager

import (
"fmt"
"os"
"path/filepath"

"github.com/defenseunicorns/zarf/src/config"
Expand Down Expand Up @@ -145,11 +146,18 @@ func (p *Packager) fixComposedFilepaths(parent, child types.ZarfComponent) types
child.Files[fileIdx].Source = p.getComposedFilePath(file.Source, parent.Import.Path)
}

// Prefix non-url composed component chart values files.
// Prefix non-url composed component chart values files and localPath.
for chartIdx, chart := range child.Charts {
for valuesIdx, valuesFile := range chart.ValuesFiles {
child.Charts[chartIdx].ValuesFiles[valuesIdx] = p.getComposedFilePath(valuesFile, parent.Import.Path)
}
if child.Charts[chartIdx].LocalPath != "" {
// Check if the localPath is relative to the parent Zarf package
if _, err := os.Stat(child.Charts[chartIdx].LocalPath); os.IsNotExist(err) {
// Since the chart localPath is not relative to the parent Zarf package, get the relative path from the composed child
child.Charts[chartIdx].LocalPath = p.getComposedFilePath(child.Charts[chartIdx].LocalPath, parent.Import.Path)
}
}
}

// Prefix non-url composed manifest files and kustomizations.
Expand Down

0 comments on commit 5ee6398

Please sign in to comment.