os

package
v2.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package os provides remote OS release information detection

Index

Constants

This section is empty.

Variables

View Source
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

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

Provider is a type that can determine the host OS given a runner.

func NewProvider

func NewProvider() *Provider

NewProvider creates a new OS release provider.

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.

func (Release) String

func (o Release) String() string

String returns a human readable representation of the release information.

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

func (p *Service) GetOSRelease() (*Release, error)

GetOSRelease returns remote host operating system version and release information.

Jump to

Keyboard shortcuts

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