Skip to content

Commit

Permalink
making channel in subscriber configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Jaydip Gabani <[email protected]>
  • Loading branch information
JaydipGabani committed Oct 25, 2023
1 parent d497901 commit 9e5b403
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
18 changes: 11 additions & 7 deletions test/pubsub/fake-subscriber/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"log"
"os"
"strconv"

"github.com/dapr/go-sdk/service/common"
Expand All @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions test/pubsub/fake-subscriber/manifest/subscriber.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ spec:
- name: go-sub
image: fake-subscriber:latest
imagePullPolicy: Never
env:
- name: AUDIT_CHANNEL
value: "audit-channel"
2 changes: 1 addition & 1 deletion website/docs/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-v3.13.x/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 9e5b403

Please sign in to comment.