From b826c7f40852cda811543e94f289f2ae38632001 Mon Sep 17 00:00:00 2001 From: "OP (oppenheimer)" <21008429+Ompragash@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:32:35 +0530 Subject: [PATCH] feat: [CI-16392]: Authenticate And Pull Private Base Images when NO_PUSH is enabled (#140) --- cmd/kaniko-acr/main.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index 0fe39bd..ca22f66 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -480,25 +480,32 @@ func setupAuth(tenantId, clientId, cert, return "", fmt.Errorf("registry must be specified") } - if noPush { - return "", nil - } - // case of client secret or cert based auth if clientId != "" { // only setup auth when pushing or credentials are defined token, publicUrl, err := getACRToken(subscriptionId, tenantId, clientId, clientSecret, cert, registry) if err != nil { + if noPush { + logrus.Warnf("NO_PUSH mode: failed to fetch ACR Token: %v", err) + return "", nil + } return "", errors.Wrap(err, "failed to fetch ACR Token") } // setup docker config for azure registry and base image docker registry if err := setDockerAuth(username, token, registry, dockerUsername, dockerPassword, dockerRegistry); err != nil { + if noPush { + logrus.Warnf("NO_PUSH mode: failed to create docker config: %v", err) + return "", nil + } return "", errors.Wrap(err, "failed to create docker config") } return publicUrl, nil } else { + if noPush { + return "", nil + } return "", fmt.Errorf("managed authentication is not supported") } }