github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/linux/release.go (about)

     1  package linux
     2  
     3  // Release represents Linux Distribution release information as specified from https://www.freedesktop.org/software/systemd/man/os-release.html
     4  type Release struct {
     5  	PrettyName       string   `cyclonedx:"prettyName"` // A pretty operating system name in a format suitable for presentation to the user.
     6  	Name             string   // identifies the operating system, without a version component, and suitable for presentation to the user.
     7  	ID               string   `cyclonedx:"id"`     // identifies the operating system, excluding any version information and suitable for processing by scripts or usage in generated filenames.
     8  	IDLike           []string `cyclonedx:"idLike"` // list of operating system identifiers in the same syntax as the ID= setting. It should list identifiers of operating systems that are closely related to the local operating system in regards to packaging and programming interfaces.
     9  	Version          string   // identifies the operating system version, excluding any OS name information, possibly including a release code name, and suitable for presentation to the user.
    10  	VersionID        string   `cyclonedx:"versionID"` // identifies the operating system version, excluding any OS name information or release code name, and suitable for processing by scripts or usage in generated filenames.
    11  	VersionCodename  string   `cyclonedx:"versionCodename"`
    12  	BuildID          string   `cyclonedx:"buildID"` // A string uniquely identifying the system image originally used as the installation base.
    13  	ImageID          string   `cyclonedx:"imageID"`
    14  	ImageVersion     string   `cyclonedx:"imageVersion"`
    15  	Variant          string   `cyclonedx:"variant"`   // identifies a specific variant or edition of the operating system suitable for presentation to the user.
    16  	VariantID        string   `cyclonedx:"variantID"` // identifies a specific variant or edition of the operating system. This may be interpreted by other packages in order to determine a divergent default configuration.
    17  	HomeURL          string
    18  	SupportURL       string
    19  	BugReportURL     string
    20  	PrivacyPolicyURL string
    21  	CPEName          string // A CPE name for the operating system, in URI binding syntax
    22  	SupportEnd       string // The date at which support for this version of the OS ends.
    23  }
    24  
    25  func (r *Release) String() string {
    26  	if r == nil {
    27  		return "unknown"
    28  	}
    29  	if r.PrettyName != "" {
    30  		return r.PrettyName
    31  	}
    32  	if r.Name != "" {
    33  		return r.Name
    34  	}
    35  	if r.Version != "" {
    36  		return r.ID + " " + r.Version
    37  	}
    38  	if r.VersionID != "" {
    39  		return r.ID + " " + r.VersionID
    40  	}
    41  
    42  	return r.ID + " " + r.BuildID
    43  }