I'm trying to use this method directly because of token expiration in long builds.
- docker can push
- dagger can push without this step
So am I using this incorrectly?
// username := "jenkins@foo-dev.iam.gserviceaccount.com"
// ideally we use a service account here, neither works however
username := "tony@foo.com"
// get fresh auth creds because GCP oauth is quite short-lived
out, err := exec.Command("gcloud", "auth", "print-access-token", "--account", username).CombinedOutput()
if err != nil {
return fmt.Errorf("while refreshing auth to registry: %w", err)
}
token := rt.Dagger.SetSecret("gcp-oauth-token", string(out))
registry := "us-central1-docker.pkg.dev"
// publish to GCR/GAR
_, err = comp.Final.
WithRegistryAuth(
registry,
username,
token,
).
Publish(rt.Ctx, uri)
No matter the incantation, I get a 405 method not allowed
failed to export: failed to push us-central1-docker.pkg.dev/foo-dev/eng/foo/backup-db:feature-di-1205-fedx-poc-local: failed to authorize: failed to fetch oauth token: unexpected status from POST request to https://us-central1-docker.pkg.dev/v2/token: 405 Method Not Allowed