train icon indicating copy to clipboard operation
train copied to clipboard

Google Cloud API version should be configurable

Open walterdolce opened this issue 6 years ago • 0 comments

Description

Currently, inspec-gcp does not support GCP folders. I was about to start implementing support for them but I discovered Google Cloud V1 APIs don't provide you much functionality, but V2 does.

By looking at the gcp transport file, I see there are various references of:

gcp_client(Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService)

That means I can't tell inspec/inspec-gcp/trains to use V2.

I think users should have the ability to configure this aspect. I also think it will allow for greater flexibility (think Google Cloud V3?).

The how of this I don't care much. I.e. you may want to default to using V1, then perhaps one day with a major version of train, etc default to V2 and so on. But even then, with the API version as a configurable element future users will still be able to use old versions of the Google Cloud API (assumes Google will keep them living "forever").

Hope this makes sense. What do you think?

Train and Platform Version

N/A

Replication Case

N/A

Possible Solutions

The easiest possible solution that comes to mind is to have the gcp transport class to read an environment variable, and then instantiate the relevant Google API class. Something like this, perhaps:

      def gcp_project_client
        klass = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService
        klass = Google::Apis::CloudresourcemanagerV2::CloudResourceManagerService if ENV['TRAINS_GOOGLE_API_VERSION']
        gcp_client(klass)
      end

There might be a better way to centrally manage this. Please note I have no knowledge of the train codebase at the moment but the above is based on reverse engineering what I was trying to achieve and the limitation that I've come across 😃

Stacktrace

N/A

walterdolce avatar Feb 21 '19 10:02 walterdolce