jclouds / legacy-jclouds-labs

https://jclouds.apache.org
0 stars 18 forks source link

replace org.jclouds.googlecompute.GoogleComputeConstants.GOOGLE_PROJECT with getImageApi #4

Open codefromthecrypt opened 11 years ago

codefromthecrypt commented 11 years ago

When a user specifies the wrong email address for their account, an authorization error occurs relating to project.

$ java -jar target/compute-basics-jar-with-dependencies.jar google-compute adrian.f.cole@gmail.com "`cat $HOME/google-compute.pem`" mygroup add
>> initializing {id=google-compute, name=Google Compute Engine Api, views=[org.jclouds.compute.ComputeServiceContext], endpointName=https endpoint, identityName=Email associated with the Goole API client_id, credentialName=Optional.of(Private key literal associated with the Google API client_id), documentation=https://developers.google.com/compute/docs, api=interface org.jclouds.googlecompute.GoogleComputeApi, asyncApi=interface org.jclouds.googlecompute.GoogleComputeAsyncApi}
>> adding node to group mygroup
error: Guice provision errors:

1) Error in custom provider, org.jclouds.http.HttpResponseException: org.jclouds.http.HttpResponseException: command: POST https://accounts.google.com/o/oauth2/token HTTP/1.1 failed with response: HTTP/1.1 400 Bad Request; content: [{
  "error" : "invalid_grant"
}] connecting to GET https://www.googleapis.com/compute/v1beta13/projects/adrian.f.cole/zones HTTP/1.1
  at org.jclouds.compute.config.BaseComputeServiceContextModule.provideTemplateOptionallyFromProperties(BaseComputeServiceContextModule.java:184)
  while locating org.jclouds.compute.domain.TemplateBuilder annotated with @com.google.inject.name.Named(value=DEFAULT)

1 error

A savvy person would know that the email is wrong, and I should have re-read the README before blindly hunting. Even if it was my fault, crud in GoogleComputeConstants is distracting, particularly GOOGLE_PROJECT which shows up in grep.

Rather than having curious hard-coded constants, wouldn't it be better to make a special method that says what it does. I understand from @dralves that this is the project for public resources. So far as I can tell, this constant is only used in the compute service adapter for public images.e

Why not just make a method for that and remove the constant, such as we do in aws for the default zone?

   @Delegate
   @Path("/projects/google")
   ImageApi getImageApi(); // or getPublicImageApi
codefromthecrypt commented 11 years ago

cc @mattstep

dralves commented 11 years ago

Hi Adrian:

a few things:

codefromthecrypt commented 11 years ago

ok, once you mention what this magic constant does, I'll update the issue accordingly.

dralves commented 11 years ago

as I said it refers to the name of the project under which GCE keeps the "public" resources. It should be documented for dev's sake but there's no reason an user should need or even have to know about it.

codefromthecrypt commented 11 years ago

ok, I agree that this should be better documented, or better yet. removed.

If one enters the incorrect email address, the error relates to the http path including project and that this property is constant is passed as a method arg for project. This is so very unnecessarily confusing.

I'm changing the issue to remove this confusion now and will ping back.

codefromthecrypt commented 11 years ago

ok. changed the issue. you are correct that my google id works, so I'll mention this issue isn't a blocker

dralves commented 11 years ago

So this issue only refers to:

codefromthecrypt commented 11 years ago

No it refers to deleting the constant and instead expose a no arg method for ImageApi

On Sunday, March 10, 2013, David Ribeiro Alves wrote:

So this issue only refers to:

  • changing the name of the constant to something like PUBLIC_PROJECT_ID
  • documenting it

— Reply to this email directly or view it on GitHubhttps://github.com/jclouds/jclouds-labs/issues/4#issuecomment-14693367 .