From c04694838e454ad32986bf793b26f2a4331e585f Mon Sep 17 00:00:00 2001 From: Yoshiyuki HINO Date: Mon, 30 Oct 2023 12:20:40 +0900 Subject: [PATCH] feat: Support "Copper Argos" with Athenz authentication for pulsar (#2881) Signed-off-by: Yoshiyuki HINO --- eventsources/sources/pulsar/start.go | 14 ++++++++------ sensors/triggers/pulsar/pulsar.go | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/eventsources/sources/pulsar/start.go b/eventsources/sources/pulsar/start.go index 18a2fcc94b..e1307a999d 100644 --- a/eventsources/sources/pulsar/start.go +++ b/eventsources/sources/pulsar/start.go @@ -107,14 +107,16 @@ func (el *EventListener) StartListening(ctx context.Context, dispatch func([]byt clientOpt.Authentication = pulsar.NewAuthenticationToken(token) } - if len(pulsarEventSource.AuthAthenzParams) > 0 && pulsarEventSource.AuthAthenzSecret != nil { + if len(pulsarEventSource.AuthAthenzParams) > 0 { log.Info("setting athenz auth option...") - authAthenzFilePath, err := common.GetSecretVolumePath(pulsarEventSource.AuthAthenzSecret) - if err != nil { - log.Errorw("failed to get authAthenzSecret from the volume", zap.Error(err)) - return err + if pulsarEventSource.AuthAthenzSecret != nil { + authAthenzFilePath, err := common.GetSecretVolumePath(pulsarEventSource.AuthAthenzSecret) + if err != nil { + log.Errorw("failed to get authAthenzSecret from the volume", zap.Error(err)) + return err + } + pulsarEventSource.AuthAthenzParams["privateKey"] = "file://" + authAthenzFilePath } - pulsarEventSource.AuthAthenzParams["privateKey"] = "file://" + authAthenzFilePath clientOpt.Authentication = pulsar.NewAuthenticationAthenz(pulsarEventSource.AuthAthenzParams) } diff --git a/sensors/triggers/pulsar/pulsar.go b/sensors/triggers/pulsar/pulsar.go index 2e5f0eca08..6b0956760c 100644 --- a/sensors/triggers/pulsar/pulsar.go +++ b/sensors/triggers/pulsar/pulsar.go @@ -73,14 +73,16 @@ func NewPulsarTrigger(sensor *v1alpha1.Sensor, trigger *v1alpha1.Trigger, pulsar clientOpt.Authentication = pulsar.NewAuthenticationToken(token) } - if len(pulsarTrigger.AuthAthenzParams) > 0 && pulsarTrigger.AuthAthenzSecret != nil { + if len(pulsarTrigger.AuthAthenzParams) > 0 { logger.Info("setting athenz auth option...") - authAthenzFilePath, err := common.GetSecretVolumePath(pulsarTrigger.AuthAthenzSecret) - if err != nil { - logger.Errorw("failed to get authAthenzSecret from the volume", zap.Error(err)) - return nil, err + if pulsarTrigger.AuthAthenzSecret != nil { + authAthenzFilePath, err := common.GetSecretVolumePath(pulsarTrigger.AuthAthenzSecret) + if err != nil { + logger.Errorw("failed to get authAthenzSecret from the volume", zap.Error(err)) + return nil, err + } + pulsarTrigger.AuthAthenzParams["privateKey"] = "file://" + authAthenzFilePath } - pulsarTrigger.AuthAthenzParams["privateKey"] = "file://" + authAthenzFilePath clientOpt.Authentication = pulsar.NewAuthenticationAthenz(pulsarTrigger.AuthAthenzParams) }