mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-07 07:07:10 +02:00
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package services
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/autonomy/talos/internal/app/init/pkg/system/conditions"
|
|
"github.com/autonomy/talos/internal/app/init/pkg/system/runner"
|
|
"github.com/autonomy/talos/internal/app/init/pkg/system/runner/process"
|
|
"github.com/autonomy/talos/internal/pkg/userdata"
|
|
)
|
|
|
|
// Containerd implements the Service interface. It serves as the concrete type with
|
|
// the required methods.
|
|
type Containerd struct{}
|
|
|
|
// ID implements the Service interface.
|
|
func (c *Containerd) ID(data *userdata.UserData) string {
|
|
return "containerd"
|
|
}
|
|
|
|
// PreFunc implements the Service interface.
|
|
func (c *Containerd) PreFunc(data *userdata.UserData) error {
|
|
return os.MkdirAll("/var/lib/containerd", os.ModeDir)
|
|
}
|
|
|
|
// PostFunc implements the Service interface.
|
|
func (c *Containerd) PostFunc(data *userdata.UserData) (err error) {
|
|
return nil
|
|
}
|
|
|
|
// ConditionFunc implements the Service interface.
|
|
func (c *Containerd) ConditionFunc(data *userdata.UserData) conditions.ConditionFunc {
|
|
return conditions.None()
|
|
}
|
|
|
|
// Start implements the Service interface.
|
|
func (c *Containerd) Start(data *userdata.UserData) error {
|
|
// Set the process arguments.
|
|
args := &runner.Args{
|
|
ID: c.ID(data),
|
|
ProcessArgs: []string{"/bin/containerd"},
|
|
}
|
|
|
|
env := []string{}
|
|
for key, val := range data.Env {
|
|
env = append(env, fmt.Sprintf("%s=%s", key, val))
|
|
}
|
|
|
|
r := process.Process{}
|
|
|
|
return r.Run(
|
|
data,
|
|
args,
|
|
runner.WithEnv(env),
|
|
)
|
|
}
|