Skip to content

Commit

Permalink
feat: Support "Copper Argos" with Athenz authentication for pulsar (#…
Browse files Browse the repository at this point in the history
…2881)

Signed-off-by: Yoshiyuki HINO <yhinoz@gmail.com>
  • Loading branch information
yhino committed Oct 30, 2023
1 parent f3305b2 commit c046948
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions eventsources/sources/pulsar/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
14 changes: 8 additions & 6 deletions sensors/triggers/pulsar/pulsar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit c046948

Please sign in to comment.