diff --git a/command/daemon/config.go b/command/daemon/config.go index 339803a..753c2e2 100644 --- a/command/daemon/config.go +++ b/command/daemon/config.go @@ -7,7 +7,6 @@ package daemon import ( "fmt" "os" - "runtime" "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" @@ -18,13 +17,6 @@ type Config struct { Debug bool `envconfig:"DRONE_DEBUG"` Trace bool `envconfig:"DRONE_TRACE"` - Logger struct { - File string `envconfig:"DRONE_LOG_FILE"` - MaxAge int `envconfig:"DRONE_LOG_FILE_MAX_AGE" default:"1"` - MaxBackups int `envconfig:"DRONE_LOG_FILE_MAX_BACKUPS" default:"1"` - MaxSize int `envconfig:"DRONE_LOG_FILE_MAX_SIZE" default:"100"` - } - Client struct { Address string `ignored:"true"` Proto string `envconfig:"DRONE_RPC_PROTO" default:"http"` @@ -60,6 +52,7 @@ type Config struct { Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"` Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"` EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"` + Secrets map[string]string `envconfig:"DRONE_RUNNER_SECRETS"` Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"` Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"` Devices []string `envconfig:"DRONE_RUNNER_DEVICES"` @@ -68,8 +61,8 @@ type Config struct { } Platform struct { - OS string `envconfig:"DRONE_PLATFORM_OS"` - Arch string `envconfig:"DRONE_PLATFORM_ARCH"` + OS string `envconfig:"DRONE_PLATFORM_OS" default:"linux"` + Arch string `envconfig:"DRONE_PLATFORM_ARCH" default:"amd64"` Kernel string `envconfig:"DRONE_PLATFORM_KERNEL"` Variant string `envconfig:"DRONE_PLATFORM_VARIANT"` } @@ -115,13 +108,6 @@ func fromEnviron() (Config, error) { config.Client.Host, ) - if config.Platform.OS == "" { - config.Platform.OS = runtime.GOOS - } - if config.Platform.Arch == "" { - config.Platform.Arch = runtime.GOARCH - } - // environment variables can be sourced from a separate // file. These variables are loaded and appended to the // environment list. diff --git a/command/daemon/daemon.go b/command/daemon/daemon.go index 88d35af..26ef741 100644 --- a/command/daemon/daemon.go +++ b/command/daemon/daemon.go @@ -117,7 +117,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error { ), Compiler: &compiler.Compiler{ Environ: config.Runner.Environ, - Privileged: config.Runner.Privileged, + Privileged: append(config.Runner.Privileged, compiler.Privileged...), Networks: config.Runner.Networks, Volumes: config.Runner.Volumes, // Resources: nil, @@ -131,10 +131,15 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error { config.Registry.SkipVerify, ), ), - Secret: secret.External( - config.Secret.Endpoint, - config.Secret.Token, - config.Secret.SkipVerify, + Secret: secret.Combine( + secret.StaticVars( + config.Runner.Secrets, + ), + secret.External( + config.Secret.Endpoint, + config.Secret.Token, + config.Secret.SkipVerify, + ), ), }, Execer: runtime.NewExecer( diff --git a/engine/compiler/clone.go b/engine/compiler/clone.go index a268966..65730f0 100644 --- a/engine/compiler/clone.go +++ b/engine/compiler/clone.go @@ -22,7 +22,7 @@ func cloneImage(platform manifest.Platform) string { case "windows": return "drone/git:latest" default: - return "drone/git:1" + return "drone/git:latest" } } diff --git a/engine/compiler/clone_test.go b/engine/compiler/clone_test.go index 0799f8e..e1ca870 100644 --- a/engine/compiler/clone_test.go +++ b/engine/compiler/clone_test.go @@ -41,7 +41,7 @@ func TestClone(t *testing.T) { want := []*engine.Step{ { ID: "random", - Image: "drone/git:1", + Image: "drone/git:latest", Name: "clone", Pull: engine.PullDefault, RunPolicy: engine.RunAlways, @@ -84,7 +84,7 @@ func TestCloneDisable(t *testing.T) { func TestCloneCreate(t *testing.T) { want := &engine.Step{ Name: "clone", - Image: "drone/git:1", + Image: "drone/git:latest", RunPolicy: engine.RunAlways, Envs: map[string]string{"PLUGIN_DEPTH": "50"}, } @@ -102,11 +102,11 @@ func TestCloneImage(t *testing.T) { }{ { in: manifest.Platform{}, - out: "drone/git:1", + out: "drone/git:latest", }, { in: manifest.Platform{OS: "linux"}, - out: "drone/git:1", + out: "drone/git:latest", }, { in: manifest.Platform{OS: "windows"}, diff --git a/engine/compiler/testdata/graph.json b/engine/compiler/testdata/graph.json index 3862fd4..ff02bc6 100644 --- a/engine/compiler/testdata/graph.json +++ b/engine/compiler/testdata/graph.json @@ -4,7 +4,7 @@ { "id": "random", "environment": {}, - "image": "drone/git:1", + "image": "drone/git:latest", "labels": {}, "name": "clone", "run_policy": "always", diff --git a/engine/compiler/testdata/serial.json b/engine/compiler/testdata/serial.json index 3862fd4..ff02bc6 100644 --- a/engine/compiler/testdata/serial.json +++ b/engine/compiler/testdata/serial.json @@ -4,7 +4,7 @@ { "id": "random", "environment": {}, - "image": "drone/git:1", + "image": "drone/git:latest", "labels": {}, "name": "clone", "run_policy": "always", diff --git a/runtime/runner.go b/runtime/runner.go index 819eea6..96a70f1 100644 --- a/runtime/runner.go +++ b/runtime/runner.go @@ -76,6 +76,10 @@ func (s *Runner) Run(ctx context.Context, stage *drone.Stage) error { stage.Machine = s.Machine err := s.Client.Accept(ctx, stage) + if err != nil && err == client.ErrOptimisticLock { + log.Debug("stage accepted by another runner") + return nil + } if err != nil { log.WithError(err).Error("cannot accept stage") return err