Class: Datadog::CI::Ext::Environment::ConfigurationDiscrepancyChecker
- Inherits:
-
Object
- Object
- Datadog::CI::Ext::Environment::ConfigurationDiscrepancyChecker
- Defined in:
- lib/datadog/ci/ext/environment/configuration_discrepancy_checker.rb
Instance Method Summary collapse
- #check_for_discrepancies ⇒ Object
-
#initialize(ci_provider_env_tags, local_git_tags, user_provided_tags) ⇒ ConfigurationDiscrepancyChecker
constructor
A new instance of ConfigurationDiscrepancyChecker.
Constructor Details
#initialize(ci_provider_env_tags, local_git_tags, user_provided_tags) ⇒ ConfigurationDiscrepancyChecker
Returns a new instance of ConfigurationDiscrepancyChecker.
12 13 14 15 16 |
# File 'lib/datadog/ci/ext/environment/configuration_discrepancy_checker.rb', line 12 def initialize(, , ) @ci_provider_env_tags = @local_git_tags = @user_provided_tags = end |
Instance Method Details
#check_for_discrepancies ⇒ Object
18 19 20 21 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 73 74 75 76 77 78 79 |
# File 'lib/datadog/ci/ext/environment/configuration_discrepancy_checker.rb', line 18 def check_for_discrepancies checks = [ { left: normalize_value(@ci_provider_env_tags[Git::TAG_COMMIT_SHA]), right: normalize_value(@local_git_tags[Git::TAG_COMMIT_SHA]), type: "commit_discrepancy", expected: "ci_provider", discrepant: "git_client" }, { left: normalize_value(@user_provided_tags[Git::TAG_COMMIT_SHA]), right: normalize_value(@local_git_tags[Git::TAG_COMMIT_SHA]), type: "commit_discrepancy", expected: "user_supplied", discrepant: "git_client" }, { left: normalize_value(@user_provided_tags[Git::TAG_COMMIT_SHA]), right: normalize_value(@ci_provider_env_tags[Git::TAG_COMMIT_SHA]), type: "commit_discrepancy", expected: "user_supplied", discrepant: "ci_provider" }, { left: normalize_value(@ci_provider_env_tags[Git::TAG_REPOSITORY_URL]), right: normalize_value(@local_git_tags[Git::TAG_REPOSITORY_URL]), type: "repository_discrepancy", expected: "ci_provider", discrepant: "git_client" }, { left: normalize_value(@user_provided_tags[Git::TAG_REPOSITORY_URL]), right: normalize_value(@local_git_tags[Git::TAG_REPOSITORY_URL]), type: "repository_discrepancy", expected: "user_supplied", discrepant: "git_client" }, { left: normalize_value(@user_provided_tags[Git::TAG_REPOSITORY_URL]), right: normalize_value(@ci_provider_env_tags[Git::TAG_REPOSITORY_URL]), type: "repository_discrepancy", expected: "user_supplied", discrepant: "ci_provider" } ] git_info_match = true checks.each do |check| if check[:left] && check[:right] && check[:left] != check[:right] Utils::Telemetry.inc(Ext::Telemetry::METRIC_GIT_COMMIT_SHA_DISCREPANCY, 1, { type: check[:type].to_s, expected_provider: check[:expected].to_s, discrepant_provider: check[:discrepant].to_s }) git_info_match = false end end Utils::Telemetry.inc(Ext::Telemetry::METRIC_GIT_COMMIT_SHA_MATCH, 1, { matched: git_info_match.to_s }) end |