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
This commit is contained in:
Raghav
2025-07-09 16:03:56 +05:30
committed by GitHub
parent a8c364c9e7
commit ae33ce93b8
7 changed files with 31 additions and 13 deletions
+8 -3
View File
@@ -711,15 +711,20 @@ func setDockerAuth(username, password, registry, dockerUsername, dockerPassword,
Password: password, Password: password,
} }
credentials := []docker.RegistryCredentials{pushToRegistryCreds}
if dockerRegistry != "" {
pullFromRegistryCreds := docker.RegistryCredentials{ pullFromRegistryCreds := docker.RegistryCredentials{
Registry: dockerRegistry, Registry: dockerRegistry,
Username: dockerUsername, Username: dockerUsername,
Password: dockerPassword, Password: dockerPassword,
} }
credentials = append(credentials, pullFromRegistryCreds)
credentials := []docker.RegistryCredentials{pushToRegistryCreds, 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")
}
return dockerConfig.CreateDockerConfig(credentials, dockerConfigPath) return dockerConfig.CreateDockerConfig(credentials, dockerConfigPath)
} }
func encodeParam(s string) string { func encodeParam(s string) string {
+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 != "" {
+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")
} }
} }
+5 -2
View 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,