Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
fix(cp-connector): Added missing Register() method to FixedSubscripti…
Browse files Browse the repository at this point in the history
…onSource (#7731)

* fix(cp-connector): Added missing Register() method to FixedSubscriptionSource

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>

* enahnce

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>

* bernds little fix

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
  • Loading branch information
odubajDT committed May 12, 2022
1 parent c36faf0 commit fe5b978
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cp-connector/pkg/controlplane/eventmatcher.go
@@ -1,10 +1,11 @@
package controlplane

import (
"strings"

"github.com/keptn/go-utils/pkg/api/models"
"github.com/keptn/go-utils/pkg/common/sliceutils"
"github.com/keptn/go-utils/pkg/lib/v0_2_0"
"strings"
)

// EventMatcher is used to check whether an event contains is containing information
Expand Down
2 changes: 2 additions & 0 deletions cp-connector/pkg/controlplane/eventsource.go
Expand Up @@ -17,6 +17,8 @@ type EventSenderKeyType struct{}

var EventSenderKey = EventSenderKeyType{}

var _ EventSource = (*NATSEventSource)(nil)

type EventSender func(ce models.KeptnContextExtendedCE) error

// EventUpdate wraps a new Keptn event received from the Event source
Expand Down
2 changes: 2 additions & 0 deletions cp-connector/pkg/controlplane/logforwarder.go
Expand Up @@ -17,6 +17,8 @@ type LogForwarder interface {
Forward(keptnEvent models.KeptnContextExtendedCE, integrationID string) error
}

var _ LogForwarder = LogForwardingHandler{}

type LogForwardingHandler struct {
logApi api.LogsV1Interface
logger logger.Logger
Expand Down
7 changes: 7 additions & 0 deletions cp-connector/pkg/controlplane/subscriptionsource.go
Expand Up @@ -15,6 +15,9 @@ type SubscriptionSource interface {
Register(integration models.Integration) (string, error)
}

var _ SubscriptionSource = FixedSubscriptionSource{}
var _ SubscriptionSource = (*UniformSubscriptionSource)(nil)

// UniformSubscriptionSource represents a source for uniform subscriptions
type UniformSubscriptionSource struct {
uniformAPI api.UniformV1Interface
Expand Down Expand Up @@ -97,3 +100,7 @@ func (s FixedSubscriptionSource) Start(ctx context.Context, data RegistrationDat
go func() { c <- s.fixedSubscriptions }()
return nil
}

func (s FixedSubscriptionSource) Register(integration models.Integration) (string, error) {
return "", nil
}
8 changes: 8 additions & 0 deletions cp-connector/pkg/controlplane/subscriptionsource_test.go
Expand Up @@ -193,6 +193,14 @@ func TestFixedSubscriptionSourcer_WithNoSubscriptions(t *testing.T) {
require.Equal(t, 0, len(updates))
}

func TestFixedSubscriptionSourcer_Register(t *testing.T) {
fss := NewFixedSubscriptionSource()
initialRegistrationData := RegistrationData{}
s, err := fss.Register(models.Integration(initialRegistrationData))
require.NoError(t, err)
require.Equal(t, "", s)
}

func TestSubscriptionRegistrationSucceeds(t *testing.T) {
initialRegistrationData := RegistrationData{}
uniformInterface := &fake.UniformAPIMock{
Expand Down
5 changes: 4 additions & 1 deletion cp-connector/pkg/nats/nats.go
Expand Up @@ -4,12 +4,15 @@ import (
"encoding/json"
"errors"
"fmt"
"os"

"github.com/keptn/go-utils/pkg/api/models"
"github.com/keptn/keptn/cp-connector/pkg/logger"
"github.com/nats-io/nats.go"
"os"
)

var _ NATS = (*NatsConnector)(nil)

const (
EnvVarNatsURL = "NATS_URL"
EnvVarNatsURLDefault = "nats://keptn-nats"
Expand Down

0 comments on commit fe5b978

Please sign in to comment.