Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <brian@bmcgee.ie>
  • Loading branch information
brianmcgee committed Aug 9, 2024
1 parent 8b14ea8 commit f93b44c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 63 deletions.
1 change: 0 additions & 1 deletion nix/packages/nixos-facter/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
args @ {
flake,
inputs,
perSystem,
system,
pkgs,
Expand Down
14 changes: 7 additions & 7 deletions pkg/hwinfo/detail_cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type DetailCpu struct {
Stepping uint `json:"stepping"`
Cache uint `json:"cache"`
// This field changes as the CPU up/down scales, so we do not export it
Clock uint `json:"-"`
Clock uint `json:"-"`
Units uint `json:"units"`
VendorName string `json:"vendor_name"`
ModelName string `json:"model_name"`
Expand All @@ -65,12 +65,12 @@ func NewDetailCpu(cpu C.hd_detail_cpu_t) (Detail, error) {
Stepping: uint(data.stepping),
Cache: uint(data.cache),
Clock: uint(data.clock),
Units: uint(data.units),
VendorName: C.GoString(data.vend_name),
ModelName: stripCpuFreq(C.GoString(data.model_name)),
Platform: C.GoString(data.platform),
Features: ReadStringList(data.features),
Bogo: float64(data.bogo),
Units: uint(data.units),
VendorName: C.GoString(data.vend_name),
ModelName: stripCpuFreq(C.GoString(data.model_name)),
Platform: C.GoString(data.platform),
Features: ReadStringList(data.features),
Bogo: float64(data.bogo),
}, nil
}

Expand Down
57 changes: 30 additions & 27 deletions pkg/hwinfo/detail_pci.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ package hwinfo
#include <hd.h>
*/
import "C"
import "encoding/hex"
import "unsafe"

import (
"encoding/hex"
"unsafe"
)

//go:generate enumer -type=PciFlag -json -transform=snake -trimprefix PciFlag -output=./detail_enum_pci_flag.go
type PciFlag uint
Expand Down Expand Up @@ -86,36 +89,36 @@ func NewDetailPci(pci C.hd_detail_pci_t) (Detail, error) {
data := pci.data

return DetailPci{
Type: DetailTypePci,
Data: hex.EncodeToString(C.GoBytes(unsafe.Pointer(&data.data), 256)),
DataLength: uint(data.data_len),
DataExtLength: uint(data.data_ext_len),
Log: C.GoString(data.log),
Flags: ParsePciFlags(uint(data.flags)),
Command: uint(data.cmd),
HeaderType: uint(data.hdr_type),
SecondaryBus: uint(data.secondary_bus),
Bus: uint(data.bus),
Slot: uint(data.slot),
Function: uint(data._func),
BaseClass: uint(data.base_class),
SubClass: uint(data.sub_class),
ProgIf: uint(data.prog_if),
Device: uint(data.dev),
Vendor: uint(data.vend),
SubDevice: uint(data.sub_dev),
SubVendor: uint(data.sub_vend),
Revision: uint(data.rev),
Irq: uint(data.irq),
Type: DetailTypePci,
Data: hex.EncodeToString(C.GoBytes(unsafe.Pointer(&data.data), 256)),
DataLength: uint(data.data_len),
DataExtLength: uint(data.data_ext_len),
Log: C.GoString(data.log),
Flags: ParsePciFlags(uint(data.flags)),
Command: uint(data.cmd),
HeaderType: uint(data.hdr_type),
SecondaryBus: uint(data.secondary_bus),
Bus: uint(data.bus),
Slot: uint(data.slot),
Function: uint(data._func),
BaseClass: uint(data.base_class),
SubClass: uint(data.sub_class),
ProgIf: uint(data.prog_if),
Device: uint(data.dev),
Vendor: uint(data.vend),
SubDevice: uint(data.sub_dev),
SubVendor: uint(data.sub_vend),
Revision: uint(data.rev),
Irq: uint(data.irq),
BaseAddress: [7]uint64(ReadUint64Array(unsafe.Pointer(&data.base_addr), 7)),
BaseLength: [7]uint64(ReadUint64Array(unsafe.Pointer(&data.base_len), 7)),
AddressFlags: [7]uint(ReadUintArray(unsafe.Pointer(&data.addr_flags), 7)),
RomBaseAddress: uint64(data.rom_base_addr),
RomBaseLength: uint64(data.rom_base_len),
SysfsId: C.GoString(data.sysfs_id),
SysfsBusId: C.GoString(data.sysfs_bus_id),
ModuleAlias: C.GoString(data.modalias),
Label: C.GoString(data.label),
SysfsId: C.GoString(data.sysfs_id),
SysfsBusId: C.GoString(data.sysfs_bus_id),
ModuleAlias: C.GoString(data.modalias),
Label: C.GoString(data.label),
// todo edid data
}, nil
}
55 changes: 27 additions & 28 deletions pkg/hwinfo/virtual_network_devices.go
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
package hwinfo

// original list taken from systemd.network
var virtualNetworkDevices = map[string]bool {
"bonding": true,
"bridge": true,
"dummy": true,
"ip_gre": true,
"ip6_gre": true,
"ipip": true,
"ipvlan": true,
"macvlan": true,
"sit": true,
"tun": true,
"veth": true,
"8021q": true,
"ip_vti": true,
"ip6_vti": true,
"vxlan": true,
"geneve": true,
"macsec": true,
"vrf": true,
"vcan": true,
"vxcan": true,
"wireguard": true,
"nlmon": true,
"fou": true,
"ifb": true,
"bareudp": true,
var virtualNetworkDevices = map[string]bool{
"bonding": true,
"bridge": true,
"dummy": true,
"ip_gre": true,
"ip6_gre": true,
"ipip": true,
"ipvlan": true,
"macvlan": true,
"sit": true,
"tun": true,
"veth": true,
"8021q": true,
"ip_vti": true,
"ip6_vti": true,
"vxlan": true,
"geneve": true,
"macsec": true,
"vrf": true,
"vcan": true,
"vxcan": true,
"wireguard": true,
"nlmon": true,
"fou": true,
"ifb": true,
"bareudp": true,
"batman-adv": true,
"ib_ipoib": true,
"ib_ipoib": true,
// FIXME: could not confirm the following netdev drivers:
// "l2tp": true,
// "xfrm": true,
// "erspan": true,
// "ip6tnl": true,
}

0 comments on commit f93b44c

Please sign in to comment.