Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Commit

Permalink
Add support for an environ (V2) endpoint
Browse files Browse the repository at this point in the history
Add the ability to configure a
DRONE_ENV_PLUGIN_ENDPOINT with the runner

Bump drone-go to v1.6.0
Bump runner-go to 1.7.0

tidy via `go mod tidy`
  • Loading branch information
mach6 committed Jul 5, 2022
1 parent 9decf29 commit a486f32
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 153 deletions.
15 changes: 11 additions & 4 deletions command/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import (
"github.com/drone-runners/drone-runner-exec/command/internal"
"github.com/drone-runners/drone-runner-exec/engine/compiler"
"github.com/drone-runners/drone-runner-exec/engine/resource"
"github.com/drone-runners/drone-runner-exec/runtime"

"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/secret"

Expand Down Expand Up @@ -80,18 +83,22 @@ func (c *compileCommand) run(*kingpin.ParseContext) error {

// compile the pipeline to an intermediate representation.
comp := &compiler.Compiler{
Environ: provider.Static(c.Environ),
Secret: secret.StaticVars(c.Secrets),
Root: c.Root,
}

args := runtime.CompilerArgs{
Pipeline: resource,
Manifest: manifest,
Build: c.Build,
Netrc: c.Netrc,
Repo: c.Repo,
Stage: c.Stage,
System: c.System,
Environ: c.Environ,
Secret: secret.StaticVars(c.Secrets),
Root: c.Root,
}
spec := comp.Compile(nocontext)

spec := comp.Compile(nocontext, args)

// encode the pipeline in json format and print to the
// console for inspection.
Expand Down
15 changes: 10 additions & 5 deletions command/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import (
"github.com/drone-runners/drone-runner-exec/engine/compiler"
"github.com/drone-runners/drone-runner-exec/engine/resource"
"github.com/drone-runners/drone-runner-exec/runtime"

"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/manifest"
"github.com/drone/runner-go/pipeline"
"github.com/drone/runner-go/pipeline/console"
"github.com/drone/runner-go/pipeline/streamer/console"
"github.com/drone/runner-go/secret"
"github.com/drone/signal"

Expand Down Expand Up @@ -90,18 +92,21 @@ func (c *execCommand) run(*kingpin.ParseContext) error {

// compile the pipeline to an intermediate representation.
comp := &compiler.Compiler{
Environ: provider.Static(c.Environ),
Secret: secret.StaticVars(c.Secrets),
Root: c.Root,
}

args := runtime.CompilerArgs{
Pipeline: resource,
Manifest: manifest,
Build: c.Build,
Netrc: c.Netrc,
Repo: c.Repo,
Stage: c.Stage,
System: c.System,
Environ: c.Environ,
Secret: secret.StaticVars(c.Secrets),
Root: c.Root,
}
spec := comp.Compile(nocontext)
spec := comp.Compile(nocontext, args)

// create a step object for each pipeline step.
for _, step := range spec.Steps {
Expand Down
6 changes: 6 additions & 0 deletions daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ type Config struct {
Trusted bool `envconfig:"DRONE_LIMIT_TRUSTED"`
}

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"`
Expand Down
30 changes: 21 additions & 9 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import (
"time"

"github.com/drone-runners/drone-runner-exec/engine"
"github.com/drone-runners/drone-runner-exec/engine/compiler"
"github.com/drone-runners/drone-runner-exec/engine/resource"
"github.com/drone-runners/drone-runner-exec/internal/match"
"github.com/drone-runners/drone-runner-exec/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"
"github.com/drone/runner-go/pipeline/history"
"github.com/drone/runner-go/pipeline/remote"
"github.com/drone/runner-go/pipeline/reporter/history"
"github.com/drone/runner-go/pipeline/reporter/remote"
"github.com/drone/runner-go/secret"
"github.com/drone/runner-go/server"

Expand Down Expand Up @@ -61,19 +63,29 @@ func Run(ctx context.Context, config Config) error {
Client: cli,
Environ: config.Runner.Environ,
Machine: config.Runner.Name,
Root: config.Runner.Root,
Symlinks: config.Runner.Symlinks,
Reporter: tracer,
Match: match.Func(
config.Limit.Repos,
config.Limit.Events,
config.Limit.Trusted,
),
Secret: secret.External(
config.Secret.Endpoint,
config.Secret.Token,
config.Secret.SkipVerify,
),
Compiler: &compiler.Compiler{
Environ: provider.Combine(
provider.Static(config.Runner.Environ),
provider.External(
config.Environ.Endpoint,
config.Environ.Token,
config.Environ.SkipVerify,
),
),
Secret: secret.External(
config.Secret.Endpoint,
config.Secret.Token,
config.Secret.SkipVerify,
),
Root: config.Runner.Root,
Symlinks: config.Runner.Symlinks,
},
Execer: runtime.NewExecer(
tracer,
remote,
Expand Down
Loading

0 comments on commit a486f32

Please sign in to comment.