Skip to content

Commit

Permalink
POC
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 12c00e4 commit bb29398
Showing 1 changed file with 8 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,7 +11,7 @@ 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/api/v1beta1"
"github.com/zarf-dev/zarf/src/pkg/interactive"
)

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 v1beta1.ZarfPackage) ([]v1beta1.ZarfComponent, error) {
var selectedComponents []v1beta1.ZarfComponent
groupedComponents := map[string][]v1beta1.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 *v1beta1.ZarfComponent
var groupSelected *v1beta1.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

0 comments on commit bb29398

Please sign in to comment.