Skip to content
This repository was archived by the owner on Mar 25, 2018. It is now read-only.
This repository was archived by the owner on Mar 25, 2018. It is now read-only.

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

Open
@codefromthecrypt

Description

@codefromthecrypt

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 [email protected] "`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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions