Add secrets support (#14)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
@@ -54,8 +55,8 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
|
||||
|
||||
var auth transport.AuthMethod
|
||||
|
||||
if pe.Pipeline.Credential != nil {
|
||||
credential, err := db.GetCredentialById(*pe.Pipeline.Credential)
|
||||
if pe.Pipeline.CloneCredential != nil {
|
||||
credential, err := db.GetCloneCredentialById(*pe.Pipeline.CloneCredential)
|
||||
if err != nil {
|
||||
log.Errorf("could not get credenital from db: %v", err)
|
||||
return
|
||||
@@ -154,6 +155,27 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
|
||||
)
|
||||
}
|
||||
|
||||
env := make([]string, 0)
|
||||
|
||||
// set cursorius environment variables
|
||||
env = append(env, []string{
|
||||
fmt.Sprintf("RUNID=%v", pe.Run.Id),
|
||||
"CURSORIUS_SRC_DIR=/cursorius/src",
|
||||
fmt.Sprintf("CUROSRIUS_SERVER_URL=%v", pipelineConf.AccessURL),
|
||||
}...)
|
||||
|
||||
// load secrets into environment
|
||||
secrets, err := db.GetSecretsForPipeline(pe.Pipeline.Id)
|
||||
if err != nil {
|
||||
log.Errorf("Could not get secrets for pipeline", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, secret := range secrets {
|
||||
// TODO: this doesn't validate either of these strings
|
||||
env = append(env, fmt.Sprintf("%v=%v", strings.ToUpper(secret.Name), secret.Secret))
|
||||
}
|
||||
|
||||
resp, err := cli.ContainerCreate(ctx,
|
||||
&container.Config{
|
||||
Image: imageName,
|
||||
|
||||
Reference in New Issue
Block a user