Documentation ¶
Overview ¶
Package os provides a platform-independent interface to operating system functionality.
Index ¶
- Variables
- type FileInfo
- type Host
- type Linux
- func (c Linux) CheckPrivilege(h Host) error
- func (c Linux) Chmod(h Host, s, perm string, opts ...exec.Option) error
- func (c Linux) CleanupEnvironment(h Host, env map[string]string) error
- func (c Linux) CleanupServiceEnvironment(h Host, s string) error
- func (c Linux) CommandExist(h Host, cmd string) bool
- func (c Linux) DaemonReload(h Host) error
- func (c Linux) DeleteFile(h Host, path string) error
- func (c Linux) DisableService(h Host, s string) error
- func (c Linux) EnableService(h Host, s string) error
- func (c Linux) FileExist(h Host, path string) bool
- func (c Linux) FixContainer(h Host) error
- func (c Linux) Hostname(h Host) string
- func (c Linux) InstallFile(h Host, src, dst, permissions string) error
- func (c Linux) IsContainer(h Host) bool
- func (c Linux) JoinPath(parts ...string) string
- func (c Linux) Kind() string
- func (c Linux) LineIntoFile(h Host, path, matcher, newLine string) error
- func (c Linux) LongHostname(h Host) string
- func (c Linux) MkDir(h Host, s string, opts ...exec.Option) error
- func (c Linux) Pwd(h Host) string
- func (c Linux) ReadFile(h Host, path string) (string, error)
- func (c Linux) Reboot(h Host) error
- func (c Linux) RestartService(h Host, s string) error
- func (c Linux) SELinuxEnabled(h Host) bool
- func (c Linux) ServiceIsRunning(h Host, s string) bool
- func (c Linux) ServiceScriptPath(h Host, s string) (string, error)
- func (c Linux) Sha256sum(h Host, path string, opts ...exec.Option) (string, error)
- func (c Linux) StartService(h Host, s string) error
- func (c Linux) Stat(h Host, path string, opts ...exec.Option) (*FileInfo, error)
- func (c Linux) StopService(h Host, s string) error
- func (c Linux) Touch(h Host, path string, ts time.Time, opts ...exec.Option) error
- func (c Linux) UpdateEnvironment(h Host, env map[string]string) error
- func (c Linux) UpdateServiceEnvironment(h Host, s string, env map[string]string) error
- func (c Linux) WriteFile(h Host, path string, data string, permissions string) error
- type Windows
- func (c Windows) CheckPrivilege(h Host) error
- func (c Windows) Chmod(_ Host, _, _ string, _ ...exec.Option) error
- func (c Windows) CleanupEnvironment(h Host, env map[string]string) error
- func (c Windows) CleanupServiceEnvironment(_ Host, _ string) error
- func (c Windows) CommandExist(h Host, cmd string) bool
- func (c Windows) DaemonReload(_ Host) error
- func (c Windows) DeleteFile(h Host, path string) error
- func (c Windows) DisableService(h Host, s string) error
- func (c Windows) EnableService(h Host, s string) error
- func (c Windows) FileExist(h Host, path string) bool
- func (c Windows) FixContainer(_ Host) error
- func (c Windows) Hostname(h Host) string
- func (c Windows) InstallFile(h Host, src, dst, _ string) error
- func (c Windows) InstallPackage(h Host, s ...string) error
- func (c Windows) IsContainer(_ Host) bool
- func (c Windows) JoinPath(parts ...string) string
- func (c Windows) Kind() string
- func (c Windows) LineIntoFile(h Host, path, matcher, newLine string) error
- func (c Windows) LongHostname(h Host) string
- func (c Windows) MkDir(h Host, s string, opts ...exec.Option) error
- func (c Windows) Pwd(h Host) string
- func (c Windows) ReadFile(h Host, path string) (string, error)
- func (c Windows) Reboot(h Host) error
- func (c Windows) RestartService(h Host, s string) error
- func (c Windows) SELinuxEnabled(_ Host) bool
- func (c Windows) ServiceIsRunning(h Host, s string) bool
- func (c Windows) ServiceScriptPath(_ Host, _ string) (string, error)
- func (c Windows) Sha256sum(h Host, path string, opts ...exec.Option) (string, error)
- func (c Windows) StartService(h Host, s string) error
- func (c Windows) Stat(h Host, path string, opts ...exec.Option) (*FileInfo, error)
- func (c Windows) StopService(h Host, s string) error
- func (c Windows) Touch(h Host, path string, ts time.Time, opts ...exec.Option) error
- func (c Windows) UpdateEnvironment(h Host, env map[string]string) error
- func (c Windows) UpdateServiceEnvironment(_ Host, _ string, _ map[string]string) error
- func (c Windows) WriteFile(h Host, path string, data string, _ string) error
Constants ¶
This section is empty.
Variables ¶
var ErrCommandFailed = errors.New("command failed")
ErrCommandFailed is returned when a command fails
var ErrInitSystemNotSupported = errors.New("init system not supported")
ErrInitSystemNotSupported is returned when the init system is not supported
Functions ¶
This section is empty.
Types ¶
type FileInfo ¶ added in v0.6.0
FileInfo implements fs.FileInfo for stat on remote files
type Host ¶
type Host interface { Upload(source, destination string, opts ...exec.Option) error Exec(cmd string, opts ...exec.Option) error ExecOutput(cmd string, opts ...exec.Option) (string, error) Execf(cmd string, argsOrOpts ...any) error ExecOutputf(cmd string, argsOrOpts ...any) (string, error) ExecStreams(cmd string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer, opts ...exec.Option) (exec.Waiter, error) String() string Sudo(cmd string) (string, error) }
Host is an interface to a host object that has the functions needed by the various OS support packages
type Linux ¶
type Linux struct{}
Linux is a base module for various linux OS support packages
func (Linux) CheckPrivilege ¶
CheckPrivilege checks if the current user has root privileges
func (Linux) CleanupEnvironment ¶
CleanupEnvironment removes environment variable configuration
func (Linux) CleanupServiceEnvironment ¶ added in v0.3.24
CleanupServiceEnvironment updates environment variables for a service
func (Linux) CommandExist ¶
CommandExist returns true if the command exists
func (Linux) DaemonReload ¶
DaemonReload performs an init system config reload
func (Linux) DeleteFile ¶
DeleteFile deletes a file from the host.
func (Linux) DisableService ¶
DisableService disables a service on the host
func (Linux) EnableService ¶
EnableService enables a service on the host
func (Linux) FixContainer ¶
FixContainer makes a container work like a real host
func (Linux) InstallFile ¶ added in v0.4.0
InstallFile installs a file to the host
func (Linux) IsContainer ¶
IsContainer returns true if the host is actually a container
func (Linux) LineIntoFile ¶
LineIntoFile tries to find a line starting with the matcher and replace it with a new entry. If match isn't found, the string is appended to the file. TODO add exec.Opts (requires modifying readfile and writefile signatures)
func (Linux) LongHostname ¶
LongHostname resolves the FQDN (long) hostname
func (Linux) RestartService ¶
RestartService restarts a service on the host
func (Linux) SELinuxEnabled ¶
SELinuxEnabled is true when SELinux is enabled
func (Linux) ServiceIsRunning ¶
ServiceIsRunning returns true if the service is running on the host
func (Linux) ServiceScriptPath ¶
ServiceScriptPath returns the service definition file path on the host
func (Linux) StartService ¶
StartService starts a service on the host
func (Linux) StopService ¶
StopService stops a service on the host
func (Linux) Touch ¶ added in v0.6.0
Touch updates a file's last modified time. It creates a new empty file if it didn't exist prior to the call to Touch.
func (Linux) UpdateEnvironment ¶
UpdateEnvironment updates the hosts's environment variables
func (Linux) UpdateServiceEnvironment ¶ added in v0.3.24
UpdateServiceEnvironment updates environment variables for a service
type Windows ¶
type Windows struct{}
Windows is the base package for windows OS support
func (Windows) CheckPrivilege ¶
CheckPrivilege returns an error if the user does not have admin access to the host
func (Windows) CleanupEnvironment ¶
CleanupEnvironment removes environment variable configuration
func (Windows) CleanupServiceEnvironment ¶ added in v0.3.24
CleanupServiceEnvironment does nothing on windows
func (Windows) CommandExist ¶
CommandExist returns true if the provided command exists
func (Windows) DaemonReload ¶
DaemonReload reloads init system configuration. No-op on windows.
func (Windows) DeleteFile ¶
DeleteFile deletes a file from the host.
func (Windows) DisableService ¶
DisableService disables a service
func (Windows) EnableService ¶
EnableService enables a service
func (Windows) FixContainer ¶
FixContainer makes a container work like a real host (does nothing on windows for now)
func (Windows) InstallFile ¶ added in v0.4.0
InstallFile on windows is a regular file move operation
func (Windows) InstallPackage ¶
InstallPackage enables an optional windows feature
func (Windows) IsContainer ¶
IsContainer returns true if the host is actually a container (always false on windows for now)
func (Windows) LineIntoFile ¶ added in v0.6.2
LineIntoFile tries to find a line starting with the matcher and replace it with a new entry. If match isn't found, the string is appended to the file. TODO this is a straight copypaste from linux, figure out a way to share these
func (Windows) LongHostname ¶
LongHostname resolves the FQDN (long) hostname
func (Windows) MkDir ¶ added in v0.4.6
MkDir creates a directory (including intermediate directories)
func (Windows) RestartService ¶
RestartService restarts a service
func (Windows) SELinuxEnabled ¶
SELinuxEnabled is true when SELinux is enabled (always false on windows for now)
func (Windows) ServiceIsRunning ¶
ServiceIsRunning returns true if a service is running
func (Windows) ServiceScriptPath ¶
ServiceScriptPath returns the path to a service configuration file
func (Windows) StartService ¶
StartService starts a service
func (Windows) StopService ¶
StopService stops a service
func (Windows) Touch ¶ added in v0.6.0
Touch updates a file's last modified time or creates a new empty file
func (Windows) UpdateEnvironment ¶
UpdateEnvironment updates the hosts's environment variables
func (Windows) UpdateServiceEnvironment ¶ added in v0.3.24
UpdateServiceEnvironment does nothing on windows
Directories ¶
Path | Synopsis |
---|---|
Package initsystem provides an abstraction over several supported init systems.
|
Package initsystem provides an abstraction over several supported init systems. |
Package linux contains configurers for various linux based distributions
|
Package linux contains configurers for various linux based distributions |
enterpriselinux
Package enterpriselinux provides OS modules for Enterprise Linux based distributions
|
Package enterpriselinux provides OS modules for Enterprise Linux based distributions |
Package darwin provides a configurer for macOS
|
Package darwin provides a configurer for macOS |
Package registry is a registry of OS support modules
|
Package registry is a registry of OS support modules |
Package support can be imported to load all the stock os support packages.
|
Package support can be imported to load all the stock os support packages. |
Package windows provides OS support for Windows.
|
Package windows provides OS support for Windows. |