From 88b3cf03ddbeb50ab96a0fc687b9ec53e3db4b85 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Tue, 28 Jul 2026 11:15:45 +0200 Subject: [PATCH] gofmt: normalize internal/localapi (whitespace only) Swept up by gofmt -w on the package while adding the guest-power observable. No semantic change; 3 of 5 files are tests. --- internal/localapi/backup_tiers_test.go | 9 +++++---- internal/localapi/disks_candidates_test.go | 4 ++-- internal/localapi/guestmemory.go | 6 +++--- internal/localapi/netstorage.go | 12 ++++++------ internal/localapi/netverifyjob_test.go | 4 ++-- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/internal/localapi/backup_tiers_test.go b/internal/localapi/backup_tiers_test.go index f375079..ec92e41 100644 --- a/internal/localapi/backup_tiers_test.go +++ b/internal/localapi/backup_tiers_test.go @@ -28,7 +28,7 @@ func tieredServer(t *testing.T, st *fakeStore, localSvc, pbsSvc *fakeBackups) *S ListenAddr: "127.0.0.1:0", Guests: &fakeGuests{}, Backups: localSvc, - Store: st, + Store: st, // Both tier targets must be PRESENT in the storage view: since v0.102.0 a tier whose target // storage is absent DEFERS. A real box has both; a fake with no targets would silently // defer every tier and make these assertions vacuous. @@ -260,7 +260,7 @@ func TestBackupTiers_AdvertisesPrimaryFirst(t *testing.T) { if !resp.Data.Tiers[0].Primary || resp.Data.Tiers[0].Target != "local" { t.Fatalf("primary must be first and flagged; got %+v", resp.Data.Tiers) } - if resp.Data.Tiers[1].Target != "felhom-pbs" || resp.Data.Tiers[1].CadenceSeconds != int64((7 * 24 * time.Hour).Seconds()) { + if resp.Data.Tiers[1].Target != "felhom-pbs" || resp.Data.Tiers[1].CadenceSeconds != int64((7*24*time.Hour).Seconds()) { t.Fatalf("PBS tier mis-advertised: %+v", resp.Data.Tiers[1]) } } @@ -601,7 +601,8 @@ func dueFor(t *testing.T, h http.Handler, target string) BackupDueResponse { // COMPANION RED-PROOF (observed): delete the newestArchiveOn fold-in from handleBackupDue (the // pre-R-84 shape, in-memory only) → this fails with // "a restart must NOT make the tier due when the storage holds a 2h-old backup; -// got {... Due:true Reason:no successful backup recorded yet ...}". Restored. +// +// got {... Due:true Reason:no successful backup recorded yet ...}". Restored. func TestBackupDue_ColdStore_UsesStorageGroundTruth(t *testing.T) { h := listerServer(t, &fakeStore{}, archiveLister{ fakeBackups: &fakeBackups{}, at: testNow.Add(-2 * time.Hour), found: true, @@ -610,7 +611,7 @@ func TestBackupDue_ColdStore_UsesStorageGroundTruth(t *testing.T) { if got.Due { t.Fatalf("a restart must NOT make the tier due when the storage holds a 2h-old backup; got %+v", got) } - if got.AgeSecs == nil || *got.AgeSecs != int64((2 * time.Hour).Seconds()) { + if got.AgeSecs == nil || *got.AgeSecs != int64((2*time.Hour).Seconds()) { t.Fatalf("the age must come from the storage; got %+v", got) } } diff --git a/internal/localapi/disks_candidates_test.go b/internal/localapi/disks_candidates_test.go index 17bf238..f7d9319 100644 --- a/internal/localapi/disks_candidates_test.go +++ b/internal/localapi/disks_candidates_test.go @@ -11,9 +11,9 @@ import ( // handleDiskCandidates splits discovery into initialize (all unclaimed) + attach (mountable-FS subset). func TestDiskCandidates_Split(t *testing.T) { d := &fakeDiskOps{candidates: []storage.CandidateDisk{ - {Device: "/dev/sdd", SizeBytes: 64 << 30, DataBearing: false}, // blank → initialize only + {Device: "/dev/sdd", SizeBytes: 64 << 30, DataBearing: false}, // blank → initialize only {Device: "/dev/sde", FSType: "ext4", DataBearing: true, Mountable: true, MountSource: "/dev/sde1"}, // FS → init + attach - {Device: "/dev/sdf", FSType: "ntfs", DataBearing: true, Mountable: false}, // ntfs → initialize only + {Device: "/dev/sdf", FSType: "ntfs", DataBearing: true, Mountable: false}, // ntfs → initialize only }} h := newDiskServer(t, d, &fakeGate{}, nil, nil) diff --git a/internal/localapi/guestmemory.go b/internal/localapi/guestmemory.go index a5602d9..a511d0f 100644 --- a/internal/localapi/guestmemory.go +++ b/internal/localapi/guestmemory.go @@ -134,9 +134,9 @@ func (s *Server) readMemoryBounds(ctx context.Context, vmid int) (memoryBounds, return memoryBounds{}, fmt.Errorf("node status: %w", err) } b := memoryBounds{ - allocatedMB: cfg.Memory, // PVE config memory is already MB - usageMB: bytesToMBUp(st.Mem), // bytes → MB, rounded up - hostTotalMB: node.Memory.Total / mib, // bytes → MB, floor (conservative for max) + allocatedMB: cfg.Memory, // PVE config memory is already MB + usageMB: bytesToMBUp(st.Mem), // bytes → MB, rounded up + hostTotalMB: node.Memory.Total / mib, // bytes → MB, floor (conservative for max) minMB: minGuestMemoryMB, running: st.Status == "running", } diff --git a/internal/localapi/netstorage.go b/internal/localapi/netstorage.go index ca84a1d..c098207 100644 --- a/internal/localapi/netstorage.go +++ b/internal/localapi/netstorage.go @@ -41,12 +41,12 @@ type netStorageAddRequest struct { Name string `json:"name"` Protocol string `json:"protocol"` // "nfs" | "smb" Server string `json:"server"` - Export string `json:"export"` // NFS export path | SMB share name - MappedUID int `json:"mapped_uid"` // container uid (e.g. 1000) - MappedGID int `json:"mapped_gid"` // container gid - IdleTimeoutSec int `json:"idle_timeout_sec"` // automount idle-unmount window; 0 → default - Username string `json:"username,omitempty"` // SMB only (secret — written to creds file) - Password string `json:"password,omitempty"` // SMB only (secret — written to creds file) + Export string `json:"export"` // NFS export path | SMB share name + MappedUID int `json:"mapped_uid"` // container uid (e.g. 1000) + MappedGID int `json:"mapped_gid"` // container gid + IdleTimeoutSec int `json:"idle_timeout_sec"` // automount idle-unmount window; 0 → default + Username string `json:"username,omitempty"` // SMB only (secret — written to creds file) + Password string `json:"password,omitempty"` // SMB only (secret — written to creds file) } // handleNetStorageAdd installs a NAS share host-side — verify-before-commit (SPIKE-nas-verify). diff --git a/internal/localapi/netverifyjob_test.go b/internal/localapi/netverifyjob_test.go index b28b133..c3cc71b 100644 --- a/internal/localapi/netverifyjob_test.go +++ b/internal/localapi/netverifyjob_test.go @@ -148,8 +148,8 @@ func TestNetVerify_TruthTable(t *testing.T) { t.Run("ReadDir ok but NOT mounted = FAILED (empty-dir false positive guard)", func(t *testing.T) { n := &fakeNetOps{} srv := newVerifyServer(t, n, t.TempDir(), verifySeams{ - trigger: func(string) error { return nil }, // the read "worked" (empty dir) - mounted: func(string) bool { return false }, // …but no nfs4/cifs in /proc/mounts + trigger: func(string) error { return nil }, // the read "worked" (empty dir) + mounted: func(string) bool { return false }, // …but no nfs4/cifs in /proc/mounts journal: func(context.Context, string) (string, error) { return "", nil }, }) h := srv.Handler()