Skip to content

Commit

Permalink
Use tenancy as filter in ownerReference test
Browse files Browse the repository at this point in the history
  • Loading branch information
killianmuldoon committed Jan 23, 2023
1 parent 4f4b730 commit 8125147
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
19 changes: 4 additions & 15 deletions cmd/clusterctl/client/cluster/ownergraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ func GetOwnerGraph(namespace, kubeconfigPath string) (OwnerGraph, error) {

graph := newObjectGraph(p, invClient)

cl, err := p.NewClient()
if err != nil {
return OwnerGraph{}, errors.Wrap(err, "failed to create client for ownerGraph")
}
// Gets all the types defined by the CRDs installed by clusterctl plus the ConfigMap/Secret core types.
err = graph.getDiscoveryTypes()
err := graph.getDiscoveryTypes()
if err != nil {
return OwnerGraph{}, errors.Wrap(err, "failed to retrieve discovery types")
}
Expand All @@ -79,16 +75,9 @@ func GetOwnerGraph(namespace, kubeconfigPath string) (OwnerGraph, error) {
}
owners := OwnerGraph{}
for _, v := range graph.uidToNode {
// The Discovery function returns all secrets in the Cluster namespace. Ensure a Secret that is not part of the
// Cluster is not added to the OwnerGraph.
if v.identity.Kind == "Secret" {
clusterSecret, err := isClusterSecret(v.identity, cl)
if err != nil {
return OwnerGraph{}, err
}
if !clusterSecret {
continue
}
// If the node is not a tenant do not add it to the ownerGraph.
if len(v.tenant) == 0 {
continue
}
n := OwnerGraphNode{Object: v.identity, Owners: []metav1.OwnerReference{}}
for owner, attributes := range v.owners {
Expand Down
2 changes: 1 addition & 1 deletion test/framework/ownerreference_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var KubernetesReferenceAssertions = map[string]func([]metav1.OwnerReference) err
},
configMapKind: func(owners []metav1.OwnerReference) error {
// The only configMaps considered here are those owned by a ClusterResourceSet.
return hasOneOfExactOwnersByGVK(owners, []schema.GroupVersionKind{clusterResourceSetGVK}, []schema.GroupVersionKind{})
return hasOneOfExactOwnersByGVK(owners, []schema.GroupVersionKind{clusterResourceSetGVK})
},
}

Expand Down

0 comments on commit 8125147

Please sign in to comment.