Allow KVM access on request
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-04-18 09:18:40 +02:00
parent 3a7b0940d8
commit 65cddc2ed7
2 changed files with 15 additions and 1 deletions

View File

@@ -81,6 +81,11 @@ func main() {
Usage: "disable forced pulling in act",
EnvVar: "PLUGIN_NO_FORCE_PULL",
},
cli.BoolFlag{
Name: "kvm",
Usage: "enable KVM (Kernel Virtual Machine)",
EnvVar: "PLUGIN_KVM",
},
cli.StringFlag{
Name: "event-payload",
Usage: "Webhook event payload",
@@ -194,6 +199,7 @@ func run(c *cli.Context) error {
Verbose: c.Bool("action-verbose"),
Image: c.String("action-image"),
NoForcePull: c.Bool("no-force-pull"),
Kvm: c.Bool("kvm"),
EventPayload: c.String("event-payload"),
Actor: c.String("actor"),
},

View File

@@ -39,6 +39,7 @@ type (
Actor string
Verbose bool
NoForcePull bool
Kvm bool
}
Plugin struct {
@@ -94,7 +95,11 @@ func (p Plugin) Exec() error {
}
if p.Action.NoForcePull {
cmdArgs = append(cmdArgs, "-p=false")
cmdArgs = append(cmdArgs, "--pull=false")
}
if p.Action.Kvm {
cmdArgs = append(cmdArgs, "--privileged")
}
if p.Daemon.Disabled {
@@ -111,6 +116,9 @@ func (p Plugin) Exec() error {
bindModifiers = ":z"
}
cmdArgs = append(cmdArgs, "--container-options", fmt.Sprintf("--volume=%s:%s%s", hostWorkDirPath, guestWorkDirPath, bindModifiers))
if p.Action.Kvm {
cmdArgs = append(cmdArgs, "--volume=/dev/kvm:/dev/kvm")
}
}
cmd := exec.Command("act", cmdArgs...)