os

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package os is for running commands on a remote host

Index

Constants

View Source
const (
	// BinaryPath key for the binary path for the distro engine
	BinaryPath = "BinaryPath"
	// ConfigPath key for the config directory for the distro engine
	ConfigPath = "ConfigPath"
	// JoinTokenPath key for the join token for the cluster
	JoinTokenPath = "JoinTokenPath"
	// DataDirDefaultPath key for the data directory for the distro engine
	DataDirDefaultPath = "DataDirDefaultPath"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configurer

type Configurer interface {
	//keep-sorted start
	Arch(os.Host) (string, error)
	Base(string) string
	CTLLockFilePath(h os.Host) string
	CheckPrivilege(os.Host) error
	Chmod(os.Host, string, string, ...exec.Option) error
	Chown(os.Host, string, string, ...exec.Option) error
	CleanupServiceEnvironment(os.Host, string) error
	CommandExist(os.Host, string) bool
	DaemonReload(os.Host) error
	DeleteDir(os.Host, string, ...exec.Option) error
	DeleteFile(os.Host, string) error
	Dir(string) string
	DownloadURL(os.Host, string, string, ...exec.Option) error
	EnableService(os.Host, string) error
	FileContains(os.Host, string, string) bool
	FileExist(os.Host, string) bool
	GetDistroService(string) (string, error)
	GetSysctlValue(os.Host, string) (string, error)
	HTTPStatus(os.Host, string) (int, error)
	HostPath(string) string
	Hostname(os.Host) string
	InstallPackage(os.Host, ...string) error
	Kind() string
	LongHostname(os.Host) string
	LookPath(os.Host, string) (string, error)
	MkDir(os.Host, string, ...exec.Option) error
	MoveFile(os.Host, string, string) error
	OSKind() string
	PrivateAddress(os.Host, string, string) (string, error)
	PrivateInterface(os.Host) (string, error)
	Quote(string) string
	ReadFile(os.Host, string) (string, error)
	RestartService(os.Host, string) error
	SELinuxEnabled(os.Host) bool
	ServiceIsRunning(os.Host, string) bool
	ServiceScriptPath(os.Host, string) (string, error)
	SetPath(string, string)
	SetSysctlValue(os.Host, string, string) error
	Sha256sum(h os.Host, path string, opts ...exec.Option) (string, error)
	StartService(os.Host, string) error
	Stat(os.Host, string, ...exec.Option) (*os.FileInfo, error)
	StopService(os.Host, string) error
	SystemTime(os.Host) (time.Time, error)
	TempDir(os.Host) (string, error)
	TempFile(os.Host) (string, error)
	Touch(os.Host, string, time.Time, ...exec.Option) error
	UninstallPackage(os.Host, ...string) error
	UpdateEnvironment(os.Host, map[string]string) error
	UpdateServiceEnvironment(os.Host, string, map[string]string) error
	UpsertFile(os.Host, string, string) error
	WriteFile(os.Host, string, string, string) error
}

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

type HostValidator

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 engine expects it

func (*Linux) Base

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

Base returns the base part of a path

func (*Linux) CTLLockFilePath

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

CTLLockFilePath returns a path to a lock file

func (*Linux) Chown

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

Chown sets owner for a file or directory

func (*Linux) DeleteDir

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

DeleteDir removes a directory

func (*Linux) Dir

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

Dir returns the directory part of a path

func (*Linux) DownloadURL

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) GetDistroService

func (l *Linux) GetDistroService(key string) (string, error)

GetDistroService returns the name of the service for the current distro. common key values are, "controller" and "agent"

func (*Linux) GetSysctlValue

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

GetSysctlValue get the current value of a sysctl value, will return an error if the key does not exist

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

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

HostPath returns the given path unchanged for linux hosts

func (*Linux) LookPath

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) MoveFile

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

MoveFile moves a file on the host

func (*Linux) OSKind

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

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

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

func (*Linux) SetPath

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

SetPath adds a key value to the paths string map. TODO add ref to what the paths string map does....

func (*Linux) SetSysctlValue

func (l *Linux) SetSysctlValue(h os.Host, key string, value string) error

SetSysctlValue sets the sysctl key with the given value, will return if any errors are set

func (*Linux) SystemTime

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

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

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
Package linux is implementing the interface github.com/colonel-byte/cargoship/src/types/os.Configurer for Linux based hosts
Package linux is implementing the interface github.com/colonel-byte/cargoship/src/types/os.Configurer for Linux based hosts
enterpriselinux
Package enterpriselinux is implementing the interface github.com/colonel-byte/cargoship/src/types/os.Configurer for Enterprise Linux hosts
Package enterpriselinux is implementing the interface github.com/colonel-byte/cargoship/src/types/os.Configurer for Enterprise Linux hosts

Jump to

Keyboard shortcuts

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