From 4f45409697dbf7efc529fb97e9d3642c4deaf205 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Fri, 19 Jun 2026 09:58:06 +0200 Subject: [PATCH] Seed defaultComponents in bootstrap signing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `resetCmdArgs` in `main_test.go` rebuilds `bootstrapArgs` from `NewBootstrapFlags`, which deliberately omits the cobra-populated `defaultComponents`. In the `e2e` build, `TestMain` runs `flux install …` before any test executes; that call triggers the reset and leaves `bootstrapArgs.defaultComponents` empty for the lifetime of the process. `bootstrapValidate` then trips on its `requiredComponents` pre-check and fails with "component source-controller is required" before it ever reaches the SSH/GPG signing flag validation that this test cares about. Save, seed, and restore `defaultComponents` per subtest so the required-component check passes regardless of whether the test runs under the plain or the `e2e` build tag. Assisted-by: claude/opus-4.7 Signed-off-by: Hidde Beydals --- cmd/flux/bootstrap_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/flux/bootstrap_test.go b/cmd/flux/bootstrap_test.go index 8686d3e8..95b4e172 100644 --- a/cmd/flux/bootstrap_test.go +++ b/cmd/flux/bootstrap_test.go @@ -112,6 +112,7 @@ func TestBootstrapValidate_signingFlags(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + savedDefaultComponents := bootstrapArgs.defaultComponents savedGpgRing := bootstrapArgs.gpgKeyRingPath savedGpgPass := bootstrapArgs.gpgPassphrase savedSshKey := bootstrapArgs.sshSigningKeyFile @@ -120,6 +121,7 @@ func TestBootstrapValidate_signingFlags(t *testing.T) { savedPrivKey := bootstrapArgs.privateKeyFile savedReuse := bootstrapArgs.sshSigningReusePrivateKey defer func() { + bootstrapArgs.defaultComponents = savedDefaultComponents bootstrapArgs.gpgKeyRingPath = savedGpgRing bootstrapArgs.gpgPassphrase = savedGpgPass bootstrapArgs.sshSigningKeyFile = savedSshKey @@ -129,6 +131,10 @@ func TestBootstrapValidate_signingFlags(t *testing.T) { bootstrapArgs.sshSigningReusePrivateKey = savedReuse }() + // The e2e TestMain calls resetCmdArgs which clears the + // cobra-populated default components, so seed them here to + // satisfy the requiredComponents pre-check in bootstrapValidate. + bootstrapArgs.defaultComponents = bootstrapArgs.requiredComponents bootstrapArgs.gpgKeyRingPath = tt.gpgRing bootstrapArgs.gpgPassphrase = tt.gpgPass bootstrapArgs.sshSigningKeyFile = tt.sshKey