feat: flag Ubuntu phased updates on PackageUpdate

This commit is contained in:
2026-09-15 14:48:16 +00:00
parent aa1c87037b
commit 0e5597fcc0
3 changed files with 28 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
package pb
import (
"encoding/json"
"strings"
"testing"
)
// A phased update is flagged on the wire; an ordinary one carries no field at
// all, so an old server or agent sees exactly the shape it always did.
func TestPackageUpdatePhasedOnWire(t *testing.T) {
b, err := json.Marshal(PackageUpdate{Name: "libkrb5-3", NewVersion: "1.20", Phased: true})
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(b), `"phased":true`) {
t.Fatalf("phased missing: %s", b)
}
b, _ = json.Marshal(PackageUpdate{Name: "curl", NewVersion: "8"})
if strings.Contains(string(b), "phased") {
t.Fatalf("an ordinary update must not carry phased: %s", b)
}
}
+4
View File
@@ -85,6 +85,10 @@ type PackageUpdate struct {
Name string `json:"name"`
CurrentVersion string `json:"current_version,omitempty"`
NewVersion string `json:"new_version"`
// Phased marks an Ubuntu phased update this host is not yet selected for:
// apt lists it as upgradable, but an upgrade defers it until the host's
// phase comes up. It is pending, not installable, so counts leave it out.
Phased bool `json:"phased,omitempty"`
}
type ReportUpdatesRequest struct {
+1
View File
@@ -127,6 +127,7 @@ message PackageUpdate {
string name = 1;
string current_version = 2;
string new_version = 3;
bool phased = 4; // Ubuntu phased update this host is not yet selected for; deferred by apt
}
message ReportUpdatesRequest {