wip adding docker run commands [ci skip]

This commit is contained in:
Brad Rydzewski
2019-10-19 11:39:16 -07:00
parent 55336ebdd6
commit 00df09b842
14 changed files with 1005 additions and 111 deletions

View File

@@ -12,6 +12,7 @@ import (
"strings"
"github.com/drone-runners/drone-runner-docker/command/internal"
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/compiler"
"github.com/drone-runners/drone-runner-docker/engine/linter"
"github.com/drone-runners/drone-runner-docker/engine/resource"
@@ -35,6 +36,7 @@ type compileCommand struct {
Labels map[string]string
Secrets map[string]string
Resources compiler.Resources
Clone bool
Config string
}
@@ -96,13 +98,6 @@ func (c *compileCommand) run(*kingpin.ParseContext) error {
// compile the pipeline to an intermediate representation.
comp := &compiler.Compiler{
Pipeline: resource,
Manifest: manifest,
Build: c.Build,
Netrc: c.Netrc,
Repo: c.Repo,
Stage: c.Stage,
System: c.System,
Environ: c.Environ,
Labels: c.Labels,
Resources: c.Resources,
@@ -114,7 +109,38 @@ func (c *compileCommand) run(*kingpin.ParseContext) error {
registry.File(c.Config),
),
}
spec := comp.Compile(nocontext)
args := compiler.Args{
Pipeline: resource,
Manifest: manifest,
Build: c.Build,
Netrc: c.Netrc,
Repo: c.Repo,
Stage: c.Stage,
System: c.System,
}
spec := comp.Compile(nocontext, args)
// when running a build locally cloning is always
// disabled in favor of mounting the source code
// from the current working directory.
if c.Clone == false {
pwd, _ := os.Getwd()
for _, volume := range spec.Volumes {
if volume.EmptyDir != nil && volume.EmptyDir.Name == "_workspace" {
volume.HostPath = &engine.VolumeHostPath{
ID: volume.EmptyDir.ID,
Name: volume.EmptyDir.Name,
Path: pwd,
}
volume.EmptyDir = nil
}
}
for _, step := range spec.Steps {
if step.Name == "clone" {
step.RunPolicy = engine.RunNever
}
}
}
// encode the pipeline in json format and print to the
// console for inspection.
@@ -138,6 +164,9 @@ func registerCompile(app *kingpin.Application) {
Default(".drone.yml").
FileVar(&c.Source)
cmd.Flag("clone", "enable cloning").
BoolVar(&c.Clone)
cmd.Flag("secrets", "secret parameters").
StringMapVar(&c.Secrets)

View File

@@ -9,6 +9,7 @@ import (
"time"
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/compiler"
"github.com/drone-runners/drone-runner-docker/engine/linter"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"github.com/drone-runners/drone-runner-docker/internal/match"
@@ -80,7 +81,6 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
Client: cli,
Runner: &runtime.Runner{
Client: cli,
Environ: config.Runner.Environ,
Machine: config.Runner.Name,
Reporter: tracer,
Linter: linter.New(),
@@ -89,11 +89,20 @@ 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: nil,
Labels: nil,
Privileged: nil,
Networks: nil,
Volumes: nil,
// Resources: nil,
Registry: nil,
Secret: secret.External(
config.Secret.Endpoint,
config.Secret.Token,
config.Secret.SkipVerify,
),
},
Execer: runtime.NewExecer(
tracer,
remote,

View File

@@ -48,6 +48,7 @@ type execCommand struct {
Labels map[string]string
Secrets map[string]string
Resources compiler.Resources
Clone bool
Config string
Pretty bool
Procs int64
@@ -116,13 +117,6 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
// compile the pipeline to an intermediate representation.
comp := &compiler.Compiler{
Pipeline: resource,
Manifest: manifest,
Build: c.Build,
Netrc: c.Netrc,
Repo: c.Repo,
Stage: c.Stage,
System: c.System,
Environ: c.Environ,
Labels: c.Labels,
Resources: c.Resources,
@@ -134,7 +128,16 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
registry.File(c.Config),
),
}
spec := comp.Compile(nocontext)
args := compiler.Args{
Pipeline: resource,
Manifest: manifest,
Build: c.Build,
Netrc: c.Netrc,
Repo: c.Repo,
Stage: c.Stage,
System: c.System,
}
spec := comp.Compile(nocontext, args)
// include only steps that are in the include list,
// if the list in non-empty.
@@ -262,6 +265,9 @@ func registerExec(app *kingpin.Application) {
Default(".drone.yml").
FileVar(&c.Source)
cmd.Flag("clone", "enable cloning").
BoolVar(&c.Clone)
cmd.Flag("secrets", "secret parameters").
StringMapVar(&c.Secrets)