Skip to content

Commit

Permalink
refactor: remove duplicate IsCrossNamespaceImportAllowed
Browse files Browse the repository at this point in the history
  • Loading branch information
msvechla committed Jan 27, 2025
1 parent feeee41 commit b79554d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions api/v1beta1/grafananotificationpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ func (np *GrafanaNotificationPolicy) NamespacedResource() string {
return fmt.Sprintf("%v/%v/%v", np.ObjectMeta.Namespace, np.ObjectMeta.Name, np.ObjectMeta.UID)
}

// IsCrossNamespaceImportAllowed returns true when cross namespace imports are allowed
func (np *GrafanaNotificationPolicy) IsCrossNamespaceImportAllowed() bool {
return np.Spec.AllowCrossNamespaceImport
}

//+kubebuilder:object:root=true

// GrafanaNotificationPolicyList contains a list of GrafanaNotificationPolicy
Expand Down
4 changes: 2 additions & 2 deletions controllers/notificationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *GrafanaNotificationPolicyReconciler) Reconcile(ctx context.Context, req

if notificationPolicy.Spec.Route.RouteSelector != nil || hasRouteSelector(notificationPolicy.Spec.Route) {
var namespace *string
if !notificationPolicy.IsCrossNamespaceImportAllowed() {
if !notificationPolicy.AllowCrossNamespace() {
ns := notificationPolicy.GetObjectMeta().GetNamespace()
namespace = &ns
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func (r *GrafanaNotificationPolicyReconciler) SetupWithManager(mgr ctrl.Manager)
continue
}

if np.GetNamespace() != o.GetNamespace() && !np.IsCrossNamespaceImportAllowed() {
if np.GetNamespace() != o.GetNamespace() && !np.AllowCrossNamespace() {
continue
}

Expand Down

0 comments on commit b79554d

Please sign in to comment.