os

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 11 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo added in v0.6.0

type FileInfo struct {
	FName    string
	FSize    int64
	FMode    fs.FileMode
	FModTime time.Time
	FIsDir   bool
}

FileInfo implements fs.FileInfo

func (*FileInfo) IsDir added in v0.6.0

func (f *FileInfo) IsDir() bool

func (*FileInfo) ModTime added in v0.6.0

func (f *FileInfo) ModTime() time.Time

func (*FileInfo) Mode added in v0.6.0

func (f *FileInfo) Mode() fs.FileMode

func (*FileInfo) Name added in v0.6.0

func (f *FileInfo) Name() string

func (*FileInfo) Size added in v0.6.0

func (f *FileInfo) Size() int64

type Host

type Host interface {
	Upload(source, destination string, opts ...exec.Option) error
	Exec(string, ...exec.Option) error
	ExecOutput(string, ...exec.Option) (string, error)
	Execf(string, ...interface{}) error
	ExecOutputf(string, ...interface{}) (string, error)
	String() string
	Sudo(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

func (c Linux) CheckPrivilege(h Host) error

func (Linux) Chmod added in v0.4.6

func (c Linux) Chmod(h Host, s, perm string, opts ...exec.Option) error

Chmod updates permissions of a path

func (Linux) CleanupEnvironment

func (c Linux) CleanupEnvironment(h Host, env map[string]string) error

CleanupEnvironment removes environment variable configuration

func (Linux) CleanupServiceEnvironment added in v0.3.24

func (c Linux) CleanupServiceEnvironment(h Host, s string) error

CleanupServiceEnvironment updates environment variables for a service

func (Linux) CommandExist

func (c Linux) CommandExist(h Host, cmd string) bool

CommandExist returns true if the command exists

func (Linux) DaemonReload

func (c Linux) DaemonReload(h Host) error

DaemonReload performs an init system config reload

func (Linux) DeleteFile

func (c Linux) DeleteFile(h Host, path string) error

DeleteFile deletes a file from the host.

func (Linux) DisableService

func (c Linux) DisableService(h Host, s string) error

DisableService disables a service on the host

func (Linux) EnableService

func (c Linux) EnableService(h Host, s string) error

EnableService enables a service on the host

func (Linux) FileExist

func (c Linux) FileExist(h Host, path string) bool

FileExist checks if a file exists on the host

func (Linux) FixContainer

func (c Linux) FixContainer(h Host) error

FixContainer makes a container work like a real host

func (Linux) Hostname

func (c Linux) Hostname(h Host) string

Hostname resolves the short hostname

func (Linux) InstallFile added in v0.4.0

func (c Linux) InstallFile(h Host, src, dst, permissions string) error

func (Linux) IsContainer

func (c Linux) IsContainer(h Host) bool

IsContainer returns true if the host is actually a container

func (Linux) JoinPath

func (c Linux) JoinPath(parts ...string) string

JoinPath joins a path

func (Linux) Kind

func (c Linux) Kind() string

Kind returns "linux"

func (Linux) LineIntoFile

func (c Linux) LineIntoFile(h Host, path, matcher, newLine string) error

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

func (c Linux) LongHostname(h Host) string

LongHostname resolves the FQDN (long) hostname

func (Linux) MkDir added in v0.4.6

func (c Linux) MkDir(h Host, s string, opts ...exec.Option) error

MkDir creates a directory (including intermediate directories)

func (Linux) Pwd

func (c Linux) Pwd(h Host) string

Pwd returns the current working directory of the session

func (Linux) ReadFile

func (c Linux) ReadFile(h Host, path string) (string, error)

ReadFile reads a files contents from the host.

func (Linux) Reboot

func (c Linux) Reboot(h Host) error

Reboot executes the reboot command

func (Linux) RestartService

func (c Linux) RestartService(h Host, s string) error

RestartService restarts a service on the host

func (Linux) SELinuxEnabled

func (c Linux) SELinuxEnabled(h Host) bool

SELinuxEnabled is true when SELinux is enabled

func (Linux) ServiceIsRunning

func (c Linux) ServiceIsRunning(h Host, s string) bool

ServiceIsRunning returns true if the service is running on the host

func (Linux) ServiceScriptPath

func (c Linux) ServiceScriptPath(h Host, s string) (string, error)

ServiceScriptPath returns the service definition file path on the host

func (Linux) StartService

func (c Linux) StartService(h Host, s string) error

StartService starts a service on the host

func (Linux) Stat added in v0.6.0

func (c Linux) Stat(h Host, path string, opts ...exec.Option) (*FileInfo, error)

Stat gets file / directory information

func (Linux) StopService

func (c Linux) StopService(h Host, s string) error

StopService stops a service on the host

func (Linux) Touch added in v0.6.0

func (c Linux) Touch(h Host, path string, ts time.Time, opts ...exec.Option) error

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

func (c Linux) UpdateEnvironment(h Host, env map[string]string) error

UpdateEnvironment updates the hosts's environment variables

func (Linux) UpdateServiceEnvironment added in v0.3.24

func (c Linux) UpdateServiceEnvironment(h Host, s string, env map[string]string) error

UpdateServiceEnvironment updates environment variables for a service

func (Linux) WriteFile

func (c Linux) WriteFile(h Host, path string, data string, permissions string) error

WriteFile writes file to host with given contents. Do not use for large files.

type Windows

type Windows struct{}

Windows is the base package for windows OS support

func (Windows) CheckPrivilege

func (c Windows) CheckPrivilege(h Host) error

CheckPrivilege returns an error if the user does not have admin access to the host

func (Windows) Chmod added in v0.4.6

func (c Windows) Chmod(h Host, s, perm string, opts ...exec.Option) error

Chmod on windows does nothing

func (Windows) CleanupEnvironment

func (c Windows) CleanupEnvironment(h Host, env map[string]string) error

CleanupEnvironment removes environment variable configuration

func (Windows) CleanupServiceEnvironment added in v0.3.24

func (c Windows) CleanupServiceEnvironment(_ Host, _ string) error

CleanupServiceEnvironment does nothing on windows

func (Windows) CommandExist

func (c Windows) CommandExist(h Host, cmd string) bool

CommandExist returns true if the provided command exists

func (Windows) DaemonReload

func (c Windows) DaemonReload(_ Host) error

DaemonReload reloads init system configuration

func (Windows) DeleteFile

func (c Windows) DeleteFile(h Host, path string) error

DeleteFile deletes a file from the host.

func (Windows) DisableService

func (c Windows) DisableService(h Host, s string) error

DisableService disables a a service

func (Windows) EnableService

func (c Windows) EnableService(h Host, s string) error

EnableService enables a a service

func (Windows) FileExist

func (c Windows) FileExist(h Host, path string) bool

FileExist checks if a file exists on the host

func (Windows) FixContainer

func (c Windows) FixContainer(_ Host) error

FixContainer makes a container work like a real host (does nothing on windows for now)

func (Windows) Hostname

func (c Windows) Hostname(h Host) string

Hostname resolves the short hostname

func (Windows) InstallFile added in v0.4.0

func (c Windows) InstallFile(h Host, src, dst, _ string) error

func (Windows) InstallPackage

func (c Windows) InstallPackage(h Host, s ...string) error

InstallPackage enables an optional windows feature

func (Windows) IsContainer

func (c Windows) IsContainer(_ Host) bool

IsContainer returns true if the host is actually a container (always false on windows for now)

func (Windows) JoinPath

func (c Windows) JoinPath(parts ...string) string

JoinPath joins a path

func (Windows) Kind

func (c Windows) Kind() string

Kind returns "windows"

func (Windows) LineIntoFile added in v0.6.2

func (c Windows) LineIntoFile(h Host, path, matcher, newLine string) error

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

func (c Windows) LongHostname(h Host) string

LongHostname resolves the FQDN (long) hostname

func (Windows) MkDir added in v0.4.6

func (c Windows) MkDir(h Host, s string, opts ...exec.Option) error

MkDir creates a directory (including intermediate directories)

func (Windows) Pwd

func (c Windows) Pwd(h Host) string

Pwd returns the current working directory

func (Windows) ReadFile

func (c Windows) ReadFile(h Host, path string) (string, error)

ReadFile reads a files contents from the host.

func (Windows) Reboot

func (c Windows) Reboot(h Host) error

Reboot executes the reboot command

func (Windows) RestartService

func (c Windows) RestartService(h Host, s string) error

RestartService restarts a a service

func (Windows) SELinuxEnabled

func (c Windows) SELinuxEnabled(_ Host) bool

SELinuxEnabled is true when SELinux is enabled (always false on windows for now)

func (Windows) ServiceIsRunning

func (c Windows) ServiceIsRunning(h Host, s string) bool

ServiceIsRunning returns true if a service is running

func (Windows) ServiceScriptPath

func (c Windows) ServiceScriptPath(h Host, s string) (string, error)

ServiceScriptPath returns the path to a service configuration file

func (Windows) StartService

func (c Windows) StartService(h Host, s string) error

StartService starts a a service

func (Windows) Stat added in v0.6.0

func (c Windows) Stat(h Host, path string, opts ...exec.Option) (*FileInfo, error)

Stat gets file / directory information

func (Windows) StopService

func (c Windows) StopService(h Host, s string) error

StopService stops a a service

func (Windows) Touch added in v0.6.0

func (c Windows) Touch(h Host, path string, ts time.Time, opts ...exec.Option) error

Touch updates a file's last modified time or creates a new empty file

func (Windows) UpdateEnvironment

func (c Windows) UpdateEnvironment(h Host, env map[string]string) error

UpdateEnvironment updates the hosts's environment variables

func (Windows) UpdateServiceEnvironment added in v0.3.24

func (c Windows) UpdateServiceEnvironment(_ Host, _ string, _ map[string]string) error

UpdateServiceEnvironment does nothing on windows

func (Windows) WriteFile

func (c Windows) WriteFile(h Host, path string, data string, permissions string) error

WriteFile writes file to host with given contents. Do not use for large files. The permissions argument is ignored on windows.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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