Method: Common::Utils::CredentialsInfo.project_id

Defined in:
lib/fluent/plugin/common.rb

.project_idObject

Determine the project ID from the credentials, if possible. Returns the project ID (as a string) on success, or nil on failure.

[View source]

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/fluent/plugin/common.rb', line 353

def self.project_id
  creds = Google::Auth.get_application_default(LOGGING_SCOPE)
  if creds.respond_to?(:project_id)
    return creds.project_id if creds.project_id
  end
  if creds.issuer
    id = extract_project_id(creds.issuer)
    return id unless id.nil?
  end
  if creds.client_id
    id = extract_project_id(creds.client_id)
    return id unless id.nil?
  end
  nil
end