New route to expose PGP Keys

This commit is contained in:
nemunaire 2022-09-10 12:14:11 +02:00
commit fa6b421d70
3 changed files with 35 additions and 16 deletions

View file

@ -349,24 +349,12 @@ func TriggerTagUpdate(c *gin.Context, work *Work, repo *Repository, u *User, tag
repo_tag = *tag
}
var pgp_keys string
keys, err := u.GetKeys()
if err != nil {
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Something goes really wrong with your PGP keys: unable to retrieve them."})
return
}
for _, k := range keys {
pgp_keys += k.Content + "\n"
}
client := drone.NewClient(droneEndpoint, droneConfig)
result, err := client.BuildCreate("srs", "atsebay.t-worker", "", "master", map[string]string{
"REPO_URL": repo.URI,
"REPO_TAG": repo_tag,
"USER_PGP_PUBKEY": pgp_keys,
"LOGIN": u.Login,
"DEST": fmt.Sprintf("%d", work.Id),
"REPO_URL": repo.URI,
"REPO_TAG": repo_tag,
"LOGIN": u.Login,
"DEST": fmt.Sprintf("%d", work.Id),
})
if err != nil {
log.Println("Unable to communicate with Drone:", err.Error())