A (hardware-ingest-json v2.8-2.9): remove sensor location fields from schema and collector; tag HardwareMemory.Location as json:"-"; add PlatformConfig to HardwareSnapshot. B (no-hardcoded-vendors): consolidate PCI vendor IDs into collector/pci_vendors.go; replace all vendor-name string checks in isGPUDevice, isNVIDIADevice, isMellanoxDevice, isAMDGPUDevice, matchesGPUVendor (sat_overlay), and validateIsVendorGPU (page_validate) with numeric vendor_id comparisons. C (module-structure): split app/app.go (1413 lines) into app.go + app_format.go, app_network.go, app_services.go, app_packs.go, app_install.go — no logic changes. D (go-code-style): wrap bare return err in interfaceAdminState and interfaceIPv4Addrs (platform/network.go) with fmt.Errorf context including the interface name. E (go-project-bible): add bible-local/architecture/data-model.md and bible-local/architecture/api-surface.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
77 lines
2.2 KiB
Go
77 lines
2.2 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"bee/audit/internal/platform"
|
|
)
|
|
|
|
func (a *App) ListRemovableTargets() ([]platform.RemovableTarget, error) {
|
|
return a.exports.ListRemovableTargets()
|
|
}
|
|
|
|
func (a *App) ExportLatestAudit(target platform.RemovableTarget) (string, error) {
|
|
if _, err := os.Stat(DefaultAuditJSONPath); err != nil {
|
|
return "", err
|
|
}
|
|
filename := fmt.Sprintf("audit-%s-%s.json", sanitizeFilename(hostnameOr("unknown")), time.Now().UTC().Format("20060102-150405"))
|
|
tmpPath := filepath.Join(os.TempDir(), filename)
|
|
data, err := readFileLimited(DefaultAuditJSONPath, 100<<20)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if normalized, normErr := ApplySATOverlay(data); normErr == nil {
|
|
data = normalized
|
|
}
|
|
if err := os.WriteFile(tmpPath, data, 0644); err != nil {
|
|
return "", err
|
|
}
|
|
defer os.Remove(tmpPath)
|
|
return a.exports.ExportFileToTarget(tmpPath, target)
|
|
}
|
|
|
|
func (a *App) ExportLatestAuditResult(target platform.RemovableTarget) (ActionResult, error) {
|
|
path, err := a.ExportLatestAudit(target)
|
|
body := "Audit export failed."
|
|
if err == nil {
|
|
body = "Audit exported."
|
|
}
|
|
if err == nil && path != "" {
|
|
body = "Audit exported to " + path
|
|
}
|
|
return ActionResult{Title: "Export audit", Body: body}, err
|
|
}
|
|
|
|
func (a *App) ExportSupportBundle(target platform.RemovableTarget) (string, error) {
|
|
archive, err := BuildSupportBundle(DefaultExportDir)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
defer os.Remove(archive)
|
|
return a.exports.ExportFileToTarget(archive, target)
|
|
}
|
|
|
|
func (a *App) ExportSupportBundleResult(target platform.RemovableTarget) (ActionResult, error) {
|
|
path, err := a.ExportSupportBundle(target)
|
|
body := "Support bundle export failed."
|
|
if err == nil {
|
|
body = "Support bundle exported. USB target unmounted and safe to remove."
|
|
}
|
|
if err == nil && path != "" {
|
|
body = "Support bundle exported to " + path + ".\n\nUSB target unmounted and safe to remove."
|
|
}
|
|
return ActionResult{Title: "Export support bundle", Body: body}, err
|
|
}
|
|
|
|
func (a *App) ListInstallDisks() ([]platform.InstallDisk, error) {
|
|
return a.installer.ListInstallDisks()
|
|
}
|
|
|
|
func (a *App) InstallToDisk(ctx context.Context, device string, logFile string) error {
|
|
return a.installer.InstallToDisk(ctx, device, logFile)
|
|
}
|