k3s/pkg/agent/run_windows.go
Luther Monson 9a849b1bb7
[master] changing package to k3s-io (#4846)
* changing package to k3s-io

Signed-off-by: Luther Monson <luther.monson@gmail.com>

Co-authored-by: Derek Nola <derek.nola@suse.com>
2022-03-02 15:47:27 -08:00

45 lines
1.0 KiB
Go

//go:build windows
// +build windows
package agent
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config"
)
const (
dockershimSock = "npipe:////./pipe/docker_engine"
containerdSock = "npipe:////./pipe/containerd-containerd"
)
// setupCriCtlConfig creates the crictl config file and populates it
// with the given data from config.
func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
cre := nodeConfig.ContainerRuntimeEndpoint
if cre == "" || strings.HasPrefix(cre, "npipe:") {
switch {
case cfg.Docker:
cre = dockershimSock
default:
cre = containerdSock
}
} else {
cre = containerdSock
}
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
if _, err := os.Stat(agentConfDir); os.IsNotExist(err) {
if err := os.MkdirAll(agentConfDir, 0700); err != nil {
return err
}
}
crp := "runtime-endpoint: " + cre + "\n"
return ioutil.WriteFile(filepath.Join(agentConfDir, "crictl.yaml"), []byte(crp), 0600)
}