Skip to content

Commit

Permalink
Merge pull request #96 from fluxcd/rec-all
Browse files Browse the repository at this point in the history
Lookup ready receivers in all namespaces
  • Loading branch information
stefanprodan authored Dec 7, 2020
2 parents d9659be + 4bfeabb commit bff07cb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/server/receiver_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"strings"

"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/google/go-github/v32/github"
corev1 "k8s.io/api/core/v1"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/fluxcd/notification-controller/api/v1beta1"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
)

func (s *ReceiverServer) handlePayload() func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -43,7 +42,7 @@ func (s *ReceiverServer) handlePayload() func(w http.ResponseWriter, r *http.Req
s.logger.Info("handling request", "digest", digest)

var allReceivers v1beta1.ReceiverList
err := s.kubeClient.List(ctx, &allReceivers, client.InNamespace(os.Getenv("RUNTIME_NAMESPACE")))
err := s.kubeClient.List(ctx, &allReceivers)
if err != nil {
s.logger.Error(err, "unable to list receivers")
w.WriteHeader(http.StatusBadRequest)
Expand All @@ -52,7 +51,9 @@ func (s *ReceiverServer) handlePayload() func(w http.ResponseWriter, r *http.Req

receivers := make([]v1beta1.Receiver, 0)
for _, receiver := range allReceivers.Items {
if receiver.Status.URL == fmt.Sprintf("/hook/%s", digest) && !receiver.Spec.Suspend {
if !receiver.Spec.Suspend &&
apimeta.IsStatusConditionTrue(receiver.Status.Conditions, meta.ReadyCondition) &&
receiver.Status.URL == fmt.Sprintf("/hook/%s", digest) {
receivers = append(receivers, receiver)
}
}
Expand Down

0 comments on commit bff07cb

Please sign in to comment.