Skip to content

Commit

Permalink
secret creation log adjust (feedback)
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r committed Jun 20, 2024
1 parent 2508d5f commit 7699745
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions api/secret/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func CreateSecret(c *gin.Context) {

// check if secret is a shared secret
if strings.EqualFold(t, constants.SecretShared) {
// update log fields from API metadata
// update log fields for shared secret
delete(fields, "secret_repo")
fields["secret_team"] = n
}
Expand Down Expand Up @@ -255,14 +255,23 @@ func CreateSecret(c *gin.Context) {
return
}

l.WithFields(logrus.Fields{
// update log fields from create response
fields = logrus.Fields{
"secret_id": s.GetID(),
"secret_name": s.GetName(),
"secret_org": s.GetOrg(),
"secret_repo": s.GetRepo(),
"secret_type": s.GetType(),
"secret_team": s.GetTeam(),
}).Infof("created secret %s for %s service", entry, e)
}

// check if secret is a shared secret
if strings.EqualFold(t, constants.SecretShared) {
// update log fields for shared secret
delete(fields, "secret_repo")
fields["secret_team"] = s.GetTeam()
}

l.WithFields(fields).Infof("created secret %s for %s service", entry, e)

c.JSON(http.StatusOK, s.Sanitize())
}

0 comments on commit 7699745

Please sign in to comment.