Class: Datadog::CI::Ext::Environment::Extractor
- Inherits:
-
Object
- Object
- Datadog::CI::Ext::Environment::Extractor
- Defined in:
- lib/datadog/ci/ext/environment/extractor.rb
Overview
Provider is a specific CI provider like Azure Pipelines, Github Actions, Gitlab CI, etc Extractor is responsible for detecting where pipeline is being executed based on environment vars and return the specific extractor that is able to return environment- and git-specific tags
Instance Method Summary collapse
-
#initialize(env, provider_klass: nil) ⇒ Extractor
constructor
A new instance of Extractor.
- #tags ⇒ Object
Constructor Details
#initialize(env, provider_klass: nil) ⇒ Extractor
Returns a new instance of Extractor.
17 18 19 20 |
# File 'lib/datadog/ci/ext/environment/extractor.rb', line 17 def initialize(env, provider_klass: nil) @env = env @provider = provider_klass ? provider_klass.new(env) : Providers.for_environment(env) end |
Instance Method Details
#tags ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/datadog/ci/ext/environment/extractor.rb', line 22 def return @tags if defined?(@tags) @tags = { Environment::TAG_JOB_NAME => @provider.job_name, Environment::TAG_JOB_URL => @provider.job_url, Environment::TAG_PIPELINE_ID => @provider.pipeline_id, Environment::TAG_PIPELINE_NAME => @provider.pipeline_name, Environment::TAG_PIPELINE_NUMBER => @provider.pipeline_number, Environment::TAG_PIPELINE_URL => @provider.pipeline_url, Environment::TAG_PROVIDER_NAME => @provider.provider_name, Environment::TAG_STAGE_NAME => @provider.stage_name, Environment::TAG_WORKSPACE_PATH => @provider.workspace_path, Environment::TAG_NODE_LABELS => @provider.node_labels, Environment::TAG_NODE_NAME => @provider.node_name, Environment::TAG_CI_ENV_VARS => @provider.ci_env_vars, Git::TAG_BRANCH => @provider.git_branch, Git::TAG_REPOSITORY_URL => @provider.git_repository_url, Git::TAG_TAG => @provider.git_tag, Git::TAG_COMMIT_AUTHOR_DATE => @provider., Git::TAG_COMMIT_AUTHOR_EMAIL => @provider., Git::TAG_COMMIT_AUTHOR_NAME => @provider., Git::TAG_COMMIT_COMMITTER_DATE => @provider.git_commit_committer_date, Git::TAG_COMMIT_COMMITTER_EMAIL => @provider.git_commit_committer_email, Git::TAG_COMMIT_COMMITTER_NAME => @provider.git_commit_committer_name, Git::TAG_COMMIT_MESSAGE => @provider., Git::TAG_COMMIT_SHA => @provider.git_commit_sha } # set additional tags if provider needs them @provider..each do |key, value| @tags[key] = value end # Normalize Git references and filter sensitive data normalize_git! # Expand ~ # remove empty tags @tags.reject! do |_, v| # setting type of v here to untyped because steep does not # understand `v.nil? || something` # @type var v: untyped v.nil? || v.strip.empty? end @tags end |