fix compiler unit tests, hook up daemon
This commit is contained in:
@@ -7,6 +7,7 @@ package daemon
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/kelseyhightower/envconfig"
|
"github.com/kelseyhightower/envconfig"
|
||||||
@@ -54,12 +55,23 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Runner struct {
|
Runner struct {
|
||||||
Name string `envconfig:"DRONE_RUNNER_NAME"`
|
Name string `envconfig:"DRONE_RUNNER_NAME"`
|
||||||
Capacity int `envconfig:"DRONE_RUNNER_CAPACITY" default:"10"`
|
Capacity int `envconfig:"DRONE_RUNNER_CAPACITY" default:"2"`
|
||||||
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
|
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
|
||||||
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
|
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
|
||||||
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
|
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
|
||||||
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 {
|
Limit struct {
|
||||||
@@ -73,6 +85,16 @@ type Config struct {
|
|||||||
Token string `envconfig:"DRONE_SECRET_PLUGIN_TOKEN"`
|
Token string `envconfig:"DRONE_SECRET_PLUGIN_TOKEN"`
|
||||||
SkipVerify bool `envconfig:"DRONE_SECRET_PLUGIN_SKIP_VERIFY"`
|
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) {
|
func fromEnviron() (Config, error) {
|
||||||
@@ -93,6 +115,13 @@ func fromEnviron() (Config, error) {
|
|||||||
config.Client.Host,
|
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
|
// environment variables can be sourced from a separate
|
||||||
// file. These variables are loaded and appended to the
|
// file. These variables are loaded and appended to the
|
||||||
// environment list.
|
// environment list.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
loghistory "github.com/drone/runner-go/logger/history"
|
loghistory "github.com/drone/runner-go/logger/history"
|
||||||
"github.com/drone/runner-go/pipeline/history"
|
"github.com/drone/runner-go/pipeline/history"
|
||||||
"github.com/drone/runner-go/pipeline/remote"
|
"github.com/drone/runner-go/pipeline/remote"
|
||||||
|
"github.com/drone/runner-go/registry"
|
||||||
"github.com/drone/runner-go/secret"
|
"github.com/drone/runner-go/secret"
|
||||||
"github.com/drone/runner-go/server"
|
"github.com/drone/runner-go/server"
|
||||||
"github.com/drone/signal"
|
"github.com/drone/signal"
|
||||||
@@ -115,13 +116,21 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
config.Limit.Trusted,
|
config.Limit.Trusted,
|
||||||
),
|
),
|
||||||
Compiler: &compiler.Compiler{
|
Compiler: &compiler.Compiler{
|
||||||
Environ: nil,
|
Environ: config.Runner.Environ,
|
||||||
Labels: nil,
|
Privileged: config.Runner.Privileged,
|
||||||
Privileged: nil,
|
Networks: config.Runner.Networks,
|
||||||
Networks: nil,
|
Volumes: config.Runner.Volumes,
|
||||||
Volumes: nil,
|
|
||||||
// Resources: nil,
|
// 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(
|
Secret: secret.External(
|
||||||
config.Secret.Endpoint,
|
config.Secret.Endpoint,
|
||||||
config.Secret.Token,
|
config.Secret.Token,
|
||||||
@@ -136,9 +145,13 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
Filter: &client.Filter{
|
Filter: &client.Filter{
|
||||||
Kind: resource.Kind,
|
Kind: resource.Kind,
|
||||||
Type: resource.Type,
|
Type: resource.Type,
|
||||||
Labels: config.Runner.Labels,
|
OS: config.Platform.OS,
|
||||||
|
Arch: config.Platform.Arch,
|
||||||
|
Variant: config.Platform.Variant,
|
||||||
|
Kernel: config.Platform.Kernel,
|
||||||
|
Labels: config.Runner.Labels,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ USER ContainerAdministrator
|
|||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV GODEBUG=netdns=go
|
ENV GODEBUG=netdns=go
|
||||||
|
ENV DRONE_PLATFORM_OS windows
|
||||||
|
ENV DRONE_PLATFORM_ARCH amd64
|
||||||
|
ENV DRONE_PLATFORM_KERNEL 1809
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe
|
ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe
|
||||||
ENTRYPOINT [ "C:\\drone-runner-docker.exe" ]
|
ENTRYPOINT [ "C:\\drone-runner-docker.exe" ]
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ FROM mcr.microsoft.com/windows/nanoserver:1903
|
|||||||
USER ContainerAdministrator
|
USER ContainerAdministrator
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV GODEBUG=netdns=go
|
ENV GODEBUG netdns=go
|
||||||
|
ENV DRONE_PLATFORM_OS windows
|
||||||
|
ENV DRONE_PLATFORM_ARCH amd64
|
||||||
|
ENV DRONE_PLATFORM_KERNEL 1903
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe
|
ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe
|
||||||
ENTRYPOINT [ "C:\\drone-runner-docker.exe" ]
|
ENTRYPOINT [ "C:\\drone-runner-docker.exe" ]
|
||||||
@@ -5,8 +5,10 @@ FROM alpine:3.6
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV GODEBUG netdns=go
|
ENV GODEBUG netdns=go
|
||||||
|
ENV DRONE_PLATFORM_OS linux
|
||||||
|
ENV DRONE_PLATFORM_ARCH arm64
|
||||||
|
|
||||||
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
ADD release/linux/amd64/drone-runner-docker /bin/
|
ADD release/linux/arm64/drone-runner-docker /bin/
|
||||||
ENTRYPOINT ["/bin/drone-runner-docker"]
|
ENTRYPOINT ["/bin/drone-runner-docker"]
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ FROM alpine:3.6
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV GODEBUG netdns=go
|
ENV GODEBUG netdns=go
|
||||||
|
ENV DRONE_PLATFORM_OS linux
|
||||||
|
ENV DRONE_PLATFORM_ARCH arm
|
||||||
|
|
||||||
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ FROM alpine:3.6
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV GODEBUG netdns=go
|
ENV GODEBUG netdns=go
|
||||||
|
ENV DRONE_PLATFORM_OS linux
|
||||||
|
ENV DRONE_PLATFORM_ARCH amd64
|
||||||
|
|
||||||
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import (
|
|||||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||||
"github.com/drone/drone-go/drone"
|
"github.com/drone/drone-go/drone"
|
||||||
"github.com/drone/runner-go/manifest"
|
"github.com/drone/runner-go/manifest"
|
||||||
|
"github.com/drone/runner-go/registry"
|
||||||
|
"github.com/drone/runner-go/secret"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
@@ -24,6 +26,10 @@ func TestClone(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
c := &Compiler{
|
c := &Compiler{
|
||||||
|
Registry: registry.Static(nil),
|
||||||
|
Secret: secret.Static(nil),
|
||||||
|
}
|
||||||
|
args := Args{
|
||||||
Repo: &drone.Repo{},
|
Repo: &drone.Repo{},
|
||||||
Build: &drone.Build{},
|
Build: &drone.Build{},
|
||||||
Stage: &drone.Stage{},
|
Stage: &drone.Stage{},
|
||||||
@@ -37,12 +43,19 @@ func TestClone(t *testing.T) {
|
|||||||
ID: "random",
|
ID: "random",
|
||||||
Image: "drone/git:1",
|
Image: "drone/git:1",
|
||||||
Name: "clone",
|
Name: "clone",
|
||||||
|
Pull: engine.PullDefault,
|
||||||
RunPolicy: engine.RunAlways,
|
RunPolicy: engine.RunAlways,
|
||||||
WorkingDir: "/drone/src",
|
WorkingDir: "/drone/src",
|
||||||
|
Volumes: []*engine.VolumeMount{
|
||||||
|
&engine.VolumeMount{
|
||||||
|
Name: "_workspace",
|
||||||
|
Path: "/drone/src",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
got := c.Compile(nil)
|
got := c.Compile(nocontext, args)
|
||||||
ignore := cmpopts.IgnoreFields(engine.Step{}, "Envs")
|
ignore := cmpopts.IgnoreFields(engine.Step{}, "Envs", "Labels")
|
||||||
if diff := cmp.Diff(got.Steps, want, ignore); len(diff) != 0 {
|
if diff := cmp.Diff(got.Steps, want, ignore); len(diff) != 0 {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
@@ -50,6 +63,10 @@ func TestClone(t *testing.T) {
|
|||||||
|
|
||||||
func TestCloneDisable(t *testing.T) {
|
func TestCloneDisable(t *testing.T) {
|
||||||
c := &Compiler{
|
c := &Compiler{
|
||||||
|
Registry: registry.Static(nil),
|
||||||
|
Secret: secret.Static(nil),
|
||||||
|
}
|
||||||
|
args := Args{
|
||||||
Repo: &drone.Repo{},
|
Repo: &drone.Repo{},
|
||||||
Build: &drone.Build{},
|
Build: &drone.Build{},
|
||||||
Stage: &drone.Stage{},
|
Stage: &drone.Stage{},
|
||||||
@@ -58,7 +75,7 @@ func TestCloneDisable(t *testing.T) {
|
|||||||
Manifest: &manifest.Manifest{},
|
Manifest: &manifest.Manifest{},
|
||||||
Pipeline: &resource.Pipeline{Clone: manifest.Clone{Disable: true}},
|
Pipeline: &resource.Pipeline{Clone: manifest.Clone{Disable: true}},
|
||||||
}
|
}
|
||||||
got := c.Compile(nil)
|
got := c.Compile(nocontext, args)
|
||||||
if len(got.Steps) != 0 {
|
if len(got.Steps) != 0 {
|
||||||
t.Errorf("Expect no clone step added when disabled")
|
t.Errorf("Expect no clone step added when disabled")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||||
"github.com/drone/drone-go/drone"
|
"github.com/drone/drone-go/drone"
|
||||||
"github.com/drone/runner-go/manifest"
|
"github.com/drone/runner-go/manifest"
|
||||||
|
"github.com/drone/runner-go/registry"
|
||||||
"github.com/drone/runner-go/secret"
|
"github.com/drone/runner-go/secret"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
@@ -82,7 +83,7 @@ func TestCompile_RunAlways(t *testing.T) {
|
|||||||
|
|
||||||
// This test verifies that steps configured to run on failure
|
// This test verifies that steps configured to run on failure
|
||||||
// are configured to run on failure.
|
// are configured to run on failure.
|
||||||
func TestCompile_RunFaiure(t *testing.T) {
|
func TestCompile_RunFailure(t *testing.T) {
|
||||||
ir := testCompile(t, "testdata/run_failure.yml", "testdata/run_failure.json")
|
ir := testCompile(t, "testdata/run_failure.yml", "testdata/run_failure.json")
|
||||||
if ir.Steps[0].RunPolicy != engine.RunOnFailure {
|
if ir.Steps[0].RunPolicy != engine.RunOnFailure {
|
||||||
t.Errorf("Expect run on failure")
|
t.Errorf("Expect run on failure")
|
||||||
@@ -94,20 +95,27 @@ func TestCompile_RunFaiure(t *testing.T) {
|
|||||||
// at compile time.
|
// at compile time.
|
||||||
func TestCompile_Secrets(t *testing.T) {
|
func TestCompile_Secrets(t *testing.T) {
|
||||||
manifest, _ := manifest.ParseFile("testdata/secret.yml")
|
manifest, _ := manifest.ParseFile("testdata/secret.yml")
|
||||||
compiler := Compiler{}
|
|
||||||
compiler.Build = &drone.Build{}
|
compiler := &Compiler{
|
||||||
compiler.Repo = &drone.Repo{}
|
Registry: registry.Static(nil),
|
||||||
compiler.Stage = &drone.Stage{}
|
Secret: secret.StaticVars(map[string]string{
|
||||||
compiler.System = &drone.System{}
|
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
||||||
compiler.Netrc = &drone.Netrc{}
|
"password": "password",
|
||||||
compiler.Manifest = manifest
|
"my_username": "octocat",
|
||||||
compiler.Pipeline = manifest.Resources[0].(*resource.Pipeline)
|
}),
|
||||||
compiler.Secret = secret.StaticVars(map[string]string{
|
}
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
args := Args{
|
||||||
"password": "password",
|
Repo: &drone.Repo{},
|
||||||
"my_username": "octocat",
|
Build: &drone.Build{},
|
||||||
})
|
Stage: &drone.Stage{},
|
||||||
ir := compiler.Compile(nocontext)
|
System: &drone.System{},
|
||||||
|
Netrc: &drone.Netrc{},
|
||||||
|
Manifest: manifest,
|
||||||
|
Pipeline: manifest.Resources[0].(*resource.Pipeline),
|
||||||
|
Secret: secret.Static(nil),
|
||||||
|
}
|
||||||
|
|
||||||
|
ir := compiler.Compile(nocontext, args)
|
||||||
got := ir.Steps[0].Secrets
|
got := ir.Steps[0].Secrets
|
||||||
want := []*engine.Secret{
|
want := []*engine.Secret{
|
||||||
{
|
{
|
||||||
@@ -149,15 +157,26 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
compiler := Compiler{}
|
compiler := &Compiler{
|
||||||
compiler.Build = &drone.Build{Target: "master"}
|
Registry: registry.Static(nil),
|
||||||
compiler.Repo = &drone.Repo{}
|
Secret: secret.StaticVars(map[string]string{
|
||||||
compiler.Stage = &drone.Stage{}
|
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
||||||
compiler.System = &drone.System{}
|
"password": "password",
|
||||||
compiler.Netrc = &drone.Netrc{Machine: "github.com", Login: "octocat", Password: "correct-horse-battery-staple"}
|
"my_username": "octocat",
|
||||||
compiler.Manifest = manifest
|
}),
|
||||||
compiler.Pipeline = manifest.Resources[0].(*resource.Pipeline)
|
}
|
||||||
got := compiler.Compile(nocontext)
|
args := Args{
|
||||||
|
Repo: &drone.Repo{},
|
||||||
|
Build: &drone.Build{Target: "master"},
|
||||||
|
Stage: &drone.Stage{},
|
||||||
|
System: &drone.System{},
|
||||||
|
Netrc: &drone.Netrc{Machine: "github.com", Login: "octocat", Password: "correct-horse-battery-staple"},
|
||||||
|
Manifest: manifest,
|
||||||
|
Pipeline: manifest.Resources[0].(*resource.Pipeline),
|
||||||
|
Secret: secret.Static(nil),
|
||||||
|
}
|
||||||
|
|
||||||
|
got := compiler.Compile(nocontext, args)
|
||||||
|
|
||||||
raw, err := ioutil.ReadFile(golden)
|
raw, err := ioutil.ReadFile(golden)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -170,10 +189,15 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore := cmpopts.IgnoreFields(engine.Step{}, "Envs", "Secrets")
|
opts := cmp.Options{
|
||||||
unexported := cmpopts.IgnoreUnexported(engine.Spec{})
|
cmpopts.IgnoreUnexported(engine.Spec{}),
|
||||||
if diff := cmp.Diff(got, want, ignore, unexported); len(diff) != 0 {
|
cmpopts.IgnoreFields(engine.Step{}, "Envs", "Secrets", "Labels"),
|
||||||
|
cmpopts.IgnoreFields(engine.Network{}, "Labels"),
|
||||||
|
cmpopts.IgnoreFields(engine.VolumeEmptyDir{}, "Labels"),
|
||||||
|
}
|
||||||
|
if diff := cmp.Diff(got, want, opts...); len(diff) != 0 {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
|
dump(got)
|
||||||
}
|
}
|
||||||
|
|
||||||
return got
|
return got
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Polyform License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package compiler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/drone/runner-go/shell/bash"
|
|
||||||
"github.com/drone/runner-go/shell/powershell"
|
|
||||||
)
|
|
||||||
|
|
||||||
// helper function returns the base temporary directory based
|
|
||||||
// on the target platform.
|
|
||||||
func tempdir(os string) string {
|
|
||||||
dir := fmt.Sprintf("drone-%s", random())
|
|
||||||
switch os {
|
|
||||||
case "windows":
|
|
||||||
return join(os, "C:\\Windows\\Temp", dir)
|
|
||||||
default:
|
|
||||||
return join(os, "/tmp", dir)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function joins the file paths.
|
|
||||||
func join(os string, paths ...string) string {
|
|
||||||
switch os {
|
|
||||||
case "windows":
|
|
||||||
return strings.Join(paths, "\\")
|
|
||||||
default:
|
|
||||||
return strings.Join(paths, "/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function returns the shell extension based on the
|
|
||||||
// target platform.
|
|
||||||
func getExt(os, file string) (s string) {
|
|
||||||
switch os {
|
|
||||||
case "windows":
|
|
||||||
return file + ".ps1"
|
|
||||||
default:
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// TODO(bradrydzewski) can we remove the below functions?
|
|
||||||
//
|
|
||||||
|
|
||||||
// helper function returns the shell command and arguments
|
|
||||||
// based on the target platform to invoke the script
|
|
||||||
func getCommand(os, script string) (string, []string) {
|
|
||||||
cmd, args := bash.Command()
|
|
||||||
switch os {
|
|
||||||
case "windows":
|
|
||||||
cmd, args = powershell.Command()
|
|
||||||
}
|
|
||||||
return cmd, append(args, script)
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function returns the netrc file name based on the
|
|
||||||
// target platform.
|
|
||||||
func getNetrc(os string) string {
|
|
||||||
switch os {
|
|
||||||
case "windows":
|
|
||||||
return "_netrc"
|
|
||||||
default:
|
|
||||||
return ".netrc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function generates and returns a shell script to
|
|
||||||
// execute the provided shell commands. The shell scripting
|
|
||||||
// language (bash vs pwoershell) is determined by the operating
|
|
||||||
// system.
|
|
||||||
func genScript(os string, commands []string) string {
|
|
||||||
switch os {
|
|
||||||
case "windows":
|
|
||||||
return powershell.Script(commands)
|
|
||||||
default:
|
|
||||||
return bash.Script(commands)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Polyform License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package compiler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/drone/runner-go/shell/bash"
|
|
||||||
"github.com/drone/runner-go/shell/powershell"
|
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test_tempdir(t *testing.T) {
|
|
||||||
// replace the default random function with one that
|
|
||||||
// is deterministic, for testing purposes.
|
|
||||||
random = notRandom
|
|
||||||
|
|
||||||
// restore the default random function and the previously
|
|
||||||
// specified temporary directory
|
|
||||||
defer func() {
|
|
||||||
random = uniuri.New
|
|
||||||
}()
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
os string
|
|
||||||
path string
|
|
||||||
}{
|
|
||||||
{os: "windows", path: "C:\\Windows\\Temp\\drone-random"},
|
|
||||||
{os: "linux", path: "/tmp/drone-random"},
|
|
||||||
{os: "openbsd", path: "/tmp/drone-random"},
|
|
||||||
{os: "netbsd", path: "/tmp/drone-random"},
|
|
||||||
{os: "freebsd", path: "/tmp/drone-random"},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
if got, want := tempdir(test.os), test.path; got != want {
|
|
||||||
t.Errorf("Want tempdir %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_join(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
os string
|
|
||||||
a []string
|
|
||||||
b string
|
|
||||||
}{
|
|
||||||
{os: "windows", a: []string{"C:", "Windows", "Temp"}, b: "C:\\Windows\\Temp"},
|
|
||||||
{os: "linux", a: []string{"/tmp", "foo", "bar"}, b: "/tmp/foo/bar"},
|
|
||||||
}
|
|
||||||
for _, test := range tests {
|
|
||||||
if got, want := join(test.os, test.a...), test.b; got != want {
|
|
||||||
t.Errorf("Want %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_getExt(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
os string
|
|
||||||
a string
|
|
||||||
b string
|
|
||||||
}{
|
|
||||||
{os: "windows", a: "clone", b: "clone.ps1"},
|
|
||||||
{os: "linux", a: "clone", b: "clone"},
|
|
||||||
}
|
|
||||||
for _, test := range tests {
|
|
||||||
if got, want := getExt(test.os, test.a), test.b; got != want {
|
|
||||||
t.Errorf("Want %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_getCommand(t *testing.T) {
|
|
||||||
cmd, args := getCommand("linux", "clone.sh")
|
|
||||||
if got, want := cmd, "/bin/sh"; got != want {
|
|
||||||
t.Errorf("Want command %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(args, []string{"-e", "clone.sh"}) {
|
|
||||||
t.Errorf("Unexpected args %v", args)
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd, args = getCommand("windows", "clone.ps1")
|
|
||||||
if got, want := cmd, "powershell"; got != want {
|
|
||||||
t.Errorf("Want command %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(args, []string{"-noprofile", "-noninteractive", "-command", "clone.ps1"}) {
|
|
||||||
t.Errorf("Unexpected args %v", args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_getNetrc(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
os string
|
|
||||||
name string
|
|
||||||
}{
|
|
||||||
{os: "windows", name: "_netrc"},
|
|
||||||
{os: "linux", name: ".netrc"},
|
|
||||||
{os: "openbsd", name: ".netrc"},
|
|
||||||
{os: "netbsd", name: ".netrc"},
|
|
||||||
{os: "freebsd", name: ".netrc"},
|
|
||||||
}
|
|
||||||
for _, test := range tests {
|
|
||||||
if got, want := getNetrc(test.os), test.name; got != want {
|
|
||||||
t.Errorf("Want %s on %s, got %s", want, test.os, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_getScript(t *testing.T) {
|
|
||||||
commands := []string{"go build"}
|
|
||||||
|
|
||||||
a := genScript("windows", commands)
|
|
||||||
b := powershell.Script(commands)
|
|
||||||
if !reflect.DeepEqual(a, b) {
|
|
||||||
t.Errorf("Generated windows linux script")
|
|
||||||
}
|
|
||||||
|
|
||||||
a = genScript("linux", commands)
|
|
||||||
b = bash.Script(commands)
|
|
||||||
if !reflect.DeepEqual(a, b) {
|
|
||||||
t.Errorf("Generated invalid linux script")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,8 @@ import (
|
|||||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// helper function configures the pipeline script for the
|
||||||
|
// target operating system.
|
||||||
func setupScript(src *resource.Step, dst *engine.Step, os string) {
|
func setupScript(src *resource.Step, dst *engine.Step, os string) {
|
||||||
if len(src.Commands) > 0 {
|
if len(src.Commands) > 0 {
|
||||||
switch os {
|
switch os {
|
||||||
@@ -22,12 +24,16 @@ func setupScript(src *resource.Step, dst *engine.Step, os string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper function configures the pipeline script for the
|
||||||
|
// windows operating system.
|
||||||
func setupScriptWindows(src *resource.Step, dst *engine.Step) {
|
func setupScriptWindows(src *resource.Step, dst *engine.Step) {
|
||||||
dst.Entrypoint = []string{"powershell", "-noprofile", "-noninteractive", "-command"}
|
dst.Entrypoint = []string{"powershell", "-noprofile", "-noninteractive", "-command"}
|
||||||
dst.Command = []string{"echo $DRONE_SCRIPT | iex"}
|
dst.Command = []string{"echo $DRONE_SCRIPT | iex"}
|
||||||
dst.Envs["DRONE_SCRIPT"] = powershell.Script(src.Commands)
|
dst.Envs["DRONE_SCRIPT"] = powershell.Script(src.Commands)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper function configures the pipeline script for the
|
||||||
|
// linux operating system.
|
||||||
func setupScriptPosix(src *resource.Step, dst *engine.Step) {
|
func setupScriptPosix(src *resource.Step, dst *engine.Step) {
|
||||||
dst.Entrypoint = []string{"/bin/sh", "-c"}
|
dst.Entrypoint = []string{"/bin/sh", "-c"}
|
||||||
dst.Command = []string{`echo "$DRONE_SCRIPT" | /bin/sh`}
|
dst.Command = []string{`echo "$DRONE_SCRIPT" | /bin/sh`}
|
||||||
|
|||||||
412
engine/compiler/testdata/graph.json
vendored
412
engine/compiler/testdata/graph.json
vendored
@@ -1,104 +1,366 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"args": [
|
"id": "random",
|
||||||
"-e",
|
"environment": {
|
||||||
"/tmp/drone-random/opt/clone"
|
"CI": "true",
|
||||||
],
|
"DRONE": "true",
|
||||||
"command": "/bin/sh",
|
"DRONE_BRANCH": "master",
|
||||||
"files": [
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571810984",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571810984",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571810984",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571810984",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"image": "drone/git:1",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810984",
|
||||||
|
"io.drone.expires": "1571814584",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "clone",
|
||||||
|
"run_policy": "always",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/clone",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnaXQgaW5pdCIKZ2l0IGluaXQKCmVjaG8gKyAiZ2l0IHJlbW90ZSBhZGQgb3JpZ2luICIKZ2l0IHJlbW90ZSBhZGQgb3JpZ2luIAoKZWNobyArICJnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6IgpnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6CgplY2hvICsgImdpdCBjaGVja291dCAgLWIgbWFzdGVyIgpnaXQgY2hlY2tvdXQgIC1iIG1hc3Rlcgo="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"secrets": [],
|
"working_dir": "/drone/src"
|
||||||
"name": "clone",
|
|
||||||
"run_policy": 2,
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
|
||||||
"depends_on": [
|
"depends_on": [
|
||||||
"clone"
|
"clone"
|
||||||
],
|
],
|
||||||
"files": [
|
"entrypoint": [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571810984",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571810984",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go build\"\ngo build\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571810984",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571810984",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810984",
|
||||||
|
"io.drone.expires": "1571814584",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "build",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"secrets": [],
|
"working_dir": "/drone/src"
|
||||||
"name": "build",
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/test"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
|
||||||
"depends_on": [
|
"depends_on": [
|
||||||
"build"
|
"build"
|
||||||
],
|
],
|
||||||
"files": [
|
"entrypoint": [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571810984",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571810984",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go test\"\ngo test\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571810984",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571810984",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810984",
|
||||||
|
"io.drone.expires": "1571814584",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "test",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/test",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"secrets": [],
|
"working_dir": "/drone/src"
|
||||||
"name": "test",
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810984",
|
||||||
|
"io.drone.expires": "1571814584",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810984",
|
||||||
|
"io.drone.expires": "1571814584",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
304
engine/compiler/testdata/match.json
vendored
304
engine/compiler/testdata/match.json
vendored
@@ -1,82 +1,264 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
"entrypoint": [
|
||||||
"files": [
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571811065",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571811065",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go build\"\ngo build\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571811065",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571811065",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811065",
|
||||||
|
"io.drone.expires": "1571814665",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "build",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "build",
|
"working_dir": "/drone/src"
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/test"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
|
||||||
"depends_on": [
|
"depends_on": [
|
||||||
"build"
|
"build"
|
||||||
],
|
],
|
||||||
"files": [
|
"entrypoint": [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571811065",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571811065",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go test\"\ngo test\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571811065",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571811065",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811065",
|
||||||
|
"io.drone.expires": "1571814665",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "test",
|
||||||
|
"run_policy": "never",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/test",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "test",
|
"working_dir": "/drone/src"
|
||||||
"run_policy": 3,
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811065",
|
||||||
|
"io.drone.expires": "1571814665",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811065",
|
||||||
|
"io.drone.expires": "1571814665",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
304
engine/compiler/testdata/noclone_graph.json
vendored
304
engine/compiler/testdata/noclone_graph.json
vendored
@@ -1,83 +1,263 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
"entrypoint": [
|
||||||
"files": [
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571811036",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571811036",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go build\"\ngo build\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571811036",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571811036",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811036",
|
||||||
|
"io.drone.expires": "1571814636",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "build",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "build",
|
"working_dir": "/drone/src"
|
||||||
"secrets": [],
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/test"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
|
||||||
"depends_on": [
|
"depends_on": [
|
||||||
"build"
|
"build"
|
||||||
],
|
],
|
||||||
"files": [
|
"entrypoint": [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571811036",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571811036",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go test\"\ngo test\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571811036",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571811036",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811036",
|
||||||
|
"io.drone.expires": "1571814636",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "test",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/test",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "test",
|
"working_dir": "/drone/src"
|
||||||
"secrets": [],
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811036",
|
||||||
|
"io.drone.expires": "1571814636",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811036",
|
||||||
|
"io.drone.expires": "1571814636",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
194
engine/compiler/testdata/noclone_serial.json
vendored
194
engine/compiler/testdata/noclone_serial.json
vendored
@@ -1,62 +1,154 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
"entrypoint": [
|
||||||
"files": [
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571811007",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571811007",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go build\"\ngo build\n\necho + \"go test\"\ngo test\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571811007",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571811007",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811007",
|
||||||
|
"io.drone.expires": "1571814607",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "build",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCmVjaG8gKyAiZ28gdGVzdCIKZ28gdGVzdAo="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "build",
|
"working_dir": "/drone/src"
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811007",
|
||||||
|
"io.drone.expires": "1571814607",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571811007",
|
||||||
|
"io.drone.expires": "1571814607",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
80
engine/compiler/testdata/run_always.json
vendored
80
engine/compiler/testdata/run_always.json
vendored
@@ -1,63 +1,39 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
"entrypoint": [
|
||||||
"files": [
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {},
|
||||||
|
"labels": {},
|
||||||
|
"name": "build",
|
||||||
|
"run_policy": "always",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "build",
|
"working_dir": "/drone/src"
|
||||||
"run_policy": 2,
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
80
engine/compiler/testdata/run_failure.json
vendored
80
engine/compiler/testdata/run_failure.json
vendored
@@ -1,63 +1,39 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
"entrypoint": [
|
||||||
"files": [
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {},
|
||||||
|
"labels": {},
|
||||||
|
"name": "build",
|
||||||
|
"run_policy": "on-failure",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "build",
|
"working_dir": "/drone/src"
|
||||||
"run_policy": 1,
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
412
engine/compiler/testdata/serial.json
vendored
412
engine/compiler/testdata/serial.json
vendored
@@ -1,104 +1,366 @@
|
|||||||
{
|
{
|
||||||
"platform": {},
|
"platform": {},
|
||||||
"token": "3DA541559918A808C2402BBA5012F6C60B27661C",
|
|
||||||
"server": {
|
|
||||||
"name": "drone-temp-random",
|
|
||||||
"image": "docker-18-04",
|
|
||||||
"region": "nyc1",
|
|
||||||
"size": "s-1vcpu-1gb",
|
|
||||||
"user": "root"
|
|
||||||
},
|
|
||||||
"root": "/tmp/drone-random",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/drone/src",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/opt",
|
|
||||||
"mode": 448,
|
|
||||||
"is_dir": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/tmp/drone-random/home/drone/.netrc",
|
|
||||||
"mode": 384,
|
|
||||||
"data": "bWFjaGluZSBnaXRodWIuY29tIGxvZ2luIG9jdG9jYXQgcGFzc3dvcmQgY29ycmVjdC1ob3JzZS1iYXR0ZXJ5LXN0YXBsZQ=="
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"args": [
|
"id": "random",
|
||||||
"-e",
|
"environment": {
|
||||||
"/tmp/drone-random/opt/clone"
|
"CI": "true",
|
||||||
],
|
"DRONE": "true",
|
||||||
"command": "/bin/sh",
|
"DRONE_BRANCH": "master",
|
||||||
"files": [
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571810939",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571810939",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571810939",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571810939",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"image": "drone/git:1",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810939",
|
||||||
|
"io.drone.expires": "1571814539",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "clone",
|
||||||
|
"run_policy": "always",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/clone",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnaXQgaW5pdCIKZ2l0IGluaXQKCmVjaG8gKyAiZ2l0IHJlbW90ZSBhZGQgb3JpZ2luICIKZ2l0IHJlbW90ZSBhZGQgb3JpZ2luIAoKZWNobyArICJnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6IgpnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6CgplY2hvICsgImdpdCBjaGVja291dCAgLWIgbWFzdGVyIgpnaXQgY2hlY2tvdXQgIC1iIG1hc3Rlcgo="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"secrets": [],
|
"working_dir": "/drone/src"
|
||||||
"name": "clone",
|
|
||||||
"run_policy": 2,
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/build"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
|
||||||
"depends_on": [
|
"depends_on": [
|
||||||
"clone"
|
"clone"
|
||||||
],
|
],
|
||||||
"files": [
|
"entrypoint": [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571810939",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571810939",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go build\"\ngo build\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571810939",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571810939",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810939",
|
||||||
|
"io.drone.expires": "1571814539",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "build",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/build",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"secrets": [],
|
"working_dir": "/drone/src"
|
||||||
"name": "build",
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "random",
|
||||||
"args": [
|
"args": [
|
||||||
"-e",
|
"echo \"$DRONE_SCRIPT\" | /bin/sh"
|
||||||
"/tmp/drone-random/opt/test"
|
|
||||||
],
|
],
|
||||||
"command": "/bin/sh",
|
|
||||||
"depends_on": [
|
"depends_on": [
|
||||||
"build"
|
"build"
|
||||||
],
|
],
|
||||||
"files": [
|
"entrypoint": [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c"
|
||||||
|
],
|
||||||
|
"environment": {
|
||||||
|
"CI": "true",
|
||||||
|
"DRONE": "true",
|
||||||
|
"DRONE_BRANCH": "master",
|
||||||
|
"DRONE_BUILD_ACTION": "",
|
||||||
|
"DRONE_BUILD_CREATED": "0",
|
||||||
|
"DRONE_BUILD_EVENT": "",
|
||||||
|
"DRONE_BUILD_FINISHED": "1571810939",
|
||||||
|
"DRONE_BUILD_LINK": ":////0",
|
||||||
|
"DRONE_BUILD_NUMBER": "0",
|
||||||
|
"DRONE_BUILD_PARENT": "0",
|
||||||
|
"DRONE_BUILD_STARTED": "1571810939",
|
||||||
|
"DRONE_BUILD_STATUS": "success",
|
||||||
|
"DRONE_COMMIT": "",
|
||||||
|
"DRONE_COMMIT_AFTER": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_AVATAR": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_EMAIL": "",
|
||||||
|
"DRONE_COMMIT_AUTHOR_NAME": "",
|
||||||
|
"DRONE_COMMIT_BEFORE": "",
|
||||||
|
"DRONE_COMMIT_BRANCH": "master",
|
||||||
|
"DRONE_COMMIT_LINK": "",
|
||||||
|
"DRONE_COMMIT_MESSAGE": "",
|
||||||
|
"DRONE_COMMIT_REF": "",
|
||||||
|
"DRONE_COMMIT_SHA": "",
|
||||||
|
"DRONE_DEPLOY_TO": "",
|
||||||
|
"DRONE_DOCKER_NETWORK_ID": "random",
|
||||||
|
"DRONE_DOCKER_VOLUME_ID": "random",
|
||||||
|
"DRONE_GIT_HTTP_URL": "",
|
||||||
|
"DRONE_GIT_SSH_URL": "",
|
||||||
|
"DRONE_NETRC_FILE": "machine github.com login octocat password correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_MACHINE": "github.com",
|
||||||
|
"DRONE_NETRC_PASSWORD": "correct-horse-battery-staple",
|
||||||
|
"DRONE_NETRC_USERNAME": "octocat",
|
||||||
|
"DRONE_REMOTE_URL": "",
|
||||||
|
"DRONE_REPO": "",
|
||||||
|
"DRONE_REPO_BRANCH": "",
|
||||||
|
"DRONE_REPO_LINK": "",
|
||||||
|
"DRONE_REPO_NAME": "",
|
||||||
|
"DRONE_REPO_NAMESPACE": "",
|
||||||
|
"DRONE_REPO_OWNER": "",
|
||||||
|
"DRONE_REPO_PRIVATE": "false",
|
||||||
|
"DRONE_REPO_SCM": "",
|
||||||
|
"DRONE_REPO_VISIBILITY": "",
|
||||||
|
"DRONE_SCRIPT": "\n\nif [ ! -z \"${DRONE_NETRC_FILE}\" ]; then\n\techo $DRONE_NETRC_FILE \u003e $HOME/.netrc\nfi\n\nunset DRONE_SCRIPT\nunset DRONE_NETRC_MACHINE\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nunset DRONE_NETRC_FILE\n\nset -e\n\n\necho + \"go test\"\ngo test\n",
|
||||||
|
"DRONE_SOURCE_BRANCH": "",
|
||||||
|
"DRONE_STAGE_ARCH": "",
|
||||||
|
"DRONE_STAGE_DEPENDS_ON": "",
|
||||||
|
"DRONE_STAGE_FINISHED": "1571810939",
|
||||||
|
"DRONE_STAGE_KIND": "",
|
||||||
|
"DRONE_STAGE_MACHINE": "",
|
||||||
|
"DRONE_STAGE_NAME": "",
|
||||||
|
"DRONE_STAGE_NUMBER": "0",
|
||||||
|
"DRONE_STAGE_OS": "",
|
||||||
|
"DRONE_STAGE_STARTED": "1571810939",
|
||||||
|
"DRONE_STAGE_STATUS": "success",
|
||||||
|
"DRONE_STAGE_TYPE": "",
|
||||||
|
"DRONE_STAGE_VARIANT": "",
|
||||||
|
"DRONE_SYSTEM_HOST": "",
|
||||||
|
"DRONE_SYSTEM_HOSTNAME": "",
|
||||||
|
"DRONE_SYSTEM_PROTO": "",
|
||||||
|
"DRONE_SYSTEM_VERSION": "",
|
||||||
|
"DRONE_TARGET_BRANCH": "master",
|
||||||
|
"DRONE_WORKSPACE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_BASE": "/drone/src",
|
||||||
|
"DRONE_WORKSPACE_PATH": "",
|
||||||
|
"GIT_AUTHOR_EMAIL": "noreply@drone",
|
||||||
|
"GIT_AUTHOR_NAME": "drone",
|
||||||
|
"GIT_COMMITTER_EMAIL": "noreply@drone",
|
||||||
|
"GIT_COMMITTER_NAME": "drone",
|
||||||
|
"GIT_TERMINAL_PROMPT": "0"
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810939",
|
||||||
|
"io.drone.expires": "1571814539",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
},
|
||||||
|
"name": "test",
|
||||||
|
"volumes": [
|
||||||
{
|
{
|
||||||
"path": "/tmp/drone-random/opt/test",
|
"name": "_workspace",
|
||||||
"mode": 448,
|
"path": "/drone/src"
|
||||||
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"secrets": [],
|
"working_dir": "/drone/src"
|
||||||
"name": "test",
|
|
||||||
"working_dir": "/tmp/drone-random/drone/src"
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"temp": {
|
||||||
|
"id": "random",
|
||||||
|
"name": "_workspace",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810939",
|
||||||
|
"io.drone.expires": "1571814539",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"network": {
|
||||||
|
"id": "random",
|
||||||
|
"labels": {
|
||||||
|
"io.drone": "true",
|
||||||
|
"io.drone.build.number": "0",
|
||||||
|
"io.drone.created": "1571810939",
|
||||||
|
"io.drone.expires": "1571814539",
|
||||||
|
"io.drone.protected": "false",
|
||||||
|
"io.drone.repo.name": "",
|
||||||
|
"io.drone.repo.namespace": "",
|
||||||
|
"io.drone.repo.slug": "",
|
||||||
|
"io.drone.stage.name": "",
|
||||||
|
"io.drone.stage.number": "0",
|
||||||
|
"io.drone.system.host": "",
|
||||||
|
"io.drone.system.proto": "",
|
||||||
|
"io.drone.system.version": "",
|
||||||
|
"io.drone.ttl": "0s"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/drone-runners/drone-runner-docker/internal/docker/image"
|
||||||
"github.com/drone-runners/drone-runner-docker/internal/docker/stdcopy"
|
"github.com/drone-runners/drone-runner-docker/internal/docker/stdcopy"
|
||||||
"github.com/drone/runner-go/registry/auths"
|
"github.com/drone/runner-go/registry/auths"
|
||||||
|
|
||||||
@@ -141,14 +142,6 @@ func (e *Docker) Run(ctx context.Context, spec *Spec, step *Step, output io.Writ
|
|||||||
//
|
//
|
||||||
|
|
||||||
func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.Writer) error {
|
func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.Writer) error {
|
||||||
// parse the docker image name. We need to extract the
|
|
||||||
// image domain name and match to registry credentials
|
|
||||||
// stored in the .docker/config.json object.
|
|
||||||
_, _, latest, err := parseImage(step.Image)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// create pull options with encoded authorization credentials.
|
// create pull options with encoded authorization credentials.
|
||||||
pullopts := types.ImagePullOptions{}
|
pullopts := types.ImagePullOptions{}
|
||||||
if step.Auth != nil {
|
if step.Auth != nil {
|
||||||
@@ -161,7 +154,7 @@ func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.W
|
|||||||
// automatically pull the latest version of the image if requested
|
// automatically pull the latest version of the image if requested
|
||||||
// by the process configuration, or if the image is :latest
|
// by the process configuration, or if the image is :latest
|
||||||
if step.Pull == PullAlways ||
|
if step.Pull == PullAlways ||
|
||||||
(step.Pull == PullDefault && latest) {
|
(step.Pull == PullDefault && image.IsLatest(step.Image)) {
|
||||||
rc, pullerr := e.client.ImagePull(ctx, step.Image, pullopts)
|
rc, pullerr := e.client.ImagePull(ctx, step.Image, pullopts)
|
||||||
if pullerr == nil {
|
if pullerr == nil {
|
||||||
io.Copy(ioutil.Discard, rc)
|
io.Copy(ioutil.Discard, rc)
|
||||||
@@ -172,7 +165,7 @@ func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.W
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = e.client.ContainerCreate(ctx,
|
_, err := e.client.ContainerCreate(ctx,
|
||||||
toConfig(spec, step),
|
toConfig(spec, step),
|
||||||
toHostConfig(spec, step),
|
toHostConfig(spec, step),
|
||||||
toNetConfig(spec, step),
|
toNetConfig(spec, step),
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Polyform License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package engine
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/docker/distribution/reference"
|
|
||||||
)
|
|
||||||
|
|
||||||
// helper function parses the image and returns the
|
|
||||||
// canonical image name, domain name, and whether or not
|
|
||||||
// the image tag is :latest.
|
|
||||||
func parseImage(s string) (canonical, domain string, latest bool, err error) {
|
|
||||||
// parse the docker image name. We need to extract the
|
|
||||||
// image domain name and match to registry credentials
|
|
||||||
// stored in the .docker/config.json object.
|
|
||||||
named, err := reference.ParseNormalizedNamed(s)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// the canonical image name, for some reason, excludes
|
|
||||||
// the tag name. So we need to make sure it is included
|
|
||||||
// in the image name so we can determine if the :latest
|
|
||||||
// tag is specified
|
|
||||||
named = reference.TagNameOnly(named)
|
|
||||||
|
|
||||||
return named.String(),
|
|
||||||
reference.Domain(named),
|
|
||||||
strings.HasSuffix(named.String(), ":latest"),
|
|
||||||
nil
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Polyform License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package engine
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func TestParseImage(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
image string
|
|
||||||
canonical string
|
|
||||||
domain string
|
|
||||||
latest bool
|
|
||||||
err bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
image: "golang",
|
|
||||||
canonical: "docker.io/library/golang:latest",
|
|
||||||
domain: "docker.io",
|
|
||||||
latest: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
image: "golang:1.11",
|
|
||||||
canonical: "docker.io/library/golang:1.11",
|
|
||||||
domain: "docker.io",
|
|
||||||
latest: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
image: "",
|
|
||||||
err: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
canonical, domain, latest, err := parseImage(test.image)
|
|
||||||
if test.err {
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf("Expect error parsing image %s", test.image)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
if got, want := canonical, test.canonical; got != want {
|
|
||||||
t.Errorf("Want image %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
if got, want := domain, test.domain; got != want {
|
|
||||||
t.Errorf("Want image domain %s, got %s", want, got)
|
|
||||||
}
|
|
||||||
if got, want := latest, test.latest; got != want {
|
|
||||||
t.Errorf("Want image latest %v, got %v", want, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
go.mod
1
go.mod
@@ -17,6 +17,7 @@ require (
|
|||||||
github.com/drone/signal v1.0.0
|
github.com/drone/signal v1.0.0
|
||||||
github.com/ghodss/yaml v1.0.0
|
github.com/ghodss/yaml v1.0.0
|
||||||
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 // indirect
|
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 // indirect
|
||||||
|
github.com/golang/mock v1.3.1
|
||||||
github.com/google/go-cmp v0.3.0
|
github.com/google/go-cmp v0.3.0
|
||||||
github.com/hashicorp/go-multierror v1.0.0
|
github.com/hashicorp/go-multierror v1.0.0
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -39,6 +39,8 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
|||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 h1:zDlw+wgyXdfkRuvFCdEDUiPLmZp2cvf/dWHazY0a5VM=
|
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 h1:zDlw+wgyXdfkRuvFCdEDUiPLmZp2cvf/dWHazY0a5VM=
|
||||||
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
|
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
|
||||||
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
@@ -79,6 +81,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A=
|
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A=
|
||||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||||
@@ -90,6 +93,7 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/p
|
|||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import "github.com/docker/distribution/reference"
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/docker/distribution/reference"
|
||||||
|
)
|
||||||
|
|
||||||
// Trim returns the short image name without tag.
|
// Trim returns the short image name without tag.
|
||||||
func Trim(name string) string {
|
func Trim(name string) string {
|
||||||
@@ -69,3 +73,9 @@ func MatchHostname(image, hostname string) bool {
|
|||||||
}
|
}
|
||||||
return reference.Domain(named) == hostname
|
return reference.Domain(named) == hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsLatest parses the image and returns true if
|
||||||
|
// the image uses the :latest tag.
|
||||||
|
func IsLatest(s string) bool {
|
||||||
|
return strings.HasSuffix(Expand(s), ":latest")
|
||||||
|
}
|
||||||
|
|||||||
@@ -297,3 +297,41 @@ func Test_matchTag(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_isLatest(t *testing.T) {
|
||||||
|
testdata := []struct {
|
||||||
|
name string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "golang:1",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "golang",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "golang:latest",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "docker.io/library/golang",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "docker.io/library/golang:latest",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "docker.io/library/golang:1",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range testdata {
|
||||||
|
got, want := IsLatest(test.name), test.want
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("Want image %q isLatest %v", test.name, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
79
internal/mock/mock_engine_gen.go
Normal file
79
internal/mock/mock_engine_gen.go
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: github.com/drone-runners/drone-runner-docker/engine (interfaces: Engine)
|
||||||
|
|
||||||
|
// Package mock is a generated GoMock package.
|
||||||
|
package mock
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
engine "github.com/drone-runners/drone-runner-docker/engine"
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
|
io "io"
|
||||||
|
reflect "reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockEngine is a mock of Engine interface
|
||||||
|
type MockEngine struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockEngineMockRecorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockEngineMockRecorder is the mock recorder for MockEngine
|
||||||
|
type MockEngineMockRecorder struct {
|
||||||
|
mock *MockEngine
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockEngine creates a new mock instance
|
||||||
|
func NewMockEngine(ctrl *gomock.Controller) *MockEngine {
|
||||||
|
mock := &MockEngine{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockEngineMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use
|
||||||
|
func (m *MockEngine) EXPECT() *MockEngineMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy mocks base method
|
||||||
|
func (m *MockEngine) Destroy(arg0 context.Context, arg1 *engine.Spec) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Destroy", arg0, arg1)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy indicates an expected call of Destroy
|
||||||
|
func (mr *MockEngineMockRecorder) Destroy(arg0, arg1 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Destroy", reflect.TypeOf((*MockEngine)(nil).Destroy), arg0, arg1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run mocks base method
|
||||||
|
func (m *MockEngine) Run(arg0 context.Context, arg1 *engine.Spec, arg2 *engine.Step, arg3 io.Writer) (*engine.State, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Run", arg0, arg1, arg2, arg3)
|
||||||
|
ret0, _ := ret[0].(*engine.State)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run indicates an expected call of Run
|
||||||
|
func (mr *MockEngineMockRecorder) Run(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockEngine)(nil).Run), arg0, arg1, arg2, arg3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup mocks base method
|
||||||
|
func (m *MockEngine) Setup(arg0 context.Context, arg1 *engine.Spec) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Setup", arg0, arg1)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup indicates an expected call of Setup
|
||||||
|
func (mr *MockEngineMockRecorder) Setup(arg0, arg1 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Setup", reflect.TypeOf((*MockEngine)(nil).Setup), arg0, arg1)
|
||||||
|
}
|
||||||
50
internal/mock/mock_execer_gen.go
Normal file
50
internal/mock/mock_execer_gen.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
|
// Source: github.com/drone-runners/drone-runner-docker/runtime (interfaces: Execer)
|
||||||
|
|
||||||
|
// Package mock is a generated GoMock package.
|
||||||
|
package mock
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
engine "github.com/drone-runners/drone-runner-docker/engine"
|
||||||
|
pipeline "github.com/drone/runner-go/pipeline"
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
|
reflect "reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockExecer is a mock of Execer interface
|
||||||
|
type MockExecer struct {
|
||||||
|
ctrl *gomock.Controller
|
||||||
|
recorder *MockExecerMockRecorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// MockExecerMockRecorder is the mock recorder for MockExecer
|
||||||
|
type MockExecerMockRecorder struct {
|
||||||
|
mock *MockExecer
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockExecer creates a new mock instance
|
||||||
|
func NewMockExecer(ctrl *gomock.Controller) *MockExecer {
|
||||||
|
mock := &MockExecer{ctrl: ctrl}
|
||||||
|
mock.recorder = &MockExecerMockRecorder{mock}
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPECT returns an object that allows the caller to indicate expected use
|
||||||
|
func (m *MockExecer) EXPECT() *MockExecerMockRecorder {
|
||||||
|
return m.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec mocks base method
|
||||||
|
func (m *MockExecer) Exec(arg0 context.Context, arg1 *engine.Spec, arg2 *pipeline.State) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Exec", arg0, arg1, arg2)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec indicates an expected call of Exec
|
||||||
|
func (mr *MockExecerMockRecorder) Exec(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockExecer)(nil).Exec), arg0, arg1, arg2)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user