Class: PactBroker::Config::RuntimeConfiguration

Inherits:
Anyway::Config
  • Object
show all
Includes:
RuntimeConfigurationBasicAuthMethods, RuntimeConfigurationCoercionMethods, RuntimeConfigurationDatabaseMethods, RuntimeConfigurationLoggingMethods
Defined in:
lib/pact_broker/config/runtime_configuration.rb

Constant Summary

Constants included from RuntimeConfigurationCoercionMethods

PactBroker::Config::RuntimeConfigurationCoercionMethods::COERCE_FEATURES, PactBroker::Config::RuntimeConfigurationCoercionMethods::COERCE_WEBHOOKS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RuntimeConfigurationBasicAuthMethods

included

Methods included from RuntimeConfigurationDatabaseMethods

included

Methods included from RuntimeConfigurationCoercionMethods

all_keys_are_number_strings?, convert_hash_with_number_string_keys_to_array

Methods included from RuntimeConfigurationLoggingMethods

included

Class Method Details

.getter_and_setter_method_namesObject



103
104
105
106
107
108
109
110
111
112
# File 'lib/pact_broker/config/runtime_configuration.rb', line 103

def self.getter_and_setter_method_names
  extra_methods = [
    :warning_error_classes,
    :database_configuration,
    :basic_auth_credentials_provided?,
    :basic_auth_write_credentials,
    :basic_auth_read_credentials
  ]
  config_attributes + config_attributes.collect{ |k| "#{k}=".to_sym } + extra_methods  - [:base_url]
end

Instance Method Details

#badge_provider_mode=(badge_provider_mode) ⇒ Object



159
160
161
# File 'lib/pact_broker/config/runtime_configuration.rb', line 159

def badge_provider_mode= badge_provider_mode
  super(badge_provider_mode&.to_sym)
end

#base_urlObject

Raises:

  • (NotImplementedError)


147
148
149
# File 'lib/pact_broker/config/runtime_configuration.rb', line 147

def base_url
  raise NotImplementedError
end

#base_url=(base_url) ⇒ Object



141
142
143
# File 'lib/pact_broker/config/runtime_configuration.rb', line 141

def base_url= base_url
  super(value_to_string_array(base_url, "base_url"))
end

#base_urlsObject



155
156
157
# File 'lib/pact_broker/config/runtime_configuration.rb', line 155

def base_urls
  (super + [*original_base_url]).uniq
end

#base_urls=(base_urls) ⇒ Object



151
152
153
# File 'lib/pact_broker/config/runtime_configuration.rb', line 151

def base_urls= base_urls
  super(value_to_string_array(base_urls, "base_urls"))
end

#custom_log_formatters=(custom_log_formatters) ⇒ Object



137
138
139
# File 'lib/pact_broker/config/runtime_configuration.rb', line 137

def custom_log_formatters= custom_log_formatters
  super(custom_log_formatters&.symbolize_keys)
end

#log_format=(log_format) ⇒ Object



129
130
131
# File 'lib/pact_broker/config/runtime_configuration.rb', line 129

def log_format= log_format
  super(log_format&.to_sym)
end

#log_level=(log_level) ⇒ Object



121
122
123
# File 'lib/pact_broker/config/runtime_configuration.rb', line 121

def log_level= log_level
  super(log_level&.downcase&.to_sym)
end

#log_otel_enabled=(value) ⇒ Object



133
134
135
# File 'lib/pact_broker/config/runtime_configuration.rb', line 133

def log_otel_enabled= value
  super(coerce_log_otel_enabled(value))
end

#log_stream=(log_stream) ⇒ Object



125
126
127
# File 'lib/pact_broker/config/runtime_configuration.rb', line 125

def log_stream= log_stream
  super(log_stream&.to_sym)
end

#main_branch_candidates=(main_branch_candidates) ⇒ Object



191
192
193
# File 'lib/pact_broker/config/runtime_configuration.rb', line 191

def main_branch_candidates= main_branch_candidates
  super(value_to_string_array(main_branch_candidates, "main_branch_candidates"))
end

#original_base_urlObject



145
# File 'lib/pact_broker/config/runtime_configuration.rb', line 145

alias_method :original_base_url, :base_url

#rack_protection_except=(rack_protection_except) ⇒ Object



199
200
201
# File 'lib/pact_broker/config/runtime_configuration.rb', line 199

def rack_protection_except= rack_protection_except
  super(value_to_string_array(rack_protection_except, "rack_protection_except")&.collect(&:to_sym))
end

#rack_protection_use=(rack_protection_use) ⇒ Object



195
196
197
# File 'lib/pact_broker/config/runtime_configuration.rb', line 195

def rack_protection_use= rack_protection_use
  super(value_to_string_array(rack_protection_use, "rack_protection_use")&.collect(&:to_sym))
end

#raise_validation_error(msg) ⇒ Object



229
230
231
# File 'lib/pact_broker/config/runtime_configuration.rb', line 229

def raise_validation_error(msg)
  raise PactBroker::ConfigurationError, msg
end

#semver_formats=(semver_formats) ⇒ Object



167
168
169
# File 'lib/pact_broker/config/runtime_configuration.rb', line 167

def semver_formats= semver_formats
  super(value_to_string_array(semver_formats, "semver_formats"))
end

#set_webhook_attribute_defaultsObject



243
244
245
246
247
248
249
# File 'lib/pact_broker/config/runtime_configuration.rb', line 243

def set_webhook_attribute_defaults
  # can't set a default on this, or anyway config blows up when trying to merge the
  # hash from the env vars into an array/nil.
  if webhook_certificates.nil?
    self.webhook_certificates = []
  end
end

#validate_logging_attributes!Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/pact_broker/config/runtime_configuration.rb', line 214

def validate_logging_attributes!
  valid_log_streams = [:file, :stdout]
  unless valid_log_streams.include?(log_stream)
    raise_validation_error("log_stream must be one of: #{valid_log_streams.join(", ")}")
  end

  if log_stream == :file && log_dir.blank?
    raise_validation_error("Must specify log_dir if log_stream is set to file")
  end

  unless [:auto, true, false].include?(log_otel_enabled)
    raise_validation_error("log_otel_enabled must be one of: auto, true, false")
  end
end

#warning_error_class_names=(warning_error_class_names) ⇒ Object



163
164
165
# File 'lib/pact_broker/config/runtime_configuration.rb', line 163

def warning_error_class_names= warning_error_class_names
  super(value_to_string_array(warning_error_class_names, "warning_error_class_names"))
end

#warning_error_classesObject



203
204
205
206
207
208
209
210
211
212
# File 'lib/pact_broker/config/runtime_configuration.rb', line 203

def warning_error_classes
  warning_error_class_names.collect do | class_name |
    begin
      Object.const_get(class_name)
    rescue NameError => e
      puts("Class #{class_name} couldn't be loaded as a warning error class (#{e.class} - #{e.message}). Ignoring.")
      nil
    end
  end.compact
end

#webhook_host_whitelist=(webhook_host_whitelist) ⇒ Object



187
188
189
# File 'lib/pact_broker/config/runtime_configuration.rb', line 187

def webhook_host_whitelist= webhook_host_whitelist
  super(value_to_string_array(webhook_host_whitelist, "webhook_host_whitelist"))
end

#webhook_http_code_success=(webhook_http_code_success) ⇒ Object



179
180
181
# File 'lib/pact_broker/config/runtime_configuration.rb', line 179

def webhook_http_code_success= webhook_http_code_success
  super(value_to_integer_array(webhook_http_code_success, "webhook_http_code_success"))
end

#webhook_http_method_whitelist=(webhook_http_method_whitelist) ⇒ Object



175
176
177
# File 'lib/pact_broker/config/runtime_configuration.rb', line 175

def webhook_http_method_whitelist= webhook_http_method_whitelist
  super(value_to_string_array(webhook_http_method_whitelist, "webhook_http_method_whitelist"))
end

#webhook_retry_schedule=(webhook_retry_schedule) ⇒ Object



171
172
173
# File 'lib/pact_broker/config/runtime_configuration.rb', line 171

def webhook_retry_schedule= webhook_retry_schedule
  super(value_to_integer_array(webhook_retry_schedule, "webhook_retry_schedule"))
end

#webhook_scheme_whitelist=(webhook_scheme_whitelist) ⇒ Object



183
184
185
# File 'lib/pact_broker/config/runtime_configuration.rb', line 183

def webhook_scheme_whitelist= webhook_scheme_whitelist
  super(value_to_string_array(webhook_scheme_whitelist, "webhook_scheme_whitelist"))
end