Documentation ¶
Overview ¶
Package os provides remote OS release information detection
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultProvider is the default OS release provider. DefaultProvider = sync.OnceValue(func() *Provider { provider := NewProvider() provider.Register(ResolveLinux) provider.Register(ResolveWindows) provider.Register(ResolveDarwin) return provider }) // ErrNotRecognized is returned when the host OS is not recognized. ErrNotRecognized = errors.New("host OS not recognized") )
Functions ¶
func RegisterDarwin ¶
func RegisterDarwin(provider *Provider)
RegisterDarwin registers the darwin OS release resolver to a provider.
func RegisterLinux ¶
func RegisterLinux(provider *Provider)
RegisterLinux registers the linux OS release resolver to a provider.
func RegisterWindows ¶
func RegisterWindows(provider *Provider)
RegisterWindows registers the windows OS release resolver to a provider.
Types ¶
type Factory ¶
type Factory = plumbing.Factory[cmd.SimpleRunner, *Release]
Factory is a function that returns an OS release based on the provided runner.
type OSReleaseProvider ¶
type OSReleaseProvider interface {
Get(runner cmd.SimpleRunner) (*Release, error)
}
OSReleaseProvider is a factory for OS release information.
type Provider ¶
type Provider = plumbing.Provider[cmd.SimpleRunner, *Release]
Provider is a type that can determine the host OS given a runner.
type Release ¶
type Release struct { ID string `kv:"ID"` IDLike []string `kv:"ID_LIKE,delim: "` Name string `kv:"NAME"` Version string `kv:"VERSION_ID"` ExtraFields map[string]string `kv:"*"` }
Release describes host operating system version information.
func ResolveDarwin ¶
func ResolveDarwin(conn cmd.SimpleRunner) (*Release, bool)
ResolveDarwin resolves the OS release information for a darwin host.
func ResolveLinux ¶
func ResolveLinux(conn cmd.SimpleRunner) (*Release, bool)
ResolveLinux resolves the OS release information for a linux host.
func ResolveWindows ¶
func ResolveWindows(conn cmd.SimpleRunner) (*Release, bool)
ResolveWindows resolves the OS release information for a windows host.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides an interface to detect the operating system version and release information using the specified Provider. The result is lazily initialized and memoized.
func NewOSReleaseService ¶
func NewOSReleaseService(provider OSReleaseProvider, runner cmd.SimpleRunner) *Service
NewOSReleaseService creates a new instance of Service with the provided provider and runner.
func (*Service) GetOSRelease ¶
GetOSRelease returns remote host operating system version and release information.