Skip to content

Commit

Permalink
add non versioned type
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Aug 23, 2024
1 parent 951b4e6 commit c01c532
Show file tree
Hide file tree
Showing 5 changed files with 973 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/pkg/packager/filters/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/agnivade/levenshtein"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/zarf-dev/zarf/src/api/v1alpha1"
"github.com/zarf-dev/zarf/src/pkg/interactive"
"github.com/zarf-dev/zarf/src/types"
)

// ForDeploy creates a new deployment filter.
Expand Down Expand Up @@ -40,9 +40,9 @@ var (
)

// Apply applies the filter.
func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfComponent, error) {
var selectedComponents []v1alpha1.ZarfComponent
groupedComponents := map[string][]v1alpha1.ZarfComponent{}
func (f *deploymentFilter) Apply(pkg types.ZarfPackage) ([]types.ZarfComponent, error) {
var selectedComponents []types.ZarfComponent
groupedComponents := map[string][]types.ZarfComponent{}
orderedComponentGroups := []string{}

// Group the components by Name and Group while maintaining order
Expand All @@ -66,16 +66,16 @@ func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfCompo

// NOTE: This does not use forIncludedComponents as it takes group, default and required status into account.
for _, groupKey := range orderedComponentGroups {
var groupDefault *v1alpha1.ZarfComponent
var groupSelected *v1alpha1.ZarfComponent
var groupDefault *types.ZarfComponent
var groupSelected *types.ZarfComponent

for _, component := range groupedComponents[groupKey] {
// Ensure we have a local version of the component to point to (otherwise the pointer might change on us)
component := component

selectState, matchedRequest := includedOrExcluded(component.Name, f.requestedComponents)

if !component.IsRequired() {
if component.IsOptional() {
if selectState == excluded {
// If the component was explicitly excluded, record the match and continue
matchedRequests[matchedRequest] = true
Expand Down Expand Up @@ -161,7 +161,7 @@ func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfCompo
} else {
component := groupedComponents[groupKey][0]

if component.IsRequired() {
if !component.IsOptional() {
selectedComponents = append(selectedComponents, component)
continue
}
Expand Down
Loading

0 comments on commit c01c532

Please sign in to comment.