Class: CodeBuildNotifier::Config
- Inherits:
-
Object
- Object
- CodeBuildNotifier::Config
- Defined in:
- lib/codebuild-notifier/config.rb
Constant Summary collapse
- DEFAULT_WHITELIST =
%w[master]
Instance Attribute Summary collapse
-
#additional_channel ⇒ Object
readonly
Returns the value of attribute additional_channel.
-
#default_strategy ⇒ Object
readonly
Returns the value of attribute default_strategy.
-
#dynamo_table ⇒ Object
readonly
Returns the value of attribute dynamo_table.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#slack_admins ⇒ Object
readonly
Returns the value of attribute slack_admins.
-
#slack_secret_name ⇒ Object
readonly
Returns the value of attribute slack_secret_name.
-
#whitelist_branches ⇒ Object
readonly
Returns the value of attribute whitelist_branches.
Instance Method Summary collapse
-
#initialize(additional_channel: ENV['CBN_ADDITIONAL_CHANNEL'], default_strategy: ENV['CBN_DEFAULT_NOTIFY_STRATEGY'] || 'fail_or_status_change', dynamo_table: ENV['CBN_DYNAMO_TABLE'] || 'codebuild-history', region: ENV['CBN_AWS_REGION'] || ENV['AWS_REGION'], slack_admins: ENV['CBN_SLACK_ADMIN_USERNAMES'], slack_secret_name: ENV['CBN_SLACK_SECRET_NAME'] || 'slack/codebuild', strategy_overrides: ENV['CBN_OVERRIDE_NOTIFY_STRATEGY'], whitelist_branches: ENV['CBN_WHITELIST_BRANCHES']) ⇒ Config
constructor
Configuration values specific to CodeBuild Notifier.
-
#non_pr_branch_ids ⇒ Object
Match the format of the CodeBuild trigger variable.
- #strategy_for_branch(branch_name) ⇒ Object
- #whitelist ⇒ Object
Constructor Details
#initialize(additional_channel: ENV['CBN_ADDITIONAL_CHANNEL'], default_strategy: ENV['CBN_DEFAULT_NOTIFY_STRATEGY'] || 'fail_or_status_change', dynamo_table: ENV['CBN_DYNAMO_TABLE'] || 'codebuild-history', region: ENV['CBN_AWS_REGION'] || ENV['AWS_REGION'], slack_admins: ENV['CBN_SLACK_ADMIN_USERNAMES'], slack_secret_name: ENV['CBN_SLACK_SECRET_NAME'] || 'slack/codebuild', strategy_overrides: ENV['CBN_OVERRIDE_NOTIFY_STRATEGY'], whitelist_branches: ENV['CBN_WHITELIST_BRANCHES']) ⇒ Config
Configuration values specific to CodeBuild Notifier. CBN_ prefix is used because ENV vars with CODEBUILD_ prefix are reserved for use by AWS.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/codebuild-notifier/config.rb', line 27 def initialize( additional_channel: ENV['CBN_ADDITIONAL_CHANNEL'], default_strategy: ENV['CBN_DEFAULT_NOTIFY_STRATEGY'] || 'fail_or_status_change', dynamo_table: ENV['CBN_DYNAMO_TABLE'] || 'codebuild-history', region: ENV['CBN_AWS_REGION'] || ENV['AWS_REGION'], slack_admins: ENV['CBN_SLACK_ADMIN_USERNAMES'], slack_secret_name: ENV['CBN_SLACK_SECRET_NAME'] || 'slack/codebuild', strategy_overrides: ENV['CBN_OVERRIDE_NOTIFY_STRATEGY'], whitelist_branches: ENV['CBN_WHITELIST_BRANCHES'] ) @additional_channel = additional_channel @default_strategy = default_strategy @dynamo_table = dynamo_table @region = region @slack_admins = slack_admins&.split(',') || [] @slack_secret_name = slack_secret_name @strategy_overrides = strategy_overrides&.split(',') || [] @whitelist_branches = whitelist_branches&.split(',') || DEFAULT_WHITELIST end |
Instance Attribute Details
#additional_channel ⇒ Object (readonly)
Returns the value of attribute additional_channel.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def additional_channel @additional_channel end |
#default_strategy ⇒ Object (readonly)
Returns the value of attribute default_strategy.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def default_strategy @default_strategy end |
#dynamo_table ⇒ Object (readonly)
Returns the value of attribute dynamo_table.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def dynamo_table @dynamo_table end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def region @region end |
#slack_admins ⇒ Object (readonly)
Returns the value of attribute slack_admins.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def slack_admins @slack_admins end |
#slack_secret_name ⇒ Object (readonly)
Returns the value of attribute slack_secret_name.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def slack_secret_name @slack_secret_name end |
#whitelist_branches ⇒ Object (readonly)
Returns the value of attribute whitelist_branches.
22 23 24 |
# File 'lib/codebuild-notifier/config.rb', line 22 def whitelist_branches @whitelist_branches end |
Instance Method Details
#non_pr_branch_ids ⇒ Object
Match the format of the CodeBuild trigger variable
53 54 55 |
# File 'lib/codebuild-notifier/config.rb', line 53 def non_pr_branch_ids whitelist_branches.map { |name| "branch/#{name}" } end |
#strategy_for_branch(branch_name) ⇒ Object
47 48 49 50 |
# File 'lib/codebuild-notifier/config.rb', line 47 def strategy_for_branch(branch_name) lookup = @strategy_overrides.map { |override| override.split(':') }.to_h lookup.fetch(branch_name, default_strategy) end |
#whitelist ⇒ Object
57 58 59 |
# File 'lib/codebuild-notifier/config.rb', line 57 def whitelist whitelist_branches.join(', ') end |