Method: Common::Utils::CredentialsInfo.extract_project_id
- Defined in:
- lib/fluent/plugin/common.rb
.extract_project_id(str) ⇒ Object
Extracts the project id (either name or number) from str and returns it (as a string) on success, or nil on failure.
Recognizes IAM format (account@project-name.iam.gserviceaccount.com) as well as the legacy format with a project number at the front of the string, terminated by a dash (-) which is not part of the ID, i.e.: <PROJECT_ID>-<OTHER_PARTS>.apps.googleusercontent.com
376 377 378 379 380 381 382 383 |
# File 'lib/fluent/plugin/common.rb', line 376 def self.extract_project_id(str) [/^.*@(?<project_id>.+)\.iam\.gserviceaccount\.com/, /^(?<project_id>\d+)-/].each do |exp| match_data = exp.match(str) return match_data['project_id'] unless match_data.nil? end nil end |