Skip to content

Commit d67ab30

Browse files
authored
Merge pull request #31 from Somefive/fix/add-ignore-namespace-for-list-managed-cluster
Fix: add ignore namespace for list managed cluster
2 parents 8026c15 + 2aca265 commit d67ab30

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pkg/apis/cluster/v1alpha1/client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (c *clusterClient) List(ctx context.Context, options ...client.ListOption)
110110
}
111111

112112
managedClusters := &ocmclusterv1.ManagedClusterList{}
113-
err = c.Client.List(ctx, managedClusters, clusterSelector{Selector: opts.LabelSelector, RequireCredentialType: false})
113+
err = c.Client.List(ctx, managedClusters, clusterSelector{Selector: opts.LabelSelector, RequireCredentialType: false, IgnoreNamespace: true})
114114
if err != nil && !meta.IsNoMatchError(err) && !runtime.IsNotRegisteredError(err) {
115115
return nil, err
116116
}
@@ -148,6 +148,7 @@ func (c *clusterClient) List(ctx context.Context, options ...client.ListOption)
148148
type clusterSelector struct {
149149
Selector labels.Selector
150150
RequireCredentialType bool
151+
IgnoreNamespace bool
151152
}
152153

153154
// ApplyToList applies this configuration to the given list options.
@@ -165,5 +166,7 @@ func (m clusterSelector) ApplyToList(opts *client.ListOptions) {
165166
r, _ := labels.NewRequirement(clustergatewaycommon.LabelKeyClusterCredentialType, selection.Exists, nil)
166167
opts.LabelSelector = opts.LabelSelector.Add(*r)
167168
}
168-
opts.Namespace = StorageNamespace
169+
if !m.IgnoreNamespace {
170+
opts.Namespace = StorageNamespace
171+
}
169172
}

0 commit comments

Comments
 (0)