Skip to content

Commit

Permalink
fix(gcpPublishEvent): Error handling in non-standard Vault cases (#4938)
Browse files Browse the repository at this point in the history
* fix error handling in non-standard Vault cases

* handle case where Vault isn't configured and no error is thrown

* remove unnecessary return

---------

Co-authored-by: jliempt <>
  • Loading branch information
jliempt authored May 28, 2024
1 parent 8924b97 commit ce34dd3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/gcpPublishEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ func gcpPublishEvent(config gcpPublishEventOptions, telemetryData *telemetry.Cus
}

client, err := piperConfig.GetVaultClientFromConfig(vaultConfig, vaultCreds)
if err != nil {
log.Entry().WithError(err).Warnf("could not create Vault client")
if err != nil || client == nil {
log.Entry().WithError(err).Warnf("could not create Vault client: incomplete Vault configuration")
return
}
defer client.MustRevokeToken()

vaultClient, ok := client.(vault.Client)
if !ok {
log.Entry().WithError(err).Warnf("could not create Vault client")
return
}

utils := gcpPublishEventUtilsBundle{
Expand Down

0 comments on commit ce34dd3

Please sign in to comment.