Skip to content

Commit

Permalink
add namespaceSelector for ClusterPropagationPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Jan 4, 2025
1 parent 28ba8da commit 60e60ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/detector/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ func getHighestPriorityPropagationPolicy(policies []*policyv1alpha1.PropagationP
var matchedPolicy *policyv1alpha1.PropagationPolicy

for _, policy := range policies {
// namespace matches ?
if policy.Spec.NamespaceSelectors != nil {
if !util.ResourceMatchSelectors(GetNamespace(resource.GetNamespace()), policy.Spec.NamespaceSelectors) {

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.29.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.29.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / init with config file (v1.30.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / init with config file (v1.30.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.30.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.30.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / init with config file (v1.29.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / init with config file (v1.29.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.31.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.31.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / init with config file (v1.31.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / init with config file (v1.31.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.31.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.31.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.30.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.30.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.31.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.31.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.29.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.29.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.30.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.30.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.29.0)

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / Test on Kubernetes (v1.29.0)

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / lint

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / lint

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors) (typecheck)

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / lint

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / lint

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors) (typecheck)

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / lint

undefined: GetNamespace

Check failure on line 38 in pkg/detector/compare.go

View workflow job for this annotation

GitHub Actions / lint

cannot use policy.Spec.NamespaceSelectors (variable of type []"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".NamespaceSelector) as "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1".ResourceSelector value in argument to util.ResourceMatchSelectors (typecheck)
continue
}
}

// resource matches ?
implicitPriority := util.ResourceMatchSelectorsPriority(resource, policy.Spec.ResourceSelectors...)
if implicitPriority <= util.PriorityMisMatch {
continue
}
explicitPriority := policy.ExplicitPriority()

explicitPriority := policy.ExplicitPriority()
if matchedPolicyExplicitPriority < explicitPriority {
matchedPolicyImplicitPriority = implicitPriority
matchedPolicyExplicitPriority = explicitPriority
Expand Down

0 comments on commit 60e60ba

Please sign in to comment.