support for new env plugin
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone/envsubst"
|
||||
"github.com/drone/runner-go/environ"
|
||||
"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,7 +98,7 @@ func (c *compileCommand) run(*kingpin.ParseContext) error {
|
||||
|
||||
// compile the pipeline to an intermediate representation.
|
||||
comp := &compiler.Compiler{
|
||||
Environ: c.Environ,
|
||||
Environ: provider.Static(c.Environ),
|
||||
Labels: c.Labels,
|
||||
Resources: c.Resources,
|
||||
Privileged: append(c.Privileged, compiler.Privileged...),
|
||||
|
||||
@@ -78,6 +78,12 @@ type Config struct {
|
||||
CPUSet []string `envconfig:"DRONE_CPU_SET"`
|
||||
}
|
||||
|
||||
Environ struct {
|
||||
Endpoint string `envconfig:"DRONE_ENV_PLUGIN_ENDPOINT"`
|
||||
Token string `envconfig:"DRONE_ENV_PLUGIN_TOKEN"`
|
||||
SkipVerify bool `envconfig:"DRONE_ENV_PLUGIN_SKIP_VERIFY"`
|
||||
}
|
||||
|
||||
Secret struct {
|
||||
Endpoint string `envconfig:"DRONE_SECRET_PLUGIN_ENDPOINT"`
|
||||
Token string `envconfig:"DRONE_SECRET_PLUGIN_TOKEN"`
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/drone-runners/drone-runner-docker/runtime"
|
||||
|
||||
"github.com/drone/runner-go/client"
|
||||
"github.com/drone/runner-go/environ/provider"
|
||||
"github.com/drone/runner-go/handler/router"
|
||||
"github.com/drone/runner-go/logger"
|
||||
loghistory "github.com/drone/runner-go/logger/history"
|
||||
@@ -120,7 +121,6 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
||||
),
|
||||
Compiler: &compiler.Compiler{
|
||||
Clone: config.Runner.Clone,
|
||||
Environ: config.Runner.Environ,
|
||||
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
||||
Networks: config.Runner.Networks,
|
||||
Volumes: config.Runner.Volumes,
|
||||
@@ -132,6 +132,14 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
||||
CPUShares: config.Resources.CPUShares,
|
||||
CPUSet: config.Resources.CPUSet,
|
||||
},
|
||||
Environ: provider.Combine(
|
||||
provider.Static(config.Runner.Environ),
|
||||
provider.External(
|
||||
config.Environ.Endpoint,
|
||||
config.Environ.Token,
|
||||
config.Environ.SkipVerify,
|
||||
),
|
||||
),
|
||||
Registry: registry.Combine(
|
||||
registry.File(
|
||||
config.Docker.Config,
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/drone/drone-go/drone"
|
||||
"github.com/drone/envsubst"
|
||||
"github.com/drone/runner-go/environ"
|
||||
"github.com/drone/runner-go/environ/provider"
|
||||
"github.com/drone/runner-go/logger"
|
||||
"github.com/drone/runner-go/manifest"
|
||||
"github.com/drone/runner-go/pipeline"
|
||||
@@ -117,7 +118,7 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
|
||||
|
||||
// compile the pipeline to an intermediate representation.
|
||||
comp := &compiler.Compiler{
|
||||
Environ: c.Environ,
|
||||
Environ: provider.Static(c.Environ),
|
||||
Labels: c.Labels,
|
||||
Resources: c.Resources,
|
||||
Privileged: append(c.Privileged, compiler.Privileged...),
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -157,7 +157,7 @@ func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.W
|
||||
// create pull options with encoded authorization credentials.
|
||||
pullopts := types.ImagePullOptions{}
|
||||
if step.Auth != nil {
|
||||
pullopts.RegistryAuth = auths.Encode(
|
||||
pullopts.RegistryAuth = auths.Header(
|
||||
step.Auth.Username,
|
||||
step.Auth.Password,
|
||||
)
|
||||
|
||||
4
go.mod
4
go.mod
@@ -11,9 +11,9 @@ require (
|
||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
|
||||
github.com/docker/distribution v2.7.1+incompatible
|
||||
github.com/docker/go-connections v0.3.0 // indirect
|
||||
github.com/drone/drone-go v1.0.5-0.20190504210458-4d6116b897ba
|
||||
github.com/drone/drone-go v1.1.1-0.20191119212130-1d2e07e87e79
|
||||
github.com/drone/envsubst v1.0.2
|
||||
github.com/drone/runner-go v1.3.0
|
||||
github.com/drone/runner-go v1.4.1-0.20191119212738-c0d9268011a7
|
||||
github.com/drone/signal v1.0.0
|
||||
github.com/ghodss/yaml v1.0.0
|
||||
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 // indirect
|
||||
|
||||
6
go.sum
6
go.sum
@@ -29,6 +29,9 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/drone/drone-go v1.0.5-0.20190504210458-4d6116b897ba h1:GKiT4UPBligLXJAP1zRllHvTUygAAlgS3t9LM9aasp0=
|
||||
github.com/drone/drone-go v1.0.5-0.20190504210458-4d6116b897ba/go.mod h1:GxyeGClYohaKNYJv/ZpsmVHtMJ7WhoT+uDaJNcDIrk4=
|
||||
github.com/drone/drone-go v1.1.0 h1:2mritc5b7PhQWvILNyzaImZMRWVbMmmZ5Q0UDwwO7SI=
|
||||
github.com/drone/drone-go v1.1.1-0.20191119212130-1d2e07e87e79 h1:jW+dJ8HrZ1CbazlsYoriOOCQnVJ2NkfNczLHs6UMU6I=
|
||||
github.com/drone/drone-go v1.1.1-0.20191119212130-1d2e07e87e79/go.mod h1:GxyeGClYohaKNYJv/ZpsmVHtMJ7WhoT+uDaJNcDIrk4=
|
||||
github.com/drone/envsubst v1.0.2 h1:dpYLMAspQHW0a8dZpLRKe9jCNvIGZPhCPrycZzIHdqo=
|
||||
github.com/drone/envsubst v1.0.2/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0=
|
||||
github.com/drone/runner-go v1.2.2 h1:fwYgjyJl6KdjQGEUFof9+HLtNpK3iHq7UuR+/aYNyDk=
|
||||
@@ -40,6 +43,9 @@ github.com/drone/runner-go v1.2.3-0.20191031202840-a11193321443 h1:uu8lbyWKBx0Y1
|
||||
github.com/drone/runner-go v1.2.3-0.20191031202840-a11193321443/go.mod h1:61VgQWhZbNPXp01lBuR7PAztTMySGLnMzK/4oYE3D9Y=
|
||||
github.com/drone/runner-go v1.3.0 h1:RGJIk7vbvxdfd3wFyiP4XkLO+b5esCLg1aFUCIHISeE=
|
||||
github.com/drone/runner-go v1.3.0/go.mod h1:61VgQWhZbNPXp01lBuR7PAztTMySGLnMzK/4oYE3D9Y=
|
||||
github.com/drone/runner-go v1.4.0 h1:zAeYtlKQGvJr2ehfLzQWblzWzvfdkNaapbr6x536fLA=
|
||||
github.com/drone/runner-go v1.4.1-0.20191119212738-c0d9268011a7 h1:iNLp8xT0rMcV/tT2J3fCuEbWLqoP7CiL3WR8W3i3HpQ=
|
||||
github.com/drone/runner-go v1.4.1-0.20191119212738-c0d9268011a7/go.mod h1:IqwuMbIoeH45k4NemcNPwymm+l386EeyBC166UElURw=
|
||||
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
|
||||
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
|
||||
Reference in New Issue
Block a user