class Capistrano::Gcp::Autoscaling::Core::ComputeService

Attributes

options[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/capistrano/gcp/autoscaling/core/compute_service.rb, line 8
def initialize(options = {})
  @options = options
end

Public Instance Methods

instance() click to toggle source
# File lib/capistrano/gcp/autoscaling/core/compute_service.rb, line 12
def instance
  @instance ||= Google::Apis::ComputeV1::ComputeService.new.tap do |instance|
    ensure_env_variables_set!
    ensure_authorization_set!(instance)
  end
end

Private Instance Methods

ensure_authorization_set!(instance) click to toggle source
# File lib/capistrano/gcp/autoscaling/core/compute_service.rb, line 28
def ensure_authorization_set!(instance)
  instance.authorization = Google::Auth::ServiceAccountCredentials.make_creds(
    scope: options.fetch(:gcp_scope)
  )
end
ensure_env_variables_set!() click to toggle source
# File lib/capistrano/gcp/autoscaling/core/compute_service.rb, line 23
def ensure_env_variables_set!
  ENV[Google::Auth::CredentialsLoader::PRIVATE_KEY_VAR] = options.fetch(:gcp_private_key)
  ENV[Google::Auth::CredentialsLoader::CLIENT_EMAIL_VAR] = options.fetch(:gcp_client_email)
end