Documentation ¶
Index ¶
Constants ¶
View Source
const ( OSReleaseFile = "/etc/os-release" OSReleaseFileNew = "/usr/lib/os-release" LSBReleaseFile = "/etc/lsb-release" IssueFile = "/etc/issue" IssueNetFile = "/etc/issue.net" DebianVersionFile = "/etc/debian_version" RedhatReleaseFile = "/etc/redhat-release" CentosReleaseFile = "/etc/centos-release" FedoraReleaseFile = "/etc/fedora-release" OracleReleaseFile = "/etc/oracle-release" SystemReleaseFile = "/etc/system-release" // Redhat/Centos/Fedora/Rocky/Alma/AmazonLinux/Oracle SystemReleaseCPEFile = "/etc/system-release-cpe" // Redhat/Centos/Fedora/Rocky/Alma/AmazonLinux/Oracle RockyReleaseFile = "/etc/rocky-release" RockyReleaseUpstream = "/etc/rocky-release-upstream" AmazonLinuxReleaseFile = "/etc/amazon-linux-release" AmazonLinuxReleaseCPEFile = "/etc/amazon-linux-release-cpe" AlpineReleaseFile = "/etc/alpine-release" //only version number ArchReleaseFile = "/etc/arch-release" //can be empty SuseReleaseFile = "/etc/SuSE-release" //depricated SuseBrandFile = "/etc/SUSE-brand" GentooReleaseFile = "/etc/gentoo-release" SlackwareVersionFile = "/etc/slackware-version" NixOSInfoFile = "/etc/NIXOS" )
Data file names
View Source
const ( DebianID = "debian" DebianName = "Debian GNU/Linux" UbuntuID = "ubuntu" UbuntuName = "Ubuntu" FedoraID = "fedora" FedoraName = "Fedora Linux" RedhatID = "rhel" RedhatName = "Red Hat Enterprise Linux" CentosID = "centos" CentosName = "CentOS Linux" RockyLinuxID = "rocky" RockyLinuxName = "Rocky Linux" AlmaLinuxID = "almalinux" //can be in double quotes AlmaLinuxName = "AlmaLinux" AmazonLinuxID = "amzn" //can be in double quotes AmazonLinuxName = "Amazon Linux" OracleLinuxID = "ol" //can be in double quotes OracleLinuxName = "Oracle Linux Server" AlpineID = "alpine" AlpineName = "Alpine Linux" ArchID = "arch" ArchName = "Arch Linux" WolfiID = "wolfi" //base wolfi images and Chainguard images WolfiName = "Wolfi" ClearLinuxID = "clear-linux-os" ClearLinuxName = "Clear Linux OS" GentooID = "gentoo" GentooName = "Gentoo" SlackwareID = "slackware" SlackwareName = "Slackware" OpenSuseID = "opensuse" //need to do a "contains" check (e.g., to match "opensuse-leap") OpenSuseName = "openSUSE" SlesID = "sles" //could be in double quotes (need to strip double quotes if present) SlesName = "SLES" //SUSE Linux Enterprise Server BottlerocketID = "bottlerocket" BottlerocketName = "Bottlerocket" FlatcarID = "flatcar" FlatcarName = "Flatcar Container Linux by Kinvolk" CoreosID = "coreos" CoreosName = "Container Linux by CoreOS" NixosID = "nixos" NixosName = "NixOS" )
Linux distro IDs and names
Variables ¶
View Source
var AllFiles = map[string]struct{}{ OSReleaseFile: {}, OSReleaseFileNew: {}, IssueFile: {}, IssueNetFile: {}, LSBReleaseFile: {}, DebianVersionFile: {}, RedhatReleaseFile: {}, CentosReleaseFile: {}, FedoraReleaseFile: {}, OracleReleaseFile: {}, SystemReleaseFile: {}, SystemReleaseCPEFile: {}, RockyReleaseFile: {}, RockyReleaseUpstream: {}, AmazonLinuxReleaseFile: {}, AmazonLinuxReleaseCPEFile: {}, AlpineReleaseFile: {}, ArchReleaseFile: {}, SuseReleaseFile: {}, SuseBrandFile: {}, GentooReleaseFile: {}, SlackwareVersionFile: {}, NixOSInfoFile: {}, }
A map of distro info files (todo: add a list of distros where the files are used)
View Source
var DistrosByID = map[string]string{ DebianID: DebianName, UbuntuID: UbuntuName, FedoraID: FedoraName, RedhatID: RedhatName, CentosID: CentosName, RockyLinuxID: RockyLinuxName, AlmaLinuxID: AlmaLinuxName, AmazonLinuxID: AmazonLinuxName, OracleLinuxID: OracleLinuxName, AlpineID: AlpineName, ArchID: ArchName, WolfiID: WolfiName, ClearLinuxID: ClearLinuxName, GentooID: GentooName, SlackwareID: SlackwareName, OpenSuseID: OpenSuseName, SlesID: SlesName, BottlerocketID: BottlerocketName, FlatcarID: FlatcarName, CoreosID: CoreosName, NixosID: NixosName, }
Functions ¶
func IsDataFile ¶
func IsKnownDistro ¶
func IsOSReleaseFile ¶
Types ¶
type OsRelease ¶
type OsRelease struct { AnsiColor string `osr:"ANSI_COLOR"` Name string `osr:"NAME"` Version string `osr:"VERSION"` Variant string `osr:"VARIANT"` VariantID string `osr:"VARIANT_ID"` ID string `osr:"ID"` IDLike string `osr:"ID_LIKE"` PrettyName string `osr:"PRETTY_NAME"` VersionID string `osr:"VERSION_ID"` HomeURL string `osr:"HOME_URL"` SupportURL string `osr:"SUPPORT_URL"` BugReportURL string `osr:"BUG_REPORT_URL"` }
OsRelease reflects values in /etc/os-release Values in this struct must always be string or the reflection will not work properly.
func NewOsRelease ¶
func (*OsRelease) ParseOsRelease ¶
Click to show internal directories.
Click to hide internal directories.