Fix issue with multiple vaults and runners

This commit is contained in:
Brian Zoetewey 2024-10-04 13:47:17 -04:00
parent 0250b0b9f7
commit 76d14365fd
2 changed files with 8 additions and 2 deletions

View File

@ -95,7 +95,7 @@ func GetRunner(w http.ResponseWriter, r *http.Request) {
if err != nil {
// TODO: return error
}
data.AccessKeys[vault.Vault.ID] = *vault.Vault
data.AccessKeys[vault.VaultKeyID] = *vault.Vault
}
}

View File

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/ansible-semaphore/semaphore/db"
"io"
"net/http"
"os"
@ -425,11 +426,16 @@ func (p *JobPool) checkNewJobs() {
taskRunner.job.Inventory.BecomeKey = response.AccessKeys[*taskRunner.job.Inventory.BecomeKeyID]
}
var vaults []db.TemplateVault
if taskRunner.job.Template.Vaults != nil {
for _, vault := range taskRunner.job.Template.Vaults {
*vault.Vault = response.AccessKeys[vault.Vault.ID]
vault := vault
key := response.AccessKeys[vault.VaultKeyID]
vault.Vault = &key
vaults = append(vaults, vault)
}
}
taskRunner.job.Template.Vaults = vaults
if taskRunner.job.Inventory.RepositoryID != nil {
taskRunner.job.Inventory.Repository.SSHKey = response.AccessKeys[taskRunner.job.Inventory.Repository.SSHKeyID]