Răsfoiți Sursa

use oauthaccess token for gar docker config

Mohammed Nafees 3 ani în urmă
părinte
comite
5b42a3a7f3
1 a modificat fișierele cu 10 adăugiri și 3 ștergeri
  1. 10 3
      internal/registry/registry.go

+ 10 - 3
internal/registry/registry.go

@@ -1604,6 +1604,13 @@ func (r *Registry) getGARDockerConfigFile(
 
 	key := r.URL
 
+	tok, err := gcp.GetBearerToken(r.getTokenCacheFunc(repo), r.setTokenCacheFunc(repo),
+		"https://www.googleapis.com/auth/cloud-platform")
+
+	if err != nil {
+		return nil, err
+	}
+
 	if !strings.Contains(key, "http") {
 		key = "https://" + key
 	}
@@ -1613,9 +1620,9 @@ func (r *Registry) getGARDockerConfigFile(
 	return &configfile.ConfigFile{
 		AuthConfigs: map[string]types.AuthConfig{
 			parsedURL.Host: {
-				Username: "_json_key",
-				Password: string(gcp.GCPKeyData),
-				Auth:     generateAuthToken("_json_key", string(gcp.GCPKeyData)),
+				Username: "oauth2accesstoken",
+				Password: tok.AccessToken,
+				Auth:     generateAuthToken("oauth2accesstoken", tok.AccessToken),
 			},
 		},
 	}, nil