Compare commits

..

2 Commits

Author SHA1 Message Date
OP (oppenheimer) 809fadc203 feat: [CI-17517]: Add push-only support for Kaniko-GAR (#147)
* Add push-only support to Kaniko-GAR

* Refactor GAR authentication and crane push to use Application Default Credentials

* Add robust GAR authentication with Docker config and crane options

* GAR authentication setup and remove redundant logging statements
2025-05-13 21:30:09 +05:30
ompragash.viswanathan@harness.io 87ca9fe1b7 Update pipeline drone-kaniko-harness 2025-05-12 20:38:33 +05:30
2 changed files with 6 additions and 9 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ pipeline:
identifier: Build
spec:
connectorRef: Plugins_Docker_Hub_Connector
image: golang:1.22.4
image: golang:1.23.0
shell: Sh
command: |-
go test ./...
@@ -322,7 +322,7 @@ pipeline:
identifier: Build_and_Test
spec:
connectorRef: Plugins_Docker_Hub_Connector
image: golang:1.22.4
image: golang:1.23.0
shell: Sh
command: |-
go test ./...
+4 -7
View File
@@ -513,13 +513,11 @@ func handlePushOnly(c *cli.Context) error {
// Setup GAR authentication
jsonKey := c.String("json-key")
if jsonKey != "" {
// Setup standard env variable auth which didn't work
if err := setupGARAuth(jsonKey); err != nil {
return err
}
// Try an alternative approach: create a Docker config.json with GAR credentials
logrus.Info("Setting up Docker config authentication for GAR")
logrus.Info("Setting up authentication for GAR")
// Create Docker config directory if it doesn't exist
dockerConfigDir := "/kaniko/.docker"
@@ -568,7 +566,6 @@ func handlePushOnly(c *cli.Context) error {
if err := os.Setenv("DOCKER_CONFIG", dockerConfigDir); err != nil {
return fmt.Errorf("failed to set DOCKER_CONFIG environment variable: %v", err)
}
logrus.Infof("Set DOCKER_CONFIG to %s", dockerConfigDir)
// Set up crane to use basic auth with docker config
opts = append(opts, crane.WithAuthFromKeychain(authn.DefaultKeychain))
@@ -592,11 +589,11 @@ func handlePushOnly(c *cli.Context) error {
for _, tag := range tags {
dest := fmt.Sprintf("%s/%s:%s", registry, repo, tag)
logrus.Infof("Pushing image to: %s", dest)
if err := crane.Push(img, dest, opts...); err != nil {
return fmt.Errorf("failed to push image to %s: %v", dest, err)
}
logrus.Infof("Successfully pushed image to %s", dest)
}