Skip to content

Commit

Permalink
use mock registry if MOCK_GOOGLE_TOKEN is true
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Oct 4, 2024
1 parent 411c80a commit 16d74b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,20 @@ func createPullSecret(clientset *kubernetes.Clientset, ns *corev1.Namespace, cre
}
}

registries := append(gcr_config.DefaultGCRRegistries[:], gcr_config.DefaultARRegistries[:]...)
// The MOCK_GOOGLE_TOKEN env var prevents using credentials to fetch the token. Instead the token will be mocked.
mockToken, _ := strconv.ParseBool(os.Getenv("MOCK_GOOGLE_TOKEN"))
var token *oauth2.Token
if mockToken {
token = &oauth2.Token{AccessToken: "mock_access_token"}
registries = []string{"mock-registry"}
} else {
token, err = creds.TokenSource.Token()
if err != nil {
return err
}
}
var dockercfg string
registries := append(gcr_config.DefaultGCRRegistries[:], gcr_config.DefaultARRegistries[:]...)
for _, reg := range registries {
dockercfg += fmt.Sprintf(`"https://%s":{"username":"oauth2accesstoken","password":"%s","email":"none"},`, reg, token.AccessToken)
}
Expand Down

0 comments on commit 16d74b2

Please sign in to comment.