Skip to content

Commit

Permalink
Exclude CiliumIdentity kind during listing resources (#751)
Browse files Browse the repository at this point in the history
Signed-off-by: Praveen Rewar <[email protected]>
  • Loading branch information
praveenrewar authored May 15, 2023
1 parent 3e2edfa commit 949012e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kapp/resources/identified_resources_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func (r IdentifiedResources) List(labelSelector labels.Selector, resRefs []Resou
schema.GroupVersionResource{Version: "v1", Resource: "componentstatuses"},
})

// https://github.com/carvel-dev/kapp/issues/748
// TODO provide a way to exclude resource via configuration
resTypes = NonMatchingGK(resTypes, schema.GroupKind{Group: "cilium.io", Kind: "CiliumIdentity"})

if len(opts.GKsScope) > 0 {
resTypes = MatchingAnyGK(resTypes, opts.GKsScope)
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/kapp/resources/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ func NonMatching(in []ResourceType, ref ResourceRef) []ResourceType {
return out
}

func NonMatchingGK(in []ResourceType, gk schema.GroupKind) []ResourceType {
var out []ResourceType
for _, item := range in {
if !(GKResourceRef{gk}).Matches(item) {
out = append(out, item)
}
}
return out
}

// TODO: Extend ResourceRef and PartialResourceRefd to allow GVK matching
func MatchingAnyGK(in []ResourceType, gks []schema.GroupKind) []ResourceType {
var out []ResourceType
Expand Down

0 comments on commit 949012e

Please sign in to comment.