@@ -33,7 +33,10 @@ import (
3333
3434// clusterRequirement is a type alias for ClusterSelectorTerm in the API, which allows
3535// easy method extension.
36- type clusterRequirement placementv1beta1.ClusterSelectorTerm
36+ type clusterRequirement struct {
37+ // Embed the original ClusterSelectorTerm.
38+ ClusterSelectorTerm placementv1beta1.ClusterSelectorTerm
39+ }
3740
3841// retrieveResourceUsageFrom retrieves a resource property value from a member cluster.
3942//
@@ -121,8 +124,8 @@ func retrievePropertyValueFrom(cluster *clusterv1beta1.MemberCluster, name strin
121124// This is an extended method for the ClusterSelectorTerm API.
122125func (c * clusterRequirement ) Matches (cluster * clusterv1beta1.MemberCluster ) (bool , error ) {
123126 // Match the cluster against the label selector.
124- if c .LabelSelector != nil {
125- ls , err := metav1 .LabelSelectorAsSelector (c .LabelSelector )
127+ if c .ClusterSelectorTerm . LabelSelector != nil {
128+ ls , err := metav1 .LabelSelectorAsSelector (c .ClusterSelectorTerm . LabelSelector )
126129 if err != nil {
127130 return false , fmt .Errorf ("failed to parse label selector: %w" , err )
128131 }
@@ -134,12 +137,12 @@ func (c *clusterRequirement) Matches(cluster *clusterv1beta1.MemberCluster) (boo
134137 }
135138
136139 // Match the cluster against the property selector.
137- if c .PropertySelector == nil || len (c .PropertySelector .MatchExpressions ) == 0 {
140+ if c .ClusterSelectorTerm . PropertySelector == nil || len (c . ClusterSelectorTerm .PropertySelector .MatchExpressions ) == 0 {
138141 // The term does not feature a property selector; no check is needed.
139142 return true , nil
140143 }
141144
142- for _ , exp := range c .PropertySelector .MatchExpressions {
145+ for _ , exp := range c .ClusterSelectorTerm . PropertySelector .MatchExpressions {
143146 // Compare the observed value with the expected one using the specified operator.
144147 q , err := retrievePropertyValueFrom (cluster , exp .Name )
145148 if err != nil {
0 commit comments