diff --git a/cmd/hepto.go b/cmd/hepto.go index 2e4ba98fa894ed0e22c6b8582b1e8afc5864a0e6..877b8adcb7f5d71679e5e0d82b9fc8fb568aa68b 100644 --- a/cmd/hepto.go +++ b/cmd/hepto.go @@ -9,12 +9,18 @@ import ( ) func main() { - fn := hepto.Hepto + var err error program := filepath.Base(os.Args[0]) - if hook, ok := hepto.Hooks[program]; ok { - fn = hook + switch program { + case "runc": + err = hepto.Runc() + case "kubectl": + err = hepto.Kubectl() + case "containerd-shim-runc-v2": + err = hepto.Shim() + default: + err = hepto.Hepto() } - err := fn() if err != nil { fmt.Println(err) os.Exit(1) diff --git a/cmd/hepto/hepto.go b/cmd/hepto/hepto.go index 6a08ec299328dcc1d12dcb775964ce80b33ca30c..519819988683e987c5193dca7f9d42b340c32a82 100644 --- a/cmd/hepto/hepto.go +++ b/cmd/hepto/hepto.go @@ -45,7 +45,7 @@ func Hepto() error { dolly.NewBind(dataPath, config.Cluster.DataDir), dolly.PrefixEnv("HEPTO_"), dolly.NewEnv("PATH", "/bin"), - dolly.MountSelf("/bin", "runc", "containerd-shim-runc-v2", "mount", "umount"), + dolly.MountSelf("/bin", "runc", "containerd-shim-runc-v2"), dolly.NewDevicesOrPanic(requiredDevices...), dolly.NewBinds(config.Mounts), ) diff --git a/cmd/hepto/hooks.go b/cmd/hepto/hooks.go index 1d43dbf0f68965cf3171ba69c32714bab64c921e..73a8e92118eaec1c5adbf30db4945c073a74496d 100644 --- a/cmd/hepto/hooks.go +++ b/cmd/hepto/hooks.go @@ -5,7 +5,6 @@ import ( "os" "strings" - containerd "github.com/containerd/containerd/cmd/containerd/command" "github.com/containerd/containerd/log" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/runtime/v2/runc/manager" @@ -19,10 +18,6 @@ import ( kubectl "k8s.io/kubectl/pkg/cmd" ) -func Containerd() error { - return containerd.App().Run(os.Args) -} - func Shim() error { ctx := context.Background() plugins := plugin.Graph(func(*plugin.Registration) bool { return false }) @@ -51,10 +46,3 @@ func Runc() error { func Kubectl() error { return kubectl.NewDefaultKubectlCommand().Execute() } - -var Hooks = map[string]func() error{ - "kubectl": Kubectl, - "runc": Runc, - "containerd-shim-runc-v2": Shim, - "containerd": Containerd, -}