configurer

package
v0.31.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseWindows added in v0.29.0

type BaseWindows struct {
	// contains filtered or unexported fields
}

Windows provides helpers and defaults for Windows hosts

func (*BaseWindows) Arch added in v0.29.0

func (w *BaseWindows) Arch(h os.Host) (string, error)

Arch returns the host processor architecture in the format k0s expects it

func (*BaseWindows) Base added in v0.29.0

func (w *BaseWindows) Base(path string) string

Base returns the last element of a path

func (*BaseWindows) Chown added in v0.29.0

func (w *BaseWindows) Chown(h os.Host, path, owner string, _ ...exec.Option) error

Chown is a no-op on Windows; ownership semantics differ and are not managed here

func (*BaseWindows) DataDirDefaultPath added in v0.29.0

func (w *BaseWindows) DataDirDefaultPath() string

DataDirDefaultPath returns the path to the k0s data dir on the host

func (*BaseWindows) DeleteDir added in v0.29.0

func (w *BaseWindows) DeleteDir(h os.Host, path string, opts ...exec.Option) error

func (*BaseWindows) Dir added in v0.29.0

func (w *BaseWindows) Dir(path string) string

Dir returns the directory part of a path

func (*BaseWindows) DownloadURL added in v0.29.0

func (w *BaseWindows) DownloadURL(h os.Host, url, destination string, opts ...exec.Option) error

DownloadURL performs a download from a URL on the host

func (*BaseWindows) FileContains added in v0.29.0

func (w *BaseWindows) FileContains(h os.Host, path, s string) bool

FileContains returns true if a file contains the substring

func (*BaseWindows) HTTPStatus added in v0.29.0

func (w *BaseWindows) HTTPStatus(h os.Host, url string) (int, error)

HTTPStatus makes a HTTP GET request to the url and returns the status code or an error

func (*BaseWindows) HostPath added in v0.29.0

func (w *BaseWindows) HostPath(path string) string

HostPath converts the provided path to a native Windows path representation

func (*BaseWindows) Hostname added in v0.29.0

func (w *BaseWindows) Hostname(h os.Host) string

Hostname on windows returns the hostname

func (*BaseWindows) K0sBinaryPath added in v0.29.0

func (w *BaseWindows) K0sBinaryPath() string

K0sBinaryPath returns the path to the k0s binary on the host

func (*BaseWindows) K0sCmdf added in v0.29.0

func (w *BaseWindows) K0sCmdf(template string, args ...interface{}) string

K0sCmdf can be used to construct k0s commands in sprintf style.

func (*BaseWindows) K0sConfigPath added in v0.29.0

func (w *BaseWindows) K0sConfigPath() string

K0sConfigPath returns the path to the k0s config file on the host

func (*BaseWindows) K0sJoinTokenPath added in v0.29.0

func (w *BaseWindows) K0sJoinTokenPath() string

K0sJoinTokenPath returns the path to the k0s join token file on the host

func (*BaseWindows) K0sctlLockFilePath added in v0.29.0

func (w *BaseWindows) K0sctlLockFilePath(h os.Host) string

K0sctlLockFilePath returns a path to a lock file

func (*BaseWindows) KubeconfigPath added in v0.29.0

func (w *BaseWindows) KubeconfigPath(h os.Host, dataDir string) string

KubeconfigPath returns the path to a kubeconfig on the host

func (*BaseWindows) KubectlCmdf added in v0.29.0

func (w *BaseWindows) KubectlCmdf(h os.Host, dataDir, s string, args ...interface{}) string

KubectlCmdf returns a command line in sprintf manner for running kubectl on the host using the kubeconfig from KubeconfigPath

func (*BaseWindows) LookPath added in v0.29.0

func (w *BaseWindows) LookPath(h os.Host, file string) (string, error)

LookPath resolves a binary path on the remote Windows host similarly to exec.LookPath

func (*BaseWindows) MachineID added in v0.29.0

func (w *BaseWindows) MachineID(h os.Host) (string, error)

func (*BaseWindows) MoveFile added in v0.29.0

func (w *BaseWindows) MoveFile(h os.Host, src, dst string) error

MoveFile moves a file on the host

func (*BaseWindows) OSKind added in v0.29.0

func (w *BaseWindows) OSKind() string

OSKind returns the identifier for Windows hosts

func (*BaseWindows) PrivateAddress added in v0.29.0

func (w *BaseWindows) PrivateAddress(h os.Host, iface, publicip string) (string, error)

PrivateAddress resolves internal ip from private interface (not implemented for Windows yet)

func (*BaseWindows) PrivateInterface added in v0.29.0

func (w *BaseWindows) PrivateInterface(h os.Host) (string, error)

PrivateInterface tries to find a private network interface (not implemented for Windows yet)

func (*BaseWindows) Quote added in v0.29.0

func (w *BaseWindows) Quote(value string) string

func (*BaseWindows) ReplaceK0sTokenPath added in v0.29.0

func (w *BaseWindows) ReplaceK0sTokenPath(h os.Host, spath string) error

ReplaceK0sTokenPath replaces the config path in the service stub

func (*BaseWindows) SetPath added in v0.29.0

func (w *BaseWindows) SetPath(key, value string)

SetPath sets a path for a key

func (*BaseWindows) SystemTime added in v0.29.0

func (w *BaseWindows) SystemTime(h os.Host) (time.Time, error)

SystemTime returns the system time as UTC reported by the OS or an error if this fails

func (*BaseWindows) TempDir added in v0.29.0

func (w *BaseWindows) TempDir(h os.Host) (string, error)

TempDir returns a temp dir path

func (*BaseWindows) TempFile added in v0.29.0

func (w *BaseWindows) TempFile(h os.Host) (string, error)

TempFile returns a temp file path

func (*BaseWindows) UpsertFile added in v0.29.0

func (w *BaseWindows) UpsertFile(h os.Host, path, content string) error

UpsertFile creates a file in path with content only if the file does not exist already

type Configurer added in v0.29.0

type Configurer interface {
	Kind() string
	OSKind() string
	Quote(string) string
	CheckPrivilege(os.Host) error
	StartService(os.Host, string) error
	StopService(os.Host, string) error
	RestartService(os.Host, string) error
	ServiceIsRunning(os.Host, string) bool
	Arch(os.Host) (string, error)
	K0sCmdf(string, ...interface{}) string
	K0sBinaryPath() string
	K0sConfigPath() string
	DataDirDefaultPath() string
	K0sJoinTokenPath() string
	WriteFile(os.Host, string, string, string) error
	UpdateEnvironment(os.Host, map[string]string) error
	DaemonReload(os.Host) error
	ReplaceK0sTokenPath(os.Host, string) error
	ServiceScriptPath(os.Host, string) (string, error)
	ReadFile(os.Host, string) (string, error)
	FileExist(os.Host, string) bool
	Chmod(os.Host, string, string, ...exec.Option) error
	Chown(os.Host, string, string, ...exec.Option) error
	DownloadURL(os.Host, string, string, ...exec.Option) error
	InstallPackage(os.Host, ...string) error
	FileContains(os.Host, string, string) bool
	MoveFile(os.Host, string, string) error
	MkDir(os.Host, string, ...exec.Option) error
	DeleteFile(os.Host, string) error
	CommandExist(os.Host, string) bool
	Hostname(os.Host) string
	KubectlCmdf(os.Host, string, string, ...interface{}) string
	KubeconfigPath(os.Host, string) string
	IsContainer(os.Host) bool
	FixContainer(os.Host) error
	HTTPStatus(os.Host, string) (int, error)
	PrivateInterface(os.Host) (string, error)
	PrivateAddress(os.Host, string, string) (string, error)
	TempDir(os.Host) (string, error)
	TempFile(os.Host) (string, error)
	UpdateServiceEnvironment(os.Host, string, map[string]string) error
	CleanupServiceEnvironment(os.Host, string) error
	Stat(os.Host, string, ...exec.Option) (*os.FileInfo, error)
	DeleteDir(os.Host, string, ...exec.Option) error
	K0sctlLockFilePath(os.Host) string
	UpsertFile(os.Host, string, string) error
	MachineID(os.Host) (string, error)
	SetPath(string, string)
	SystemTime(os.Host) (time.Time, error)
	Touch(os.Host, string, time.Time, ...exec.Option) error
	Dir(string) string
	Base(string) string
	HostPath(string) string
	LookPath(os.Host, string) (string, error)
}

Configurer defines the per-host operations required for managing a host.

type HostValidator added in v0.29.0

type HostValidator interface {
	ValidateHost(os.Host) error
}

HostValidator allows a Configurer to implement host-specific validation logic.

type Linux

type Linux struct {
	// contains filtered or unexported fields
}

Linux is a base module for various linux OS support packages

func (*Linux) Arch

func (l *Linux) Arch(h os.Host) (string, error)

Arch returns the host processor architecture in the format k0s expects it

func (*Linux) Base added in v0.29.0

func (l *Linux) Base(p string) string

Base returns the base part of a path

func (*Linux) Chown added in v0.29.0

func (l *Linux) Chown(h os.Host, path, owner string, opts ...exec.Option) error

Chown sets owner for a file or directory

func (*Linux) DataDirDefaultPath added in v0.15.1

func (l *Linux) DataDirDefaultPath() string

DataDirDefaultPath returns the path to the k0s data dir on the host

func (*Linux) DeleteDir added in v0.13.0

func (l *Linux) DeleteDir(h os.Host, path string, opts ...exec.Option) error

func (*Linux) Dir added in v0.29.0

func (l *Linux) Dir(p string) string

Dir returns the directory part of a path

func (*Linux) DownloadURL added in v0.12.0

func (l *Linux) DownloadURL(h os.Host, url, destination string, opts ...exec.Option) error

DownloadURL performs a download from a URL on the host

func (*Linux) FileContains

func (l *Linux) FileContains(h os.Host, path, s string) bool

FileContains returns true if a file contains the substring

func (*Linux) HTTPStatus

func (l *Linux) HTTPStatus(h os.Host, url string) (int, error)

HTTPStatus makes a HTTP GET request to the url and returns the status code or an error

func (*Linux) HostPath added in v0.29.0

func (l *Linux) HostPath(p string) string

HostPath returns the given path unchanged for linux hosts

func (*Linux) K0sBinaryPath

func (l *Linux) K0sBinaryPath() string

K0sBinaryPath returns the path to the k0s binary on the host

func (*Linux) K0sCmdf

func (l *Linux) K0sCmdf(template string, args ...any) string

K0sCmdf can be used to construct k0s commands in sprintf style.

func (*Linux) K0sConfigPath

func (l *Linux) K0sConfigPath() string

K0sConfigPath returns the path to the k0s config file on the host

func (*Linux) K0sJoinTokenPath

func (l *Linux) K0sJoinTokenPath() string

K0sJoinTokenPath returns the path to the k0s join token file on the host

func (*Linux) K0sctlLockFilePath added in v0.13.0

func (l *Linux) K0sctlLockFilePath(h os.Host) string

K0sctlLockFilePath returns a path to a lock file

func (*Linux) KubeconfigPath

func (l *Linux) KubeconfigPath(h os.Host, dataDir string) string

KubeconfigPath returns the path to a kubeconfig on the host

func (*Linux) KubectlCmdf

func (l *Linux) KubectlCmdf(h os.Host, dataDir, s string, args ...any) string

KubectlCmdf returns a command line in sprintf manner for running kubectl on the host using the kubeconfig from KubeconfigPath

func (*Linux) LookPath added in v0.29.0

func (l *Linux) LookPath(h os.Host, file string) (string, error)

LookPath behaves similarly to exec.LookPath but resolves the binary on the remote host

func (*Linux) MachineID added in v0.15.0

func (l *Linux) MachineID(h os.Host) (string, error)

func (*Linux) MoveFile

func (l *Linux) MoveFile(h os.Host, src, dst string) error

MoveFile moves a file on the host

func (*Linux) OSKind added in v0.29.0

func (l *Linux) OSKind() string

OSKind returns the identifier for Linux hosts

func (*Linux) PrivateAddress

func (l *Linux) PrivateAddress(h os.Host, iface, publicip string) (string, error)

PrivateAddress resolves internal ip from private interface

func (*Linux) PrivateInterface

func (l *Linux) PrivateInterface(h os.Host) (string, error)

PrivateInterface tries to find a private network interface

func (*Linux) Quote added in v0.29.0

func (l *Linux) Quote(value string) string

Quote wraps shellescape.Quote for consumers that need OS-aware escaping

func (*Linux) ReplaceK0sTokenPath

func (l *Linux) ReplaceK0sTokenPath(h os.Host, spath string) error

ReplaceK0sTokenPath replaces the config path in the service stub

func (*Linux) SetPath added in v0.17.0

func (l *Linux) SetPath(key, value string)

SetPath sets a path for a key

func (*Linux) SystemTime added in v0.24.0

func (l *Linux) SystemTime(h os.Host) (time.Time, error)

SystemTime returns the system time as UTC reported by the OS or an error if this fails

func (*Linux) TempDir added in v0.8.5

func (l *Linux) TempDir(h os.Host) (string, error)

TempDir returns a temp dir path

func (*Linux) TempFile

func (l *Linux) TempFile(h os.Host) (string, error)

TempFile returns a temp file path

func (*Linux) UpsertFile added in v0.13.0

func (l *Linux) UpsertFile(h os.Host, path, content string) error

UpsertFile creates a file in path with content only if the file does not exist already

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL