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.
This commit is contained in:
2026-07-28 11:15:45 +02:00
parent f27f7a2659
commit 88b3cf03dd
5 changed files with 18 additions and 17 deletions
+5 -4
View File
@@ -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)
}
}
+2 -2
View File
@@ -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)
+3 -3
View File
@@ -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",
}
+6 -6
View File
@@ -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).
+2 -2
View File
@@ -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()