Skip to content

Commit

Permalink
fix: only upload pull secret credentials for kaniko and in cluster bu…
Browse files Browse the repository at this point in the history
…ildkit builds

Fixes #2729
Fixes ENG-2185

Signed-off-by: Russell Centanni <russell.centanni@gmail.com>
  • Loading branch information
lizardruss committed Nov 14, 2023
1 parent 419d97e commit 5b2f7ea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkg/devspace/build/build.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit 5b2f7ea

Please sign in to comment.