Skip to content

Commit

Permalink
chore: Move AdoptAll logic out of the Applier
Browse files Browse the repository at this point in the history
  • Loading branch information
karlkfi committed Feb 15, 2022
1 parent 2b7c073 commit fca07d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/apply/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,13 @@ func (a *Applier) Run(ctx context.Context, invInfo inventory.InventoryInfo, obje
InventoryPolicy: options.InventoryPolicy,
}
// Build list of apply validation filters.
var applyFilters []filter.ValidationFilter
if options.InventoryPolicy != inventory.AdoptAll {
applyFilters = append(applyFilters, filter.InventoryPolicyApplyFilter{
applyFilters := []filter.ValidationFilter{
filter.InventoryPolicyApplyFilter{
Client: a.client,
Mapper: a.mapper,
Inv: invInfo,
InvPolicy: options.InventoryPolicy,
})
},
}

// Build list of prune validation filters.
Expand Down
3 changes: 3 additions & 0 deletions pkg/apply/filter/inventory-policy-apply-filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (ipaf InventoryPolicyApplyFilter) Filter(obj *unstructured.Unstructured) (b
if obj == nil {
return true, "missing object", nil
}
if ipaf.InvPolicy == inventory.AdoptAll {
return false, "", nil
}
// Object must be retrieved from the cluster to get the inventory id.
clusterObj, err := ipaf.getObject(object.UnstructuredToObjMetadata(obj))
if err != nil {
Expand Down

0 comments on commit fca07d5

Please sign in to comment.