init commit for coverting to podman

This commit is contained in:
zerodoctor
2023-10-04 23:19:30 -05:00
parent 7e9969423c
commit 04332e5527
96 changed files with 2034 additions and 534 deletions

View File

@@ -8,7 +8,7 @@ import (
"context"
"os"
"github.com/drone-runners/drone-runner-docker/command/daemon"
"github.com/drone-runners/drone-runner-podman/command/daemon"
"gopkg.in/alecthomas/kingpin.v2"
)
@@ -22,7 +22,7 @@ var nocontext = context.Background()
// Command parses the command line arguments and then executes a
// subcommand program.
func Command() {
app := kingpin.New("drone", "drone docker runner")
app := kingpin.New("drone", "drone podman runner")
registerCompile(app)
registerExec(app)
registerCopy(app)

View File

@@ -7,14 +7,14 @@ package command
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"strings"
"github.com/drone-runners/drone-runner-docker/command/internal"
"github.com/drone-runners/drone-runner-docker/engine/compiler"
"github.com/drone-runners/drone-runner-docker/engine/linter"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"github.com/drone-runners/drone-runner-podman/command/internal"
"github.com/drone-runners/drone-runner-podman/engine/compiler"
"github.com/drone-runners/drone-runner-podman/engine/linter"
"github.com/drone-runners/drone-runner-podman/engine/resource"
"github.com/drone/envsubst"
"github.com/drone/runner-go/environ"
"github.com/drone/runner-go/environ/provider"
@@ -43,7 +43,7 @@ type compileCommand struct {
}
func (c *compileCommand) run(*kingpin.ParseContext) error {
rawsource, err := ioutil.ReadAll(c.Source)
rawsource, err := io.ReadAll(c.Source)
if err != nil {
return err
}
@@ -171,7 +171,7 @@ func registerCompile(app *kingpin.Application) {
cmd.Flag("volumes", "container volumes").
StringMapVar(&c.Volumes)
cmd.Flag("privileged", "privileged docker images").
cmd.Flag("privileged", "privileged podman images").
StringsVar(&c.Privileged)
cmd.Flag("cpu-period", "container cpu period").
@@ -192,11 +192,11 @@ func registerCompile(app *kingpin.Application) {
cmd.Flag("memory-swap", "container memory swap limit").
Int64Var(&c.Resources.MemorySwap)
cmd.Flag("docker-config", "path to the docker config file").
cmd.Flag("podman-config", "path to the podman config file").
StringVar(&c.Config)
cmd.Flag("tmate-image", "tmate docker image").
Default("drone/drone-runner-docker:1").
cmd.Flag("tmate-image", "tmate podman image").
Default("drone/drone-runner-podman:1").
StringVar(&c.Tmate.Image)
cmd.Flag("tmate-enabled", "tmate enabled").

View File

@@ -102,14 +102,14 @@ type Config struct {
SkipVerify bool `envconfig:"DRONE_REGISTRY_PLUGIN_SKIP_VERIFY"`
}
Docker struct {
Config string `envconfig:"DRONE_DOCKER_CONFIG"`
Stream bool `envconfig:"DRONE_DOCKER_STREAM_PULL" default:"true"`
Podman struct {
Config string `envconfig:"DRONE_PODMAN_CONFIG"`
Stream bool `envconfig:"DRONE_PODMAN_STREAM_PULL" default:"true"`
}
Tmate struct {
Enabled bool `envconfig:"DRONE_TMATE_ENABLED" default:"false"`
Image string `envconfig:"DRONE_TMATE_IMAGE" default:"drone/drone-runner-docker:1"`
Image string `envconfig:"DRONE_TMATE_IMAGE" default:"drone/drone-runner-podman:1"`
Server string `envconfig:"DRONE_TMATE_HOST"`
Port string `envconfig:"DRONE_TMATE_PORT"`
RSA string `envconfig:"DRONE_TMATE_FINGERPRINT_RSA"`

View File

@@ -8,11 +8,11 @@ import (
"context"
"time"
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/compiler"
"github.com/drone-runners/drone-runner-docker/engine/linter"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"github.com/drone-runners/drone-runner-docker/internal/match"
"github.com/drone-runners/drone-runner-podman/engine"
"github.com/drone-runners/drone-runner-podman/engine/compiler"
"github.com/drone-runners/drone-runner-podman/engine/linter"
"github.com/drone-runners/drone-runner-podman/engine/resource"
"github.com/drone-runners/drone-runner-podman/internal/match"
"github.com/drone/runner-go/client"
"github.com/drone/runner-go/environ/provider"
@@ -82,31 +82,12 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
)
opts := engine.Opts{
HidePull: !config.Docker.Stream,
HidePull: !config.Podman.Stream,
}
engine, err := engine.NewEnv(opts)
engine, err := engine.NewEnv(context.Background(), opts)
if err != nil {
logrus.WithError(err).
Fatalln("cannot load the docker engine")
}
for {
err := engine.Ping(ctx)
if err == context.Canceled {
break
}
select {
case <-ctx.Done():
return ctx.Err()
default:
}
if err != nil {
logrus.WithError(err).
Errorln("cannot ping the docker daemon")
time.Sleep(time.Second)
} else {
logrus.Debugln("successfully pinged the docker daemon")
break
}
Fatalln("cannot load the podman engine")
}
remote := remote.New(cli)
@@ -162,7 +143,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
),
Registry: registry.Combine(
registry.File(
config.Docker.Config,
config.Podman.Config,
),
registry.External(
config.Registry.Endpoint,

View File

@@ -5,10 +5,12 @@
package daemon
import (
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/compiler"
"github.com/drone-runners/drone-runner-docker/engine/linter"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"context"
"github.com/drone-runners/drone-runner-podman/engine"
"github.com/drone-runners/drone-runner-podman/engine/compiler"
"github.com/drone-runners/drone-runner-podman/engine/linter"
"github.com/drone-runners/drone-runner-podman/engine/resource"
"github.com/drone/runner-go/pipeline/uploader"
"github.com/drone/runner-go/client"
@@ -54,12 +56,12 @@ func (c *processCommand) run(*kingpin.ParseContext) error {
)
opts := engine.Opts{
HidePull: !config.Docker.Stream,
HidePull: !config.Podman.Stream,
}
engine, err := engine.NewEnv(opts)
engine, err := engine.NewEnv(context.Background(), opts)
if err != nil {
logrus.WithError(err).
Fatalln("cannot load the docker engine")
Fatalln("cannot load the podman engine")
}
remote := remote.New(cli)
@@ -98,7 +100,7 @@ func (c *processCommand) run(*kingpin.ParseContext) error {
),
Registry: registry.Combine(
registry.File(
config.Docker.Config,
config.Podman.Config,
),
registry.External(
config.Registry.Endpoint,

View File

@@ -8,16 +8,16 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"strings"
"time"
"github.com/drone-runners/drone-runner-docker/command/internal"
"github.com/drone-runners/drone-runner-docker/engine"
"github.com/drone-runners/drone-runner-docker/engine/compiler"
"github.com/drone-runners/drone-runner-docker/engine/linter"
"github.com/drone-runners/drone-runner-docker/engine/resource"
"github.com/drone-runners/drone-runner-podman/command/internal"
"github.com/drone-runners/drone-runner-podman/engine"
"github.com/drone-runners/drone-runner-podman/engine/compiler"
"github.com/drone-runners/drone-runner-podman/engine/linter"
"github.com/drone-runners/drone-runner-podman/engine/resource"
"github.com/drone/drone-go/drone"
"github.com/drone/envsubst"
@@ -63,7 +63,7 @@ type execCommand struct {
}
func (c *execCommand) run(*kingpin.ParseContext) error {
rawsource, err := ioutil.ReadAll(c.Source)
rawsource, err := io.ReadAll(c.Source)
if err != nil {
return err
}
@@ -231,7 +231,7 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
),
)
engine, err := engine.NewEnv(engine.Opts{})
engine, err := engine.NewEnv(context.Background(), engine.Opts{})
if err != nil {
return err
}
@@ -301,7 +301,7 @@ func registerExec(app *kingpin.Application) {
cmd.Flag("volumes", "container volumes").
StringMapVar(&c.Volumes)
cmd.Flag("privileged", "privileged docker images").
cmd.Flag("privileged", "privileged podman images").
StringsVar(&c.Privileged)
cmd.Flag("cpu-period", "container cpu period").
@@ -328,11 +328,11 @@ func registerExec(app *kingpin.Application) {
cmd.Flag("private-key", "private key file path").
ExistingFileVar(&c.PrivateKey)
cmd.Flag("docker-config", "path to the docker config file").
cmd.Flag("podman-config", "path to the podman config file").
StringVar(&c.Config)
cmd.Flag("tmate-image", "tmate docker image").
Default("drone/drone-runner-docker:1").
cmd.Flag("tmate-image", "tmate podman image").
Default("drone/drone-runner-podman:1").
StringVar(&c.Tmate.Image)
cmd.Flag("tmate-enabled", "tmate enabled").