From 5b2f7ea20a799be48bbc12793abc7214ab9451ed Mon Sep 17 00:00:00 2001 From: Russell Centanni Date: Tue, 7 Nov 2023 13:41:51 -0500 Subject: [PATCH] fix: only upload pull secret credentials for kaniko and in cluster buildkit builds Fixes #2729 Fixes ENG-2185 Signed-off-by: Russell Centanni --- pkg/devspace/build/build.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/devspace/build/build.go b/pkg/devspace/build/build.go index 3d0e215da4..1d09f29d91 100644 --- a/pkg/devspace/build/build.go +++ b/pkg/devspace/build/build.go @@ -1,9 +1,10 @@ package build import ( + "strings" + dockerclient "github.com/loft-sh/devspace/pkg/devspace/docker" "github.com/loft-sh/devspace/pkg/devspace/pullsecrets" - "strings" "github.com/loft-sh/devspace/pkg/devspace/build/builder" "github.com/loft-sh/devspace/pkg/devspace/build/types" @@ -98,17 +99,17 @@ func (c *controller) Build(ctx devspacecontext.Context, images []string, options dockerClient, err := dockerclient.NewClient(ctx.Context(), ctx.Log()) if err == nil { - if imageConf.Kaniko != nil && imageConf.Kaniko.Namespace != "" && ctx.KubeClient().Namespace() != imageConf.Kaniko.Namespace { - err = pullsecrets.NewClient().EnsurePullSecret(ctx, dockerClient, imageConf.Kaniko.Namespace, registryURL) + if imageConf.Kaniko != nil { + pullSecretNamespace := imageConf.Kaniko.Namespace + if pullSecretNamespace == "" { + pullSecretNamespace = ctx.KubeClient().Namespace() + } + + err = pullsecrets.NewClient().EnsurePullSecret(ctx, dockerClient, pullSecretNamespace, registryURL) if err != nil { ctx.Log().Errorf("error ensuring pull secret for registry %s: %v", registryURL, err) } } - - err = pullsecrets.NewClient().EnsurePullSecret(ctx, dockerClient, ctx.KubeClient().Namespace(), registryURL) - if err != nil { - ctx.Log().Errorf("error ensuring pull secret for registry %s: %v", registryURL, err) - } } }