From 9e5b403b62fb770f53b8c5d005b9c7550468bcbf Mon Sep 17 00:00:00 2001 From: Jaydip Gabani Date: Wed, 25 Oct 2023 20:26:59 +0000 Subject: [PATCH] making channel in subscriber configurable Signed-off-by: Jaydip Gabani --- test/pubsub/fake-subscriber/main.go | 18 +++++++++++------- .../fake-subscriber/manifest/subscriber.yaml | 3 +++ website/docs/pubsub.md | 2 +- .../versioned_docs/version-v3.13.x/pubsub.md | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/test/pubsub/fake-subscriber/main.go b/test/pubsub/fake-subscriber/main.go index 9831cbe2b2b..fadd3aac2c9 100644 --- a/test/pubsub/fake-subscriber/main.go +++ b/test/pubsub/fake-subscriber/main.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "log" + "os" "strconv" "github.com/dapr/go-sdk/service/common" @@ -30,15 +31,18 @@ type PubsubMsg struct { ResourceLabels map[string]string `json:"resourceLabels,omitempty"` } -var sub = &common.Subscription{ - PubsubName: "pubsub", - Topic: "audit", - Route: "/checkout", -} - func main() { + auditChannel := os.Getenv("AUDIT_CHANNEL") + if auditChannel == "" { + auditChannel = "audit-channel" + } + sub := &common.Subscription{ + PubsubName: "pubsub", + Topic: auditChannel, + Route: "/checkout", + } s := daprd.NewService(":6002") - log.Printf("Listening...") + log.Printf("Listening on %s...", auditChannel) if err := s.AddTopicEventHandler(sub, eventHandler); err != nil { log.Fatalf("error adding topic subscription: %v", err) } diff --git a/test/pubsub/fake-subscriber/manifest/subscriber.yaml b/test/pubsub/fake-subscriber/manifest/subscriber.yaml index d0372ed6350..4c656ccd577 100644 --- a/test/pubsub/fake-subscriber/manifest/subscriber.yaml +++ b/test/pubsub/fake-subscriber/manifest/subscriber.yaml @@ -41,3 +41,6 @@ spec: - name: go-sub image: fake-subscriber:latest imagePullPolicy: Never + env: + - name: AUDIT_CHANNEL + value: "audit-channel" diff --git a/website/docs/pubsub.md b/website/docs/pubsub.md index 08babf33921..aac6a766728 100644 --- a/website/docs/pubsub.md +++ b/website/docs/pubsub.md @@ -161,7 +161,7 @@ Dapr: https://dapr.io/ ```shell # auditPodAnnotations is used to add annotations required by Dapr to inject sidecar to audit pod echo 'auditPodAnnotations: {dapr.io/enabled: "true", dapr.io/app-id: "audit", dapr.io/metrics-port: "9999", dapr.io/sidecar-seccomp-profile-type: "RuntimeDefault"}' > /tmp/annotations.yaml - helm upgrade --install gatekeeper/gatekeeper --namespace gatekeeper-system \ + helm upgrade --install gatekeeper gatekeeper/gatekeeper --namespace gatekeeper-system \ --set audit.enablePubsub=true \ --set audit.connection=audit-connection \ --set audit.channel=audit-channel \ diff --git a/website/versioned_docs/version-v3.13.x/pubsub.md b/website/versioned_docs/version-v3.13.x/pubsub.md index 570354aceb3..1b8b215097d 100644 --- a/website/versioned_docs/version-v3.13.x/pubsub.md +++ b/website/versioned_docs/version-v3.13.x/pubsub.md @@ -161,7 +161,7 @@ Dapr: https://dapr.io/ ```shell # auditPodAnnotations is used to add annotations required by Dapr to inject sidecar to audit pod echo 'auditPodAnnotations: {dapr.io/enabled: "true", dapr.io/app-id: "audit", dapr.io/metrics-port: "9999", dapr.io/sidecar-seccomp-profile-type: "RuntimeDefault"}' > /tmp/annotations.yaml - helm upgrade --install gatekeeper/gatekeeper --namespace gatekeeper-system \ + helm upgrade --install gatekeeper gatekeeper/gatekeeper --namespace gatekeeper-system \ --set audit.enablePubsub=true \ --set audit.connection=audit-connection \ --set audit.channel=audit-channel \