@@ -8,10 +8,6 @@ import (
88 "strings"
99 "time"
1010
11- "github.com/caraml-dev/turing/api/turing/cluster"
12- "github.com/caraml-dev/turing/api/turing/config"
13- "github.com/caraml-dev/turing/api/turing/log"
14- "github.com/caraml-dev/turing/api/turing/models"
1511 "github.com/google/go-containerregistry/pkg/authn"
1612 "github.com/google/go-containerregistry/pkg/name"
1713 "github.com/google/go-containerregistry/pkg/v1/google"
@@ -22,6 +18,11 @@ import (
2218 apicorev1 "k8s.io/api/core/v1"
2319 kerrors "k8s.io/apimachinery/pkg/api/errors"
2420 "k8s.io/apimachinery/pkg/api/resource"
21+
22+ "github.com/caraml-dev/turing/api/turing/cluster"
23+ "github.com/caraml-dev/turing/api/turing/config"
24+ "github.com/caraml-dev/turing/api/turing/log"
25+ "github.com/caraml-dev/turing/api/turing/models"
2526)
2627
2728var (
@@ -356,11 +357,22 @@ func (ib *imageBuilder) createKanikoJob(
356357 )
357358}
358359
360+ // getGCPSubDomains returns the list of GCP container registry and artifact registry subdomains.
361+ //
362+ // GCP container registry and artifact registry domains are used to determine which keychain
363+ // to use when interacting with container registry.
364+ // This is needed because GCP registries use different authentication method than other container registry.
365+ func getGCPSubDomains () []string {
366+ return []string {"gcr.io" , "pkg.dev" }
367+ }
368+
359369func (ib * imageBuilder ) checkIfImageExists (imageName string , imageTag string ) (bool , error ) {
360370 keychain := authn .DefaultKeychain
361371
362- if strings .Contains (ib .imageBuildingConfig .DestinationRegistry , "gcr.io" ) {
363- keychain = google .Keychain
372+ for _ , domain := range getGCPSubDomains () {
373+ if strings .Contains (ib .imageBuildingConfig .DestinationRegistry , domain ) {
374+ keychain = google .Keychain
375+ }
364376 }
365377
366378 repo , err := name .NewRepository (imageName )
0 commit comments