Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for an environ (V2) endpoint #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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