From ce8d52ed0bf79f222a316716098f785ddab5f170 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 22 Oct 2026 10:27:01 +0200 Subject: [PATCH] Let gitea read the image build module's keys, so its key is the builders' (issue 1703f) --- modules/gitea/cmd/forge-account-provider/builder_test.go | 4 ++-- modules/gitea/cmd/forge-account-provider/watch_test.go | 4 ++-- modules/gitea/internal/forgeaccount/account.go | 2 +- modules/gitea/internal/forgeaccount/builder_test.go | 2 +- modules/gitea/module.json | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/gitea/cmd/forge-account-provider/builder_test.go b/modules/gitea/cmd/forge-account-provider/builder_test.go index 9bfd0408..f325acd7 100644 --- a/modules/gitea/cmd/forge-account-provider/builder_test.go +++ b/modules/gitea/cmd/forge-account-provider/builder_test.go @@ -179,7 +179,7 @@ func newTeamRig(t *testing.T) *teamRig { svc := NewService(Config{Node: "novox", HostFile: host, OriginsFile: origins, Port: 222, Forge: forgehttp.Client{URL: srv.URL, User: "mesh-admin", PasswordFile: pw}, Runner: runner, Log: func(string, ...any) {}}) svc.loaded = true - svc.loadedFrom["mesh-build-go"], svc.loadedFrom["mesh-build-node"] = true, true + svc.loadedFrom["mesh-build-go"], svc.loadedFrom["mesh-build-node"], svc.loadedFrom["mesh-build-image"] = true, true, true return &teamRig{t: t, bus: newBus(), forge: forge, svc: svc, runner: runner} } @@ -347,7 +347,7 @@ func TestABuildModulesEntryWaitsForItsOwnBuilderKey(t *testing.T) { } func TestTheKindOfAModulesKeyAndItsForgeUser(t *testing.T) { - for module, want := range map[string]string{"mesh-build-go": "nox-builder", "mesh-build-node": "nox-builder", "ssh-client": "nox-agent", "anything-else": "nox-agent"} { + for module, want := range map[string]string{"mesh-build-go": "nox-builder", "mesh-build-node": "nox-builder", "mesh-build-image": "nox-builder", "ssh-client": "nox-agent", "anything-else": "nox-agent"} { got, err := (&Service{}).valuesForUser("ace", module) if err != nil || got != want { t.Errorf("%s: %q, %v; want %q", module, got, err, want) diff --git a/modules/gitea/cmd/forge-account-provider/watch_test.go b/modules/gitea/cmd/forge-account-provider/watch_test.go index e8986788..2fb60b97 100644 --- a/modules/gitea/cmd/forge-account-provider/watch_test.go +++ b/modules/gitea/cmd/forge-account-provider/watch_test.go @@ -38,7 +38,7 @@ func newWatched(t *testing.T) *watched { r.svc.OnKeys = func(string) { n++ } r.svc.cfg.Log = func(f string, a ...any) { mu.Lock(); logs = append(logs, fmt.Sprintf(f, a...)); mu.Unlock() } w := &watched{teamRig: r, sources: map[string]*fakeKeys{}, passes: &n, logs: &logs, mu: mu} - for _, module := range []string{"ssh-client", "mesh-build-go", "mesh-build-node"} { + for _, module := range []string{"ssh-client", "mesh-build-go", "mesh-build-node", "mesh-build-image"} { w.sources[module] = &fakeKeys{} if err := r.svc.WatchSource(context.Background(), module, w.sources[module]); err != nil { t.Fatal(err) @@ -154,7 +154,7 @@ func TestTheManifestReadsTheBuildModulesKeys(t *testing.T) { if err := json.Unmarshal(raw, &m); err != nil { t.Fatal(err) } - for _, state := range []string{"mesh-controller.assignments", "ssh-client.keys", "mesh-build-go.keys", "mesh-build-node.keys"} { + for _, state := range []string{"mesh-controller.assignments", "ssh-client.keys", "mesh-build-go.keys", "mesh-build-node.keys", "mesh-build-image.keys"} { if !slices.Contains(m.Reads, state) { t.Errorf("gitea's reads %v lack %q", m.Reads, state) } diff --git a/modules/gitea/internal/forgeaccount/account.go b/modules/gitea/internal/forgeaccount/account.go index 8fe9a721..6a23d3e6 100644 --- a/modules/gitea/internal/forgeaccount/account.go +++ b/modules/gitea/internal/forgeaccount/account.go @@ -195,7 +195,7 @@ const BuilderUser = "nox-builder" // BuildModules are the modules whose keys are the builders' (kind builder), by their name, which is also the name of // the account each runs as (ADR 0466 ยง1). -var BuildModules = []string{"mesh-build-go", "mesh-build-node"} +var BuildModules = []string{"mesh-build-go", "mesh-build-node", "mesh-build-image"} // KindOfModule is the kind of key a consumer module's entry is made for: builder for a build module, machine for any // other (ssh-client's). diff --git a/modules/gitea/internal/forgeaccount/builder_test.go b/modules/gitea/internal/forgeaccount/builder_test.go index fb920dfd..50cf0634 100644 --- a/modules/gitea/internal/forgeaccount/builder_test.go +++ b/modules/gitea/internal/forgeaccount/builder_test.go @@ -12,7 +12,7 @@ func TestTheBuildModulesHaveOneForgeUserAndTheMachinesKeepTheirs(t *testing.T) { if ForgeUser("Not A Node", "builder") != "" { t.Errorf("a name no account could be named for got a user") } - for module, want := range map[string]string{"mesh-build-go": "builder", "mesh-build-node": "builder", "ssh-client": "machine", "": "machine"} { + for module, want := range map[string]string{"mesh-build-go": "builder", "mesh-build-node": "builder", "mesh-build-image": "builder", "ssh-client": "machine", "": "machine"} { if got := KindOfModule(module); got != want { t.Errorf("KindOfModule(%q) = %s, want %s", module, got, want) } diff --git a/modules/gitea/module.json b/modules/gitea/module.json index 118224cd..10ad38ce 100644 --- a/modules/gitea/module.json +++ b/modules/gitea/module.json @@ -542,6 +542,7 @@ "mesh-controller.assignments", "ssh-client.keys", "mesh-build-go.keys", - "mesh-build-node.keys" + "mesh-build-node.keys", + "mesh-build-image.keys" ] }