Class: Bcome::Driver::Gcp::Authentication::ServiceAccount
- Inherits:
-
Base
- Object
- Base
- Bcome::Driver::Gcp::Authentication::ServiceAccount
show all
- Defined in:
- lib/objects/driver/gcp/authentication/service_account.rb
Instance Method Summary
collapse
Methods inherited from Base
#credential_directory, #credential_file, #ensure_credential_directory, #full_path_to_credential_file, #loader_title
#cursor, #do_signal, #fork_process, #signal_failure, #signal_stop, #signal_success, #start_indicator, #stop_indicator, #wrap_indicator
Constructor Details
#initialize(service, scopes, node, credentials_file_name, driver) ⇒ ServiceAccount
Returns a new instance of ServiceAccount.
5
6
7
8
9
10
11
12
13
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 5
def initialize(service, scopes, node, credentials_file_name, driver)
@service = service
@scopes = scopes
@node = node
@driver = driver
@credentials_file_name = credentials_file_name
ensure_credential_directory
ensure_credentials_file
end
|
Instance Method Details
#authorize! ⇒ Object
57
58
59
60
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 57
def authorize!
storage.authorize
@service.authorization = storage.authorization
end
|
#authorized? ⇒ Boolean
19
20
21
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 19
def authorized?
!@service.authorization.nil?
end
|
#credential_file_suffix ⇒ Object
52
53
54
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 52
def credential_file_suffix
'service-account.json'
end
|
#credentials_file_path ⇒ Object
27
28
29
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 27
def credentials_file_path
has_namespaced_keyed_filename? ? namespaced_keyed_filename : defined_credentials_files
end
|
#defined_credentials_files ⇒ Object
New implementation - we take a defined file name for the service account credentials Clean & may be re-used
38
39
40
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 38
def defined_credentials_files
"#{credential_directory}/#{@credentials_file_name}"
end
|
#do! ⇒ Object
15
16
17
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 15
def do!
@service.authorization = service_account
end
|
#ensure_credentials_file ⇒ Object
#has_namespaced_keyed_filename? ⇒ Boolean
42
43
44
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 42
def has_namespaced_keyed_filename?
@has_namespaced_keyed_filename ||= File.exist?(namespaced_keyed_filename)
end
|
#namespaced_keyed_filename ⇒ Object
Older implementation - we infer the credentials file from the namespace Retained to provide backwards compatibility
48
49
50
|
# File 'lib/objects/driver/gcp/authentication/service_account.rb', line 48
def namespaced_keyed_filename
full_path_to_credential_file
end
|
#service_account ⇒ Object