Compare commits

...

2 Commits

Author SHA1 Message Date
Raghav ae33ce93b8 feat: [CI-17953]: Add warning if base image connector is not provided (#152)
* [CI-17953]: Add warning if base image connector is not provided

* [CI-17953]: Add warning if base image connector is not provided

* [CI-17953]: Add warning if base image connector is not provided
2025-07-09 16:03:56 +05:30
OP (oppenheimer) a8c364c9e7 update kaniko-executor base image to 1.25.0 from chaingaurds maintained fork (#150) 2025-07-03 19:14:28 +05:30
15 changed files with 47 additions and 29 deletions
+12 -7
View File
@@ -711,15 +711,20 @@ func setDockerAuth(username, password, registry, dockerUsername, dockerPassword,
Password: password, Password: password,
} }
pullFromRegistryCreds := docker.RegistryCredentials{ credentials := []docker.RegistryCredentials{pushToRegistryCreds}
Registry: dockerRegistry,
Username: dockerUsername, if dockerRegistry != "" {
Password: dockerPassword, pullFromRegistryCreds := docker.RegistryCredentials{
Registry: dockerRegistry,
Username: dockerUsername,
Password: dockerPassword,
}
credentials = append(credentials, pullFromRegistryCreds)
} else {
fmt.Println("\033[33mTo ensure consistent and reliable pipeline execution, we recommend setting up a Base Image Connector.\033[0m\n" +
"\033[33mWhile optional at this time, configuring it helps prevent failures caused by Docker Hub's rate limits.\033[0m")
} }
credentials := []docker.RegistryCredentials{pushToRegistryCreds, pullFromRegistryCreds}
return dockerConfig.CreateDockerConfig(credentials, dockerConfigPath) return dockerConfig.CreateDockerConfig(credentials, dockerConfigPath)
} }
func encodeParam(s string) string { func encodeParam(s string) string {
+1 -1
View File
@@ -153,4 +153,4 @@ func TestCreateDockerConfigWithoutBaseRegistry(t *testing.T) {
// Check if the public Docker Hub auth is not set // Check if the public Docker Hub auth is not set
_, exists := config.Auths[""] _, exists := config.Auths[""]
assert.False(t, exists) assert.False(t, exists)
} }
+4
View File
@@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"os" "os"
"strings" "strings"
@@ -508,6 +509,9 @@ func setDockerAuth(username, password, registry, baseImageUsername, baseImagePas
Password: baseImagePassword, Password: baseImagePassword,
} }
credentials = append(credentials, pullFromRegistryCreds) credentials = append(credentials, pullFromRegistryCreds)
} else {
fmt.Println("\033[33mTo ensure consistent and reliable pipeline execution, we recommend setting up a Base Image Connector.\033[0m\n" +
"\033[33mWhile optional at this time, configuring it helps prevent failures caused by Docker Hub's rate limits.\033[0m")
} }
// Creates docker config for both the regustries used for authentication // Creates docker config for both the regustries used for authentication
return dockerConfig.CreateDockerConfig(credentials, dockerPath) return dockerConfig.CreateDockerConfig(credentials, dockerPath)
+3
View File
@@ -585,6 +585,9 @@ func setDockerAuth(dockerRegistry, dockerUsername, dockerPassword, accessKey, se
Password: dockerPassword, Password: dockerPassword,
} }
credentials = append(credentials, pullFromRegistryCreds) credentials = append(credentials, pullFromRegistryCreds)
} else {
fmt.Println("\033[33mTo ensure consistent and reliable pipeline execution, we recommend setting up a Base Image Connector.\033[0m\n" +
"\033[33mWhile optional at this time, configuring it helps prevent failures caused by Docker Hub's rate limits.\033[0m")
} }
if assumeRole != "" && oidcToken != "" { if assumeRole != "" && oidcToken != "" {
+1 -1
View File
@@ -42,4 +42,4 @@ func TestCreateDockerConfigForECRWithBaseRegistry(t *testing.T) {
expectedDockerAuth := docker.Auth{Auth: base64.StdEncoding.EncodeToString([]byte(dockerUsername + ":" + dockerPassword))} expectedDockerAuth := docker.Auth{Auth: base64.StdEncoding.EncodeToString([]byte(dockerUsername + ":" + dockerPassword))}
assert.Equal(t, expectedDockerAuth, config.Auths[dockerRegistry]) assert.Equal(t, expectedDockerAuth, config.Auths[dockerRegistry])
} }
+3
View File
@@ -384,6 +384,9 @@ func run(c *cli.Context) error {
); err != nil { ); err != nil {
return errors.Wrap(err, "failed to create docker config") return errors.Wrap(err, "failed to create docker config")
} }
} else {
fmt.Println("\033[33mTo ensure consistent and reliable pipeline execution, we recommend setting up a Base Image Connector.\033[0m\n" +
"\033[33mWhile optional at this time, configuring it helps prevent failures caused by Docker Hub's rate limits.\033[0m")
} }
} }
+7 -4
View File
@@ -18,8 +18,8 @@ import (
const ( const (
dockerConfigPath string = "/kaniko/.docker" dockerConfigPath string = "/kaniko/.docker"
// GCR JSON key file path // GCR JSON key file path
gcrKeyPath string = "/kaniko/config.json" gcrKeyPath string = "/kaniko/config.json"
gcrEnvVariable string = "GOOGLE_APPLICATION_CREDENTIALS" gcrEnvVariable string = "GOOGLE_APPLICATION_CREDENTIALS"
defaultDigestFile string = "/kaniko/digest-file" defaultDigestFile string = "/kaniko/digest-file"
) )
@@ -353,7 +353,7 @@ func run(c *cli.Context) error {
} }
// setup docker config only when base image registry is specified // setup docker config only when base image registry is specified
if c.String("base-image-registry") != ""{ if c.String("base-image-registry") != "" {
if err := setDockerAuth( if err := setDockerAuth(
c.String("base-image-username"), c.String("base-image-username"),
c.String("base-image-password"), c.String("base-image-password"),
@@ -361,6 +361,9 @@ func run(c *cli.Context) error {
); err != nil { ); err != nil {
return errors.Wrap(err, "failed to create docker config") return errors.Wrap(err, "failed to create docker config")
} }
} else {
fmt.Println("\033[33mTo ensure consistent and reliable pipeline execution, we recommend setting up a Base Image Connector.\033[0m\n" +
"\033[33mWhile optional at this time, configuring it helps prevent failures caused by Docker Hub's rate limits.\033[0m")
} }
} }
@@ -439,7 +442,7 @@ func run(c *cli.Context) error {
return plugin.Exec() return plugin.Exec()
} }
func setDockerAuth(dockerUsername, dockerPassword, dockerRegistry string) (error) { func setDockerAuth(dockerUsername, dockerPassword, dockerRegistry string) error {
dockerConfig := docker.NewConfig() dockerConfig := docker.NewConfig()
dockerRegistryCreds := docker.RegistryCredentials{ dockerRegistryCreds := docker.RegistryCredentials{
Registry: dockerRegistry, Registry: dockerRegistry,
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-amd64
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/amd64/kaniko-acr /kaniko/ ADD release/linux/amd64/kaniko-acr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-acr"] ENTRYPOINT ["/kaniko/kaniko-acr"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.23.0 FROM harnesscommunity/kaniko-executor:1.25.0-linux-arm64
ENV HOME /root ENV HOME /root
ENV USER root ENV USER root
ENV KANIKO_VERSION=1.23.0 ENV KANIKO_VERSION=1.25.0
ADD release/linux/arm64/kaniko-acr /kaniko/ ADD release/linux/arm64/kaniko-acr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-acr"] ENTRYPOINT ["/kaniko/kaniko-acr"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-amd64
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/amd64/kaniko-docker /kaniko/ ADD release/linux/amd64/kaniko-docker /kaniko/
ENTRYPOINT ["/kaniko/kaniko-docker"] ENTRYPOINT ["/kaniko/kaniko-docker"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-arm64
ENV HOME /root ENV HOME /root
ENV USER root ENV USER root
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/arm64/kaniko-docker /kaniko/ ADD release/linux/arm64/kaniko-docker /kaniko/
ENTRYPOINT ["/kaniko/kaniko-docker"] ENTRYPOINT ["/kaniko/kaniko-docker"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-amd64
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/amd64/kaniko-ecr /kaniko/ ADD release/linux/amd64/kaniko-ecr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-ecr"] ENTRYPOINT ["/kaniko/kaniko-ecr"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-arm64
ENV HOME /root ENV HOME /root
ENV USER root ENV USER root
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/arm64/kaniko-ecr /kaniko/ ADD release/linux/arm64/kaniko-ecr /kaniko/
ENTRYPOINT ["/kaniko/kaniko-ecr"] ENTRYPOINT ["/kaniko/kaniko-ecr"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-amd64
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/amd64/kaniko-gar /kaniko/ ADD release/linux/amd64/kaniko-gar /kaniko/
ENTRYPOINT ["/kaniko/kaniko-gar"] ENTRYPOINT ["/kaniko/kaniko-gar"]
+2 -2
View File
@@ -1,8 +1,8 @@
FROM gcr.io/kaniko-project/executor:v1.23.2 FROM harnesscommunity/kaniko-executor:1.25.0-linux-arm64
ENV HOME /root ENV HOME /root
ENV USER root ENV USER root
ENV KANIKO_VERSION=1.23.2 ENV KANIKO_VERSION=1.25.0
ADD release/linux/arm64/kaniko-gar /kaniko/ ADD release/linux/arm64/kaniko-gar /kaniko/
ENTRYPOINT ["/kaniko/kaniko-gar"] ENTRYPOINT ["/kaniko/kaniko-gar"]