Skip to content

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
Bump to go1.16
  • Loading branch information
mach6 committed Jul 27, 2022
1 parent bf4b140 commit a6eb3b2
Show file tree
Hide file tree
Showing 13 changed files with 263 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ platform:

steps:
- name: test
image: golang:1.13
image: golang:1.16
commands:
- go test -cover ./...
volumes:
- name: go
path: /go

- name: build
image: golang:1.13
image: golang:1.16
commands:
- sh scripts/build.sh
volumes:
Expand Down
13 changes: 10 additions & 3 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-ssh/command/internal"
"github.com/drone-runners/drone-runner-ssh/engine/compiler"
"github.com/drone-runners/drone-runner-ssh/engine/resource"
"github.com/drone-runners/drone-runner-ssh/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 @@ -79,17 +82,21 @@ 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),
}

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),
}
spec := comp.Compile(nocontext)

spec := comp.Compile(nocontext, args)

// encode the pipeline in json format and print to the
// console for inspection.
Expand Down
6 changes: 6 additions & 0 deletions command/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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
26 changes: 19 additions & 7 deletions command/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import (
"time"

"github.com/drone-runners/drone-runner-ssh/engine"
"github.com/drone-runners/drone-runner-ssh/engine/compiler"
"github.com/drone-runners/drone-runner-ssh/engine/resource"
"github.com/drone-runners/drone-runner-ssh/internal/match"
"github.com/drone-runners/drone-runner-ssh/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"
"github.com/drone/signal"
Expand Down Expand Up @@ -83,11 +85,21 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
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,
),
},
Execer: runtime.NewExecer(
tracer,
remote,
Expand Down
13 changes: 9 additions & 4 deletions command/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import (
"github.com/drone-runners/drone-runner-ssh/engine/compiler"
"github.com/drone-runners/drone-runner-ssh/engine/resource"
"github.com/drone-runners/drone-runner-ssh/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/logger"
"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 @@ -95,17 +97,20 @@ 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),
}

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),
}
spec := comp.Compile(nocontext)
spec := comp.Compile(nocontext, args)

// create a step object for each pipeline step.
for _, step := range spec.Steps {
Expand Down
Loading

0 comments on commit a6eb3b2

Please sign in to comment.