fix compiler unit tests, hook up daemon

This commit is contained in:
Brad Rydzewski
2019-10-22 23:13:40 -07:00
parent 22e660dda7
commit 09f19e5b99
28 changed files with 1694 additions and 791 deletions

View File

@@ -7,6 +7,7 @@ package daemon
import (
"fmt"
"os"
"runtime"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
@@ -54,12 +55,23 @@ type Config struct {
}
Runner struct {
Name string `envconfig:"DRONE_RUNNER_NAME"`
Capacity int `envconfig:"DRONE_RUNNER_CAPACITY" default:"10"`
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
Name string `envconfig:"DRONE_RUNNER_NAME"`
Capacity int `envconfig:"DRONE_RUNNER_CAPACITY" default:"2"`
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
Networks []string `envconfig:"DRONE_RUNNER_NETWORKS"`
Privileged []string `envconfig:"DRONE_RUNNER_PRIVILEGED_IMAGES"`
}
Platform struct {
OS string `envconfig:"DRONE_PLATFORM_OS"`
Arch string `envconfig:"DRONE_PLATFORM_ARCH"`
Kernel string `envconfig:"DRONE_PLATFORM_KERNEL"`
Variant string `envconfig:"DRONE_PLATFORM_VARIANT"`
}
Limit struct {
@@ -73,6 +85,16 @@ type Config struct {
Token string `envconfig:"DRONE_SECRET_PLUGIN_TOKEN"`
SkipVerify bool `envconfig:"DRONE_SECRET_PLUGIN_SKIP_VERIFY"`
}
Registry struct {
Endpoint string `envconfig:"DRONE_REGISTRY_PLUGIN_ENDPOINT"`
Token string `envconfig:"DRONE_REGISTRY_PLUGIN_SECRET"`
SkipVerify bool `envconfig:"DRONE_REGISTRY_PLUGIN_SKIP_VERIFY"`
}
Docker struct {
Config string `envconfig:"DRONE_DOCKER_CONFIG"`
}
}
func fromEnviron() (Config, error) {
@@ -93,6 +115,13 @@ 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.

View File

@@ -21,6 +21,7 @@ import (
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/registry"
"github.com/drone/runner-go/secret"
"github.com/drone/runner-go/server"
"github.com/drone/signal"
@@ -115,13 +116,21 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
config.Limit.Trusted,
),
Compiler: &compiler.Compiler{
Environ: nil,
Labels: nil,
Privileged: nil,
Networks: nil,
Volumes: nil,
Environ: config.Runner.Environ,
Privileged: config.Runner.Privileged,
Networks: config.Runner.Networks,
Volumes: config.Runner.Volumes,
// Resources: nil,
Registry: nil,
Registry: registry.Combine(
registry.File(
config.Docker.Config,
),
registry.External(
config.Registry.Endpoint,
config.Registry.Token,
config.Registry.SkipVerify,
),
),
Secret: secret.External(
config.Secret.Endpoint,
config.Secret.Token,
@@ -136,9 +145,13 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
),
},
Filter: &client.Filter{
Kind: resource.Kind,
Type: resource.Type,
Labels: config.Runner.Labels,
Kind: resource.Kind,
Type: resource.Type,
OS: config.Platform.OS,
Arch: config.Platform.Arch,
Variant: config.Platform.Variant,
Kernel: config.Platform.Kernel,
Labels: config.Runner.Labels,
},
}