chore: go-smbios updates
go-smbios library updates Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
parent
f477eb8820
commit
34d9a875ac
7
go.mod
7
go.mod
@ -52,6 +52,7 @@ require (
|
||||
github.com/gdamore/tcell/v2 v2.5.1
|
||||
github.com/gizak/termui/v3 v3.1.0
|
||||
github.com/godbus/dbus/v5 v5.1.0
|
||||
github.com/golang/mock v1.6.0
|
||||
github.com/google/go-cmp v0.5.8
|
||||
github.com/google/nftables v0.0.0-20220515211605-06687b6e34eb
|
||||
github.com/google/uuid v1.3.0
|
||||
@ -81,6 +82,7 @@ require (
|
||||
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
|
||||
github.com/rs/xid v1.4.0
|
||||
github.com/ryanuber/columnize v2.1.2+incompatible
|
||||
github.com/ryanuber/go-glob v1.0.0
|
||||
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9
|
||||
github.com/siderolabs/go-pointer v1.0.0
|
||||
github.com/spf13/cobra v1.4.0
|
||||
@ -96,7 +98,7 @@ require (
|
||||
github.com/talos-systems/go-loadbalancer v0.1.1
|
||||
github.com/talos-systems/go-procfs v0.1.0
|
||||
github.com/talos-systems/go-retry v0.3.1
|
||||
github.com/talos-systems/go-smbios v0.1.1
|
||||
github.com/talos-systems/go-smbios v0.2.0
|
||||
github.com/talos-systems/grpc-proxy v0.3.0
|
||||
github.com/talos-systems/net v0.3.2
|
||||
github.com/talos-systems/siderolink v0.1.0
|
||||
@ -178,7 +180,6 @@ require (
|
||||
github.com/gogo/googleapis v1.4.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/btree v1.0.1 // indirect
|
||||
github.com/google/gnostic v0.5.7-v3refs // indirect
|
||||
@ -240,7 +241,6 @@ require (
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/russross/blackfriday v1.5.2 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/ryanuber/go-glob v1.0.0 // indirect
|
||||
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
|
||||
github.com/sethgrid/pester v0.0.0-20190127155807-68a33a018ad0 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
@ -248,7 +248,6 @@ require (
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/viper v1.10.0 // indirect
|
||||
github.com/stretchr/objx v0.2.0 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
|
||||
github.com/ulikunitz/xz v0.5.8 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -1148,8 +1148,8 @@ github.com/talos-systems/go-retry v0.1.0/go.mod h1:HiXQqyVStZ35uSY/MTLWVvQVmC3lI
|
||||
github.com/talos-systems/go-retry v0.1.1-0.20201113203059-8c63d290a688/go.mod h1:HiXQqyVStZ35uSY/MTLWVvQVmC3lIW2MS5VdDaMtoKM=
|
||||
github.com/talos-systems/go-retry v0.3.1 h1:GjjyHB8i1CJpb1O5qYPMljq74cRQ5uiDoyMaWddA5FA=
|
||||
github.com/talos-systems/go-retry v0.3.1/go.mod h1:HiXQqyVStZ35uSY/MTLWVvQVmC3lIW2MS5VdDaMtoKM=
|
||||
github.com/talos-systems/go-smbios v0.1.1 h1:Au6obB/Pp0i0JHhvPlzONk5aoNseosO2BUsmvWWi7y8=
|
||||
github.com/talos-systems/go-smbios v0.1.1/go.mod h1:vk76naUSZaWE8Z95wbDn51FgH0goECM4oK3KY2hYSMU=
|
||||
github.com/talos-systems/go-smbios v0.2.0 h1:Ga7gLxeOGg7q1V7dtGzzC6EbSxm/vyi0EBKinbtJ6x4=
|
||||
github.com/talos-systems/go-smbios v0.2.0/go.mod h1:vk76naUSZaWE8Z95wbDn51FgH0goECM4oK3KY2hYSMU=
|
||||
github.com/talos-systems/grpc-proxy v0.3.0 h1:pM4P6GqzjmZzq6jAxeP2mzjuTbx9B2E5peVdi2bufM4=
|
||||
github.com/talos-systems/grpc-proxy v0.3.0/go.mod h1:1TNaCLt0NTdFdz48OCnOM+HbPEIkj3DhCi85+z6zSM8=
|
||||
github.com/talos-systems/net v0.3.2 h1:IMseRyuha8fNsv/3FbQPRE9hLVRBEFR+9sxcoETQ5vI=
|
||||
|
@ -79,10 +79,7 @@ func (ctrl *ManagerController) Run(ctx context.Context, r controller.Runtime, lo
|
||||
return fmt.Errorf("error reading node UUID: %w", err)
|
||||
}
|
||||
|
||||
nodeUUID, err := s.SystemInformation().UUID()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting node UUID: %w", err)
|
||||
}
|
||||
nodeUUID := s.SystemInformation.UUID
|
||||
|
||||
var zeroKey wgtypes.Key
|
||||
|
||||
@ -125,7 +122,7 @@ func (ctrl *ManagerController) Run(ctx context.Context, r controller.Runtime, lo
|
||||
}
|
||||
|
||||
resp, err := sideroLinkClient.Provision(ctx, &pb.ProvisionRequest{
|
||||
NodeUuid: nodeUUID.String(),
|
||||
NodeUuid: nodeUUID,
|
||||
NodePublicKey: ctrl.nodeKey.PublicKey().String(),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/talos-systems/go-blockdevice/blockdevice/filesystem"
|
||||
"github.com/talos-systems/go-blockdevice/blockdevice/probe"
|
||||
"github.com/talos-systems/go-procfs/procfs"
|
||||
@ -65,7 +64,7 @@ func (m *Metal) Configuration(ctx context.Context) ([]byte, error) {
|
||||
}
|
||||
|
||||
// PopulateURLParameters fills in empty parameters in the download URL.
|
||||
func PopulateURLParameters(downloadURL string, getSystemUUID func() (uuid.UUID, error)) (string, error) {
|
||||
func PopulateURLParameters(downloadURL string, getSystemUUID func() (string, error)) (string, error) {
|
||||
u, err := url.Parse(downloadURL)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to parse %s: %w", constants.KernelParamConfig, err)
|
||||
@ -83,7 +82,7 @@ func PopulateURLParameters(downloadURL string, getSystemUUID func() (uuid.UUID,
|
||||
return "", err
|
||||
}
|
||||
|
||||
values.Set("uuid", uid.String())
|
||||
values.Set("uuid", uid)
|
||||
}
|
||||
default:
|
||||
log.Printf("unsupported query parameter: %q", key)
|
||||
@ -95,13 +94,13 @@ func PopulateURLParameters(downloadURL string, getSystemUUID func() (uuid.UUID,
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func getSystemUUID() (uuid.UUID, error) {
|
||||
func getSystemUUID() (string, error) {
|
||||
s, err := smbios.New()
|
||||
if err != nil {
|
||||
return uuid.Nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return s.SystemInformation().UUID()
|
||||
return s.SystemInformation.UUID, nil
|
||||
}
|
||||
|
||||
// Mode implements the platform.Platform interface.
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPopulateURLParameters(t *testing.T) {
|
||||
mockUUID := uuid.New()
|
||||
mockUUID := uuid.New().String()
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
@ -31,7 +31,7 @@ func TestPopulateURLParameters(t *testing.T) {
|
||||
{
|
||||
name: "empty uuid",
|
||||
url: "http://example.com/metadata?uuid=",
|
||||
expectedURL: fmt.Sprintf("http://example.com/metadata?uuid=%s", mockUUID.String()),
|
||||
expectedURL: fmt.Sprintf("http://example.com/metadata?uuid=%s", mockUUID),
|
||||
},
|
||||
{
|
||||
name: "uuid present",
|
||||
@ -46,13 +46,13 @@ func TestPopulateURLParameters(t *testing.T) {
|
||||
{
|
||||
name: "multiple uuids",
|
||||
url: "http://example.com/metadata?uuid=xyz&uuid=foo",
|
||||
expectedURL: fmt.Sprintf("http://example.com/metadata?uuid=%s", mockUUID.String()),
|
||||
expectedURL: fmt.Sprintf("http://example.com/metadata?uuid=%s", mockUUID),
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
output, err := metal.PopulateURLParameters(tt.url, func() (uuid.UUID, error) {
|
||||
output, err := metal.PopulateURLParameters(tt.url, func() (string, error) {
|
||||
return mockUUID, nil
|
||||
})
|
||||
|
||||
|
@ -187,7 +187,7 @@ func (n *Nocloud) acquireConfig(ctx context.Context) (metadataConfigDl, metadata
|
||||
metaBaseURL := ""
|
||||
networkSource := false
|
||||
|
||||
options := strings.Split(s.SystemInformation().SerialNumber(), ";")
|
||||
options := strings.Split(s.SystemInformation.SerialNumber, ";")
|
||||
for _, option := range options {
|
||||
parts := strings.SplitN(option, "=", 2)
|
||||
if len(parts) == 2 {
|
||||
|
@ -7,7 +7,6 @@ package keys
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/talos-systems/go-smbios/smbios"
|
||||
)
|
||||
|
||||
@ -32,25 +31,20 @@ func (h *NodeIDKeyHandler) GetKey(options ...KeyOption) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
machineUUID, err := s.SystemInformation().UUID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
machineUUID := s.SystemInformation.UUID
|
||||
|
||||
if machineUUID == uuid.Nil {
|
||||
if machineUUID == "" {
|
||||
return nil, fmt.Errorf("machine UUID is not populated %s", machineUUID)
|
||||
}
|
||||
|
||||
id := machineUUID.String()
|
||||
|
||||
// primitive entropy check
|
||||
counts := map[rune]int{}
|
||||
for _, s := range id {
|
||||
for _, s := range machineUUID {
|
||||
counts[s]++
|
||||
if counts[s] > len(id)/2 {
|
||||
if counts[s] > len(machineUUID)/2 {
|
||||
return nil, fmt.Errorf("machine UUID %s entropy check failed", machineUUID)
|
||||
}
|
||||
}
|
||||
|
||||
return []byte(id + opts.PartitionLabel), nil
|
||||
return []byte(machineUUID + opts.PartitionLabel), nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user