From 866624f8ce4274c3a9ae9b597fba04a338e20dc3 Mon Sep 17 00:00:00 2001 From: TannerGabriel Date: Mon, 18 Jul 2022 14:09:31 +0200 Subject: [PATCH] feat: Disable NATS connection on remote execution-plane configuration (#524) Signed-off-by: TannerGabriel --- pkg/sdk/keptn.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/sdk/keptn.go b/pkg/sdk/keptn.go index 93f33a64..9ad397c6 100644 --- a/pkg/sdk/keptn.go +++ b/pkg/sdk/keptn.go @@ -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" @@ -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))