Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: filter package components with strategy interface (#2321)
## Description Consolidate component filtering logic into a `filters` package. Each filter is an implementation of ```go // ComponentFilterStrategy is a strategy interface for filtering components. type ComponentFilterStrategy interface { Apply(types.ZarfPackage) ([]types.ZarfComponent, error) } ``` Public construction functions return instances of this interface _not_ instances of their underlying structs. Consumers should be fully cognizant of which filter they are using, and should not be making a common wrapper function (eg. `NewFilter(args...)` to dynamically return a filter. ex: ```go func Empty() ComponentFilterStrategy { return &emptyFilter{} } // emptyFilter is a filter that does nothing. type emptyFilter struct{} // Apply returns the components unchanged. func (f *emptyFilter) Apply(pkg types.ZarfPackage) ([]types.ZarfComponent, error) { return pkg.Components, nil } ``` BREAKING CHANGES: This changes the interface signatures on `sources.PackageSource` to reflect the new behavior whereupon the `zarf.yaml` is loaded into memory within the sources load operations. This allows for `filter`ing to take place during load and for the `zarf.yaml` in memory to reflect these filter operations. ## Related Issue Fixes #2320 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --------- Signed-off-by: razzle <[email protected]> Co-authored-by: Wayne Starr <[email protected]> Co-authored-by: Lucas Rodriguez <[email protected]> Co-authored-by: Lucas Rodriguez <[email protected]>
- Loading branch information