support for new env plugin

This commit is contained in:
Brad Rydzewski
2019-11-20 10:01:42 -08:00
parent 6c9e3ac5c0
commit 8fa2a23129
10 changed files with 47 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"github.com/drone/drone-go/drone"
"github.com/drone/runner-go/environ/provider"
"github.com/drone/runner-go/manifest"
"github.com/drone/runner-go/registry"
"github.com/drone/runner-go/secret"
@@ -28,6 +29,7 @@ func TestClone(t *testing.T) {
c := &Compiler{
Registry: registry.Static(nil),
Secret: secret.Static(nil),
Environ: provider.Static(nil),
}
args := Args{
Repo: &drone.Repo{},
@@ -63,6 +65,7 @@ func TestClone(t *testing.T) {
func TestCloneDisable(t *testing.T) {
c := &Compiler{
Environ: provider.Static(nil),
Registry: registry.Static(nil),
Secret: secret.Static(nil),
}

View File

@@ -15,6 +15,7 @@ import (
"github.com/drone/drone-go/drone"
"github.com/drone/runner-go/clone"
"github.com/drone/runner-go/environ"
"github.com/drone/runner-go/environ/provider"
"github.com/drone/runner-go/labels"
"github.com/drone/runner-go/manifest"
"github.com/drone/runner-go/registry"
@@ -25,7 +26,9 @@ import (
)
// random generator function
var random = uniuri.New
var random = func() string {
return "drone-" + uniuri.NewLen(20)
}
// Privileged provides a list of plugins that execute
// with privileged capabilities in order to run Docker
@@ -96,7 +99,7 @@ type Compiler struct {
// Environ provides a set of environment variables that
// should be added to each pipeline step by default.
Environ map[string]string
Environ provider.Provider
// Labels provides a set of labels that should be added
// to each container by default.
@@ -202,9 +205,15 @@ func (c *Compiler) Compile(ctx context.Context, args Args) *engine.Spec {
Volumes: []*engine.Volume{volume},
}
// list the global environment variables
envs, _ := c.Environ.List(ctx, &provider.Request{
Build: args.Build,
Repo: args.Repo,
})
// create the default environment variables.
envs := environ.Combine(
c.Environ,
envs = environ.Combine(
envs,
args.Build.Params,
args.Pipeline.Environment,
environ.Proxy(),

View File

@@ -17,6 +17,7 @@ import (
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"github.com/drone/drone-go/drone"
"github.com/drone/runner-go/environ/provider"
"github.com/drone/runner-go/manifest"
"github.com/drone/runner-go/registry"
"github.com/drone/runner-go/secret"
@@ -97,6 +98,7 @@ func TestCompile_Secrets(t *testing.T) {
manifest, _ := manifest.ParseFile("testdata/secret.yml")
compiler := &Compiler{
Environ: provider.Static(nil),
Registry: registry.Static(nil),
Secret: secret.StaticVars(map[string]string{
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
@@ -158,6 +160,7 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {
}
compiler := &Compiler{
Environ: provider.Static(nil),
Registry: registry.Static(nil),
Secret: secret.StaticVars(map[string]string{
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",