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 7, 2023
1 parent 419d97e commit f611213
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 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,16 +99,28 @@ 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 := ctx.KubeClient().Namespace()
if imageConf.Kaniko.Namespace != "" {
pullSecretNamespace = imageConf.Kaniko.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)
if imageConf.BuildKit != nil && imageConf.BuildKit.InCluster != nil {
pullSecretNamespace := ctx.KubeClient().Namespace()
if imageConf.BuildKit.InCluster.Namespace != "" {
pullSecretNamespace = imageConf.BuildKit.InCluster.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)
}
}
}
}
Expand Down

0 comments on commit f611213

Please sign in to comment.