Documentation ¶
Overview ¶
Package system contains utils to get system information relevant to the Agent.
Index ¶
- type Backend
- type Option
- type System
- func (s System) Info(ctx context.Context) (*agentapi.DistroInfo, error)
- func (s *System) LandscapeDisable(ctx context.Context) (err error)
- func (s *System) LandscapeEnable(ctx context.Context, landscapeConfig string, hostagentUID string) (err error)
- func (s System) Path(path ...string) string
- func (s *System) ProAttach(ctx context.Context, token string) (err error)
- func (s *System) ProDetach(ctx context.Context) (err error)
- func (s System) ProStatus(ctx context.Context) (attached bool, err error)
- func (s *System) UserProfileDir(ctx context.Context) (wslPath string, err error)
- func (s *System) WindowsHostAddress(ctx context.Context) (ip net.IP, err error)
- func (s *System) WslDistroName(ctx context.Context) (name string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Path(p ...string) string Hostname() (string, error) GetenvWslDistroName() string LookupGroup(string) (*user.Group, error) ProExecutable(ctx context.Context, args ...string) *exec.Cmd LandscapeConfigExecutable(ctx context.Context, args ...string) *exec.Cmd WslpathExecutable(ctx context.Context, args ...string) *exec.Cmd WslinfoExecutable(ctx context.Context, args ...string) *exec.Cmd CmdExe(ctx context.Context, path string, args ...string) *exec.Cmd }
Backend is the engine behind the System object, and defines the interactions it can perform with the operating system.
type Option ¶
type Option = func(*options)
Option is an optional argument for New.
func WithTestBackend ¶
WithTestBackend is an optional argument for New that injects a backend into the system. For testing purposes only.
type System ¶
type System struct {
// contains filtered or unexported fields
}
System is an object with an easily pluggable back-end that allows accessing the filesystem, a few key executables, and some information about the system.
Do not replace the backend after construction, and use one of the provided constructors.
func New ¶
New instantiates a stateless object that mediates interactions with the filesystem as well as a few key executables.
func (System) Info ¶
Info returns the current information about the system relevant to the GRPC connection to the agent.
func (*System) LandscapeDisable ¶
LandscapeDisable unregisters the current distro from Landscape.
func (*System) LandscapeEnable ¶
func (s *System) LandscapeEnable(ctx context.Context, landscapeConfig string, hostagentUID string) (err error)
LandscapeEnable registers the current distro to Landscape with the specified config.
func (*System) ProDetach ¶
ProDetach detaches the current distro from Ubuntu Pro. If the distro was already detached, nothing is done.
func (*System) UserProfileDir ¶
UserProfileDir provides the path to Windows' user profile directory from WSL, usually `/mnt/c/Users/JohnDoe/`.
func (*System) WindowsHostAddress ¶
WindowsHostAddress returns the IP that maps to Windows' localhost.
func (*System) WslDistroName ¶
WslDistroName obtains the name of the current WSL distro from these sources 1. From environment variable WSL_DISTRO_NAME, as long as it is not empty 2. From the Windows path to the distro's root ("\\wsl.localhost\<DISTRO_NAME>\").