gkatzioura / CloudStorageMaven

90 stars 59 forks source link

Provide the possibility to work with few buckets from different Google Cloud projects #72

Open mbarouski opened 4 years ago

mbarouski commented 4 years ago

Provide the possibility to work with few buckets from different Google Cloud projects.

E.g.: I have project A which has dependencies B and C. B is deployed to b-packages bucket of b-project. C is deployed to c-packages bucket of c-project. I have a service account which has necessary rights in both projects but some package is not available:

Caused by: com.vorstella.shade.com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
  "code" : 404,
  "errors" : [ {
    "domain" : "global",
    "message" : "Not Found",
    "reason" : "notFound"
  } ],
  "message" : "Not Found"
}
    at com.vorstella.shade.com.google.api.client.googleapis.json.GoogleJsonResponseException.from (GoogleJsonResponseException.java:146)
    at com.vorstella.shade.com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError (AbstractGoogleJsonClientRequest.java:113)
    at com.vorstella.shade.com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError (AbstractGoogleJsonClientRequest.java:40)
    at com.vorstella.shade.com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse (AbstractGoogleClientRequest.java:321)
    at com.vorstella.shade.com.google.api.client.http.HttpRequest.execute (HttpRequest.java:1065)
    at com.vorstella.shade.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed (AbstractGoogleClientRequest.java:419)
    at com.vorstella.shade.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed (AbstractGoogleClientRequest.java:352)
    at com.vorstella.shade.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute (AbstractGoogleClientRequest.java:469)
    at com.vorstella.shade.com.google.cloud.storage.spi.v1.HttpStorageRpc.list (HttpStorageRpc.java:336)
    at com.vorstella.shade.com.google.cloud.storage.StorageImpl$8.call (StorageImpl.java:299)
    at com.vorstella.shade.com.google.cloud.storage.StorageImpl$8.call (StorageImpl.java:296)
    at com.vorstella.shade.com.google.api.gax.retrying.DirectRetryingExecutor.submit (DirectRetryingExecutor.java:89)
    at com.vorstella.shade.com.google.cloud.RetryHelper.run (RetryHelper.java:74)
    at com.vorstella.shade.com.google.cloud.RetryHelper.runWithRetries (RetryHelper.java:51)
    at com.vorstella.shade.com.google.cloud.storage.StorageImpl.listBlobs (StorageImpl.java:295)
    at com.vorstella.shade.com.google.cloud.storage.StorageImpl.list (StorageImpl.java:262)
    at com.gkatzioura.maven.cloud.gcs.GoogleStorageRepository.connect (GoogleStorageRepository.java:55)

I suppose it means that it finds b-package in a-project and can't find it.

mbarouski commented 4 years ago

Strange that it works when I log in to my personal account via gcloud auth application-default login command but doesn't work with service account on CI with command export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json && mvn dependency:go-offline.

UPD.: Tried to activate service account via gcloud auth activate-service-account --key-file KEY_FILE_PATH on CI and locally and it doesn't work as well.