osrelease

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Official fields
	NAME               = "NAME"
	ID                 = "ID"
	ID_LIKE            = "ID_LIKE"
	PRETTY_NAME        = "PRETTY_NAME"
	CPE_NAME           = "CPU_NAME"
	VARIANT            = "VARIANT"
	VARIANT_ID         = "VARIANT_ID"
	VERSION            = "VERSION"
	VERSION_ID         = "VERSION_ID"
	VERSION_CODENAME   = "VERSION_CODENAME"
	BUILD_ID           = "BUILD_ID"
	IMAGE_ID           = "IMAGE_ID"
	IMAGE_VERSION      = "IMAGE_VERSION"
	HOME_URL           = "HOME_URL"
	DOCUMENTATION_URL  = "DOCUMENTATION_URL"
	SUPPORT_URL        = "SUPPORT_URL"
	BUG_REPORT_URL     = "BUG_REPORT_URL"
	PRIVACY_POLICY_URL = "PRIVACY_POLICY_URL"
	SUPPORT_END        = "SUPPORT_END"
	ANSI_COLOR         = "ANSI_COLOR"
	VENDOR_NAME        = "VENDOR_NAME"
	VENDOR_URL         = "VENDOR_URL"
	DEFAULT_HOSTNAME   = "DEFAULT_HOSTNAME"
	ARCHITECTURE       = "ARCHITECTURE"
	SYSEXT_LEVEL       = "SYSEXT_LEVEL"
	CONFEXT_LEVEL      = "CONFEXT_LEVEL"
	SYSEXT_SCOPE       = "SYSEXT_SCOPE"
	CONFEXT_SCOPE      = "CONFEXT_SCOPE"
	PORTABLE_PREFIXES  = "PORTABLE_PREFIXES"

	// File paths to check
	ETC_OS_RELEASE     = `/etc/os-release`
	USR_LIB_OS_RELEASE = `/usr/lib/os-release`
)

constants of os-release official entries

View Source
const (
	ARCH     = `arch`
	DEBIAN   = `debian`
	FEDORA   = `fedora`
	OPENSUSE = `opensuse`
	RHEL     = `rhel`
	SUSE     = `suse`
	UBUNTU   = `ubuntu`
)

Names to match in IsLike to determine what is compatible

View Source
const SUPPORTED_SYSTEMD_VERSION = 256

Variables

This section is empty.

Functions

func Arch

func Arch() string

func BuildId

func BuildId() string

func Id

func Id() string

func ImageId

func ImageId() string

func ImageVersion

func ImageVersion() string

func IsLike

func IsLike(name string) bool

Returns values set in the os-release file

func Name

func Name() string

func Pretty

func Pretty() string

func PrettyVariant

func PrettyVariant() string

func PrettyVersion

func PrettyVersion() string

func PrintSet

func PrintSet()

PrintSet prints all of the SET values, leaving out anything that is not set Will print in a shell consumable format if the arg for shell is true

func Version

func Version() string

Types

type OsRelease

type OsRelease struct {
	// contains filtered or unexported fields
}

OsRelease uses the standard defined by [https://www.freedesktop.org/software/systemd/man/latest/os-release.html]

func Default

func Default() *OsRelease

Default is used to access the default OsRelease object Shouldn't be needed regularly

func NewOsInfo

func NewOsInfo() *OsRelease

NewOsInfo initializes a new OsInfo struct with the defined defaults of os-release

func (*OsRelease) Arch

func (i *OsRelease) Arch() string

Arch returns the value of ARCHITECTURE

func (*OsRelease) BuildId

func (i *OsRelease) BuildId() string

BuildId returns the value of BUILD_ID

func (*OsRelease) Codename

func (i *OsRelease) Codename() string

Codename returns the value of VERSION_CODENAME

func (*OsRelease) FromFile

func (i *OsRelease) FromFile(filename string) (*OsRelease, error)

FromFile sets the readFrom attribute. Panics if the given file can't be opened/doesn't exist

func (*OsRelease) Get

func (i *OsRelease) Get(key string) (string, error)

Get returns the specified value defined by the given key This method checks official and unknown keys Returns the found value and nil; or an empty string and an error

func (*OsRelease) GetOfficial

func (i *OsRelease) GetOfficial(key string) string

GetOfficial only returns the value of the official keys returns an empty string if the key isn't set

func (*OsRelease) GetUnknown

func (i *OsRelease) GetUnknown(key string) string

GetUnknown only checks the unknown keys returns an empty string if nothing is found

func (*OsRelease) Id

func (i *OsRelease) Id() string

Id returns the value of ID

func (*OsRelease) ImageId

func (i *OsRelease) ImageId() string

ImageId returns the value of IMAGE_ID

func (*OsRelease) ImageVersion

func (i *OsRelease) ImageVersion() string

ImageVersion returns the value of IMAGE_VERSION

func (*OsRelease) IsLike

func (i *OsRelease) IsLike(name string) bool

IsLike returns true if any of the given values are in 'ID_LIKE'

func (*OsRelease) Load

func (i *OsRelease) Load() error

Load reads and parses the os-release file that works

func (*OsRelease) Name

func (i *OsRelease) Name() string

Name returns the value of NAME

func (*OsRelease) Pretty

func (i *OsRelease) Pretty() string

Pretty returns the value of PRETTY_NAME

func (*OsRelease) PrettyVariant

func (i *OsRelease) PrettyVariant() string

PrettyVariant returns the value of VARIANT

func (*OsRelease) PrettyVersion

func (i *OsRelease) PrettyVersion() string

PrettyVersion returns the value of VERSION

func (*OsRelease) Set

func (i *OsRelease) Set(key, value string) bool

Set a value for the specified key returns true if the key is officially supported

func (*OsRelease) Variant

func (i *OsRelease) Variant() string

Variant returns the value of VARIANT_ID

func (*OsRelease) Version

func (i *OsRelease) Version() string

Version returns the value of VERSION_ID

Jump to

Keyboard shortcuts

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