drone exec should read secrets from env

This commit is contained in:
Brad Rydzewski 2017-04-21 18:18:11 +02:00
parent 8d37efef68
commit cc530301fe
2 changed files with 6 additions and 1 deletions

View file

@ -19,7 +19,6 @@ deps_backend:
go get -u golang.org/x/tools/cmd/cover go get -u golang.org/x/tools/cmd/cover
go get -u github.com/jteeuwen/go-bindata/... go get -u github.com/jteeuwen/go-bindata/...
go get -u github.com/elazarl/go-bindata-assetfs/... go get -u github.com/elazarl/go-bindata-assetfs/...
go get -u github.com/tidwall/redlog
gen: gen_template gen_migrations gen: gen_template gen_migrations

View file

@ -277,6 +277,7 @@ func exec(c *cli.Context) error {
metadata := metadataFromContext(c) metadata := metadataFromContext(c)
environ := metadata.Environ() environ := metadata.Environ()
secrets := []compiler.Secret{}
for k, v := range metadata.EnvironDrone() { for k, v := range metadata.EnvironDrone() {
environ[k] = v environ[k] = v
} }
@ -284,6 +285,10 @@ func exec(c *cli.Context) error {
k := strings.Split(env, "=")[0] k := strings.Split(env, "=")[0]
v := strings.Split(env, "=")[1] v := strings.Split(env, "=")[1]
environ[k] = v environ[k] = v
secrets = append(secrets, compiler.Secret{
Name: k,
Value: v,
})
} }
tmpl, err := envsubst.ParseFile(file) tmpl, err := envsubst.ParseFile(file)
@ -345,6 +350,7 @@ func exec(c *cli.Context) error {
c.String("netrc-machine"), c.String("netrc-machine"),
), ),
compiler.WithMetadata(metadata), compiler.WithMetadata(metadata),
compiler.WithSecret(secrets...),
).Compile(conf) ).Compile(conf)
engine, err := docker.NewEnv() engine, err := docker.NewEnv()