Skip to content

Commit e75f724

Browse files
committed
merge conflicts
1 parent 90b0a17 commit e75f724

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

pkg/cmd/register/hardware.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ func FormatHardwareProfile(s *HardwareProfile) string {
6666
if s.RAMBytes != nil {
6767
_, _ = fmt.Fprintf(&b, " RAM: %.1f GB\n", float64(*s.RAMBytes)/(1024*1024*1024))
6868
}
69-
parseGPUs(s, b)
69+
parseGPUs(s, &b)
7070
_, _ = fmt.Fprintf(&b, " Arch: %s\n", s.Architecture)
7171
if s.OS != "" || s.OSVersion != "" {
7272
_, _ = fmt.Fprintf(&b, " OS: %s %s\n", s.OS, s.OSVersion)
7373
}
74-
parseInterconnects(s, b)
74+
parseInterconnects(s, &b)
7575
for _, st := range s.Storage {
7676
_, _ = fmt.Fprintf(&b, " Storage: %.1f GB", float64(st.StorageBytes)/(1024*1024*1024))
7777
if st.StorageType != "" {
@@ -85,37 +85,37 @@ func FormatHardwareProfile(s *HardwareProfile) string {
8585
return b.String()
8686
}
8787

88-
func parseGPUs(s *HardwareProfile, b strings.Builder) {
88+
func parseGPUs(s *HardwareProfile, b *strings.Builder) {
8989
for _, gpu := range s.GPUs {
9090
if gpu.MemoryBytes != nil {
9191
memGB := float64(*gpu.MemoryBytes) / (1024 * 1024 * 1024)
92-
_, _ = fmt.Fprintf(&b, " GPUs: %d x %s (%.1f GB)", gpu.Count, gpu.Model, memGB)
92+
_, _ = fmt.Fprintf(b, " GPUs: %d x %s (%.1f GB)", gpu.Count, gpu.Model, memGB)
9393
} else {
94-
_, _ = fmt.Fprintf(&b, " GPUs: %d x %s", gpu.Count, gpu.Model)
94+
_, _ = fmt.Fprintf(b, " GPUs: %d x %s", gpu.Count, gpu.Model)
9595
}
9696
if gpu.Architecture != "" {
97-
_, _ = fmt.Fprintf(&b, " [%s]", gpu.Architecture)
97+
_, _ = fmt.Fprintf(b, " [%s]", gpu.Architecture)
9898
}
9999
b.WriteString("\n")
100100
}
101101
}
102102

103-
func parseInterconnects(s *HardwareProfile, b strings.Builder) {
103+
func parseInterconnects(s *HardwareProfile, b *strings.Builder) {
104104
for _, ic := range s.Interconnects {
105-
_, _ = fmt.Fprintf(&b, " Link: %s", ic.Type)
105+
_, _ = fmt.Fprintf(b, " Link: %s", ic.Type)
106106
if ic.Generation > 0 || ic.Width > 0 {
107107
if ic.Generation > 0 {
108-
_, _ = fmt.Fprintf(&b, " Gen%d", ic.Generation)
108+
_, _ = fmt.Fprintf(b, " Gen%d", ic.Generation)
109109
}
110110
if ic.Width > 0 {
111-
_, _ = fmt.Fprintf(&b, " x%d", ic.Width)
111+
_, _ = fmt.Fprintf(b, " x%d", ic.Width)
112112
}
113113
}
114114
if ic.Device != "" {
115-
_, _ = fmt.Fprintf(&b, " (%s)", ic.Device)
115+
_, _ = fmt.Fprintf(b, " (%s)", ic.Device)
116116
}
117117
if ic.ActiveLinks > 0 {
118-
_, _ = fmt.Fprintf(&b, " x%d", ic.ActiveLinks)
118+
_, _ = fmt.Fprintf(b, " x%d", ic.ActiveLinks)
119119
}
120120
b.WriteString("\n")
121121
}

pkg/cmd/register/hardware_darwin.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,23 @@ func isWholeDisk(name string) bool {
136136
}
137137

138138
func parseDiskutilSize(val string, dev *StorageDevice) {
139+
// Prefer the parenthesized "(N Bytes)" form — most reliable.
139140
if m := diskutilBytesRe.FindStringSubmatch(val); len(m) == 2 {
140141
cleaned := strings.ReplaceAll(m[1], ",", "")
141142
if size, err := strconv.ParseInt(cleaned, 10, 64); err == nil {
142143
dev.StorageBytes = size
144+
return
143145
}
144146
}
145-
// If the regex doesn't match, leave StorageBytes as 0 (unknown).
147+
// Fallback: try parsing the first whitespace-delimited token as a
148+
// plain integer (handles "500107862016 Bytes ..." without parens).
149+
parts := strings.Fields(val)
150+
if len(parts) >= 1 {
151+
if size, err := strconv.ParseInt(parts[0], 10, 64); err == nil {
152+
dev.StorageBytes = size
153+
}
154+
}
155+
// If neither matches, leave StorageBytes as 0 (unknown).
146156
}
147157

148158
func parseDiskutilSolidState(val string, dev *StorageDevice) {

pkg/cmd/register/register_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ func Test_runRegister_PlatformIncompatible(t *testing.T) {
788788
deps.platform = mockPlatform{compatible: false}
789789

790790
term := terminal.New()
791-
err := runRegister(context.Background(), term, store, "My-Spark","TestOrg", deps)
791+
err := runRegister(context.Background(), term, store, "my-spark", "", deps)
792792
if err == nil {
793793
t.Fatal("expected error when platform is incompatible")
794794
}
@@ -813,7 +813,7 @@ func Test_runRegister_HardwareProfilerFailure(t *testing.T) {
813813
deps.hardwareProfiler = &mockHardwareProfiler{err: fmt.Errorf("nvml init failed")}
814814

815815
term := terminal.New()
816-
err := runRegister(context.Background(), term, store, "My Spark", "TestOrg",deps)
816+
err := runRegister(context.Background(), term, store, "my-spark", "", deps)
817817
if err == nil {
818818
t.Fatal("expected error when hardware profiler fails")
819819
}
@@ -838,7 +838,7 @@ func Test_runRegister_NetBirdInstallFailure(t *testing.T) {
838838
deps.netbird = mockNetBirdManager{err: fmt.Errorf("install failed")}
839839

840840
term := terminal.New()
841-
err := runRegister(context.Background(), term, store, "My Spark", "TestOrg", deps)
841+
err := runRegister(context.Background(), term, store, "my-spark", "", deps)
842842
if err == nil {
843843
t.Fatal("expected error when NetBird install fails")
844844
}

0 commit comments

Comments
 (0)