From 783dca27af2502c07d8c8d29ab63cceb9bbd3010 Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Sun, 12 Jan 2025 22:19:12 -0800 Subject: [PATCH] fix(test env): ensure build user in environment The Test pipeline environment does not get a build user included by default; this causes test pipelines to fail when the qemu runner is used because the initial connection attempt to get the host public key always uses the build user to connect. Fix this by adding the build user to all Test environments, both the primary pipeline and any subpipelines. Fixes: https://github.com/chainguard-dev/melange/issues/1732 Signed-off-by: Steve Beattie --- pkg/config/config.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2748aa5a0..e10447f66 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1358,6 +1358,16 @@ func ParseConfiguration(_ context.Context, configurationFilePath string, opts .. Members: []string{"build"}, } cfg.Environment.Accounts.Groups = append(cfg.Environment.Accounts.Groups, grp) + if cfg.Test != nil { + cfg.Test.Environment.Accounts.Groups = append(cfg.Test.Environment.Accounts.Groups, grp) + } + for i := range cfg.Subpackages { + sub := &cfg.Subpackages[i] + if sub.Test == nil || len(sub.Test.Pipeline) == 0 { + continue + } + sub.Test.Environment.Accounts.Groups = append(sub.Test.Environment.Accounts.Groups, grp) + } gid1000 := uint32(1000) usr := apko_types.User{ @@ -1366,6 +1376,16 @@ func ParseConfiguration(_ context.Context, configurationFilePath string, opts .. GID: apko_types.GID(&gid1000), } cfg.Environment.Accounts.Users = append(cfg.Environment.Accounts.Users, usr) + if cfg.Test != nil { + cfg.Test.Environment.Accounts.Users = append(cfg.Test.Environment.Accounts.Users, usr) + } + for i := range cfg.Subpackages { + sub := &cfg.Subpackages[i] + if sub.Test == nil || len(sub.Test.Pipeline) == 0 { + continue + } + sub.Test.Environment.Accounts.Users = append(sub.Test.Environment.Accounts.Users, usr) + } // Merge environment file if needed. if envFile := options.envFilePath; envFile != "" {