Skip to content

Commit

Permalink
feat: change language in smbios to an array
Browse files Browse the repository at this point in the history
When running nixos-facter on a Topton 4-port x86_64 Celeron N5105, the SMBIOS is returning multiple language entries.

```console
sudo dmidecode -t bios
# dmidecode 3.6
Getting SMBIOS data from sysfs.
SMBIOS 3.3.0 present.

...

Handle 0x0017, DMI type 13, 22 bytes
BIOS Language Information
	Language Description Format: Long
	Installable Languages: 1
		en|US|iso8859-1
	Currently Installed Language: en|US|iso8859-1

Handle 0x005E, DMI type 13, 22 bytes
BIOS Language Information
	Language Description Format: Abbreviated
	Installable Languages: 1
		enUS
	Currently Installed Language: enUS
```

 Closes #125

Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Oct 14, 2024
1 parent d0d7ea1 commit abde94e
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pkg/facter/smbios.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Smbios struct {
HardwareSecurity []hwinfo.Smbios `json:"hardware_security,omitempty"`

// Language contains language-related information, including supported and current languages.
Language *hwinfo.SmbiosLanguage `json:"language,omitempty"`
Language []hwinfo.Smbios `json:"language,omitempty"`

// Memory64Error provides information on 64-bit memory errors.
Memory64Error []hwinfo.Smbios `json:"memory_64_error,omitempty"`
Expand Down Expand Up @@ -114,13 +114,7 @@ func (s *Smbios) add(item hwinfo.Smbios) error {
case hwinfo.SmbiosTypeHardwareSecurity:
s.GroupAssociations = append(s.GroupAssociations, item)
case hwinfo.SmbiosTypeLanguage:
if s.Language != nil {
return fmt.Errorf("language field is already set")
} else if language, ok := item.(hwinfo.SmbiosLanguage); !ok {
return fmt.Errorf("expected hwinfo.SmbiosLanguage, found %T", item)
} else {
s.Language = &language
}
s.Language = append(s.Language, item)
case hwinfo.SmbiosTypeMemory64Error:
s.Memory64Error = append(s.Memory64Error, item)
case hwinfo.SmbiosTypeMemoryArray:
Expand Down

0 comments on commit abde94e

Please sign in to comment.