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

Commit

Permalink
feat: Disable NATS connection on remote execution-plane configuration (
Browse files Browse the repository at this point in the history
…#524)

Signed-off-by: TannerGabriel <[email protected]>
  • Loading branch information
TannerGabriel authored Jul 18, 2022
1 parent 3a171cc commit 866624f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/sdk/keptn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package sdk

import (
"context"
eventsource "github.com/keptn/go-utils/pkg/sdk/connector/eventsource/nats"
"github.com/benbjohnson/clock"
"github.com/keptn/go-utils/pkg/sdk/connector/eventsource"
"github.com/keptn/go-utils/pkg/sdk/connector/eventsource/http"
eventsourceNats "github.com/keptn/go-utils/pkg/sdk/connector/eventsource/nats"
"github.com/keptn/go-utils/pkg/sdk/connector/logforwarder"
"github.com/keptn/go-utils/pkg/sdk/connector/logger"
"github.com/keptn/go-utils/pkg/sdk/connector/subscriptionsource"
Expand Down Expand Up @@ -394,9 +397,15 @@ func newControlPlaneFromEnv(logger logger.Logger) (api.KeptnInterface, *controlp
logger.Fatal(err)
}

natsConnector := nats.New(env.EventBrokerURL, nats.WithLogger(logger))
eventSource := eventsource.New(natsConnector, eventsource.WithLogger(logger))
var eventSource eventsource.EventSource
if env.PubSubConnectionType() == config.ConnectionTypeHTTP {
eventSource = http.New(clock.New(), http.NewEventAPI(apiSet.ShipyardControlV1(), apiSet.APIV1()))
} else {
natsConnector := nats.New(env.EventBrokerURL, nats.WithLogger(logger))
eventSource = eventsourceNats.New(natsConnector, eventsourceNats.WithLogger(logger))
}
eventSender := eventSource.Sender()

subscriptionSource := subscriptionsource.New(apiSet.UniformV1(), subscriptionsource.WithLogger(logger))
logForwarder := logforwarder.New(apiSet.LogsV1(), logforwarder.WithLogger(logger))
controlPlane := controlplane.New(subscriptionSource, eventSource, logForwarder, controlplane.WithLogger(logger))
Expand Down

0 comments on commit 866624f

Please sign in to comment.