init commit for coverting to podman
This commit is contained in:
@@ -7,8 +7,8 @@ package compiler
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
"github.com/drone/runner-go/manifest"
|
||||
"github.com/drone/runner-go/pipeline/runtime"
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
"github.com/drone/drone-go/drone"
|
||||
"github.com/drone/runner-go/environ/provider"
|
||||
"github.com/drone/runner-go/manifest"
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-docker/internal/docker/image"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/internal/podman/image"
|
||||
|
||||
"github.com/drone/drone-go/drone"
|
||||
"github.com/drone/runner-go/clone"
|
||||
@@ -37,7 +37,7 @@ var random = func() string {
|
||||
// with privileged capabilities in order to run Docker
|
||||
// in Docker.
|
||||
var Privileged = []string{
|
||||
"plugins/docker",
|
||||
"plugins/podman",
|
||||
"plugins/acr",
|
||||
"plugins/ecr",
|
||||
"plugins/gcr",
|
||||
@@ -230,7 +230,7 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
||||
)
|
||||
|
||||
// create network reference variables
|
||||
envs["DRONE_DOCKER_NETWORK_ID"] = spec.Network.ID
|
||||
envs["DRONE_PODMAN_NETWORK_ID"] = spec.Network.ID
|
||||
|
||||
// create the workspace variables
|
||||
envs["DRONE_WORKSPACE"] = full
|
||||
@@ -239,9 +239,9 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
||||
|
||||
// create volume reference variables
|
||||
if volume.EmptyDir != nil {
|
||||
envs["DRONE_DOCKER_VOLUME_ID"] = volume.EmptyDir.ID
|
||||
envs["DRONE_PODMAN_VOLUME_ID"] = volume.EmptyDir.ID
|
||||
} else {
|
||||
envs["DRONE_DOCKER_VOLUME_PATH"] = volume.HostPath.Path
|
||||
envs["DRONE_PODMAN_VOLUME_PATH"] = volume.HostPath.Path
|
||||
}
|
||||
|
||||
// create tmate variables
|
||||
@@ -359,7 +359,7 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
||||
Labels: stageLabels,
|
||||
Pull: engine.PullIfNotExists,
|
||||
Image: image.Expand(c.Tmate.Image),
|
||||
Entrypoint: []string{"/bin/drone-runner-docker"},
|
||||
Entrypoint: []string{"/bin/drone-runner-podman"},
|
||||
Command: []string{"copy"},
|
||||
Network: "none",
|
||||
})
|
||||
@@ -531,7 +531,7 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
||||
// feature toggle that disables the check that restricts
|
||||
// docker plugins from mounting volumes.
|
||||
// DO NOT USE: THIS WILL BE DEPRECATED IN THE FUTURE
|
||||
var allowDockerPluginVolumes = os.Getenv("DRONE_FLAG_ALLOW_DOCKER_PLUGIN_VOLUMES") == "true"
|
||||
var allowPodmanPluginVolumes = os.Getenv("DRONE_FLAG_ALLOW_PODMAN_PLUGIN_VOLUMES") == "true"
|
||||
|
||||
func (c *Compiler) isPrivileged(step *resource.Step) bool {
|
||||
// privileged-by-default containers are only
|
||||
@@ -547,7 +547,7 @@ func (c *Compiler) isPrivileged(step *resource.Step) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if allowDockerPluginVolumes == false {
|
||||
if allowPodmanPluginVolumes == false {
|
||||
if len(step.Volumes) > 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by the Polyform License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package compiler
|
||||
@@ -9,14 +10,13 @@ package compiler
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
"github.com/drone/drone-go/drone"
|
||||
"github.com/drone/runner-go/environ/provider"
|
||||
"github.com/drone/runner-go/manifest"
|
||||
@@ -280,7 +280,7 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {
|
||||
|
||||
got := compiler.Compile(nocontext, args)
|
||||
|
||||
raw, err := ioutil.ReadFile(golden)
|
||||
raw, err := os.ReadFile(golden)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -320,13 +320,13 @@ func TestIsPrivileged(t *testing.T) {
|
||||
t.Errorf("Disable privileged mode if commands are specified")
|
||||
}
|
||||
if c.isPrivileged(&resource.Step{Image: "foo", Command: []string{"echo hello", "echo world"}}) {
|
||||
t.Errorf("Disable privileged mode if the Docker command is specified")
|
||||
t.Errorf("Disable privileged mode if the Podman command is specified")
|
||||
}
|
||||
if c.isPrivileged(&resource.Step{Image: "foo", Entrypoint: []string{"/bin/sh"}}) {
|
||||
t.Errorf("Disable privileged mode if the Docker entrypoint is specified")
|
||||
t.Errorf("Disable privileged mode if the Podman entrypoint is specified")
|
||||
}
|
||||
if c.isPrivileged(&resource.Step{Image: "foo", Volumes: []*resource.VolumeMount{{MountPath: "/var/run/docker.sock"}}}) {
|
||||
t.Errorf("Disable privileged mode if /var/run/docker.sock mounted")
|
||||
if c.isPrivileged(&resource.Step{Image: "foo", Volumes: []*resource.VolumeMount{{MountPath: "/var/run/podman.sock"}}}) {
|
||||
t.Errorf("Disable privileged mode if /var/run/podman.sock mounted")
|
||||
}
|
||||
if c.isPrivileged(&resource.Step{Image: "foo", Volumes: []*resource.VolumeMount{{MountPath: "/var"}}}) {
|
||||
t.Errorf("Disable privileged mode if /var mounted")
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
package compiler
|
||||
|
||||
import (
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/compiler/shell"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/compiler/shell/powershell"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/compiler/shell"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/compiler/shell/powershell"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
)
|
||||
|
||||
// helper function configures the pipeline script for the
|
||||
|
||||
@@ -7,10 +7,10 @@ package compiler
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-docker/internal/docker/image"
|
||||
"github.com/drone-runners/drone-runner-docker/internal/encoder"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/internal/encoder"
|
||||
"github.com/drone-runners/drone-runner-podman/internal/podman/image"
|
||||
|
||||
"github.com/drone/runner-go/pipeline/runtime"
|
||||
)
|
||||
|
||||
2
engine/compiler/testdata/graph.yml
vendored
2
engine/compiler/testdata/graph.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
steps:
|
||||
|
||||
2
engine/compiler/testdata/match.yml
vendored
2
engine/compiler/testdata/match.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
|
||||
4
engine/compiler/testdata/noclone_graph.yml
vendored
4
engine/compiler/testdata/noclone_graph.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
@@ -15,4 +15,4 @@ steps:
|
||||
image: golang
|
||||
commands:
|
||||
- go test
|
||||
depends_on: [ build ]
|
||||
depends_on: [ build ]
|
||||
|
||||
2
engine/compiler/testdata/noclone_serial.yml
vendored
2
engine/compiler/testdata/noclone_serial.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
|
||||
2
engine/compiler/testdata/run_always.yml
vendored
2
engine/compiler/testdata/run_always.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
|
||||
2
engine/compiler/testdata/run_failure.yml
vendored
2
engine/compiler/testdata/run_failure.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
|
||||
2
engine/compiler/testdata/secret.yml
vendored
2
engine/compiler/testdata/secret.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
|
||||
2
engine/compiler/testdata/serial.yml
vendored
2
engine/compiler/testdata/serial.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
steps:
|
||||
|
||||
2
engine/compiler/testdata/steps.yml
vendored
2
engine/compiler/testdata/steps.yml
vendored
@@ -1,5 +1,5 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: podman
|
||||
name: default
|
||||
|
||||
clone:
|
||||
|
||||
@@ -7,8 +7,8 @@ package compiler
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
|
||||
"github.com/drone/drone-go/drone"
|
||||
"github.com/drone/runner-go/manifest"
|
||||
|
||||
@@ -7,8 +7,8 @@ package compiler
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
|
||||
"github.com/drone/runner-go/manifest"
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
stdpath "path"
|
||||
"strings"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -7,8 +7,8 @@ package compiler
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine"
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
"github.com/drone-runners/drone-runner-podman/engine"
|
||||
"github.com/drone-runners/drone-runner-podman/engine/resource"
|
||||
"github.com/drone/runner-go/manifest"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user