Skip to content
Snippets Groups Projects
Commit caf3329a authored by DJ Mountney's avatar DJ Mountney
Browse files

Fix an issue were the incoming email secret file was not being created

- Ensure defaults are properly evaluated for incoming_email
  parse_secrets

Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6991

Changelog: fixed
parent 9a39753f
No related branches found
No related tags found
1 merge request!82CI/CD: do not build for MRs
......@@ -25,7 +25,7 @@
# mailroom expects exactly 32 bytes, encoded with base64
# rubocop:disable Style/IfUnlessModifier,Style/GuardClause
if Gitlab['gitlab_rails']['incoming_email_enabled'] && Gitlab['gitlab_rails']['incoming_email_delivery_method'] == "webhook"
if rails_user_config_or_default('incoming_email_enabled') && rails_user_config_or_default('incoming_email_delivery_method') == "webhook"
Gitlab['mailroom']['incoming_email_auth_token'] ||= Gitlab['gitlab_rails']['incoming_email_auth_token'] || SecretsHelper.generate_base64(32)
end
......@@ -29,7 +29,7 @@
Gitlab['mailroom']['incoming_email_auth_token'] ||= Gitlab['gitlab_rails']['incoming_email_auth_token'] || SecretsHelper.generate_base64(32)
end
if Gitlab['gitlab_rails']['service_desk_email_enabled'] && Gitlab['gitlab_rails']['service_desk_email_delivery_method'] == "webhook"
if rails_user_config_or_default('service_desk_email_enabled') && rails_user_config_or_default('service_desk_email_delivery_method') == "webhook"
Gitlab['mailroom']['service_desk_email_auth_token'] ||= Gitlab['gitlab_rails']['service_desk_email_auth_token'] || SecretsHelper.generate_base64(32)
end
# rubocop:enable Style/IfUnlessModifier,Style/GuardClause
......@@ -46,5 +46,21 @@
Gitlab['mailroom']['enable'] = true if Gitlab['mailroom']['enable'].nil?
end
private
def default_rails_config
Gitlab['node']['gitlab']['gitlab-rails']
end
def user_rails_config
Gitlab['gitlab_rails']
end
def rails_user_config_or_default(key)
# Note that we must not use an `a || b`` truthiness check here since that would mean a `false`
# user setting would fail over to the default, which is not what we want.
user_rails_config[key].nil? ? default_rails_config[key] : user_rails_config[key]
end
end
end
......@@ -304,8 +304,8 @@
)
end
it 'sets the default mailroom delivery method to webhook' do
it 'sets the default mailroom delivery method to webhook and renders the secret file' do
node = chef_run.node
expect(node['gitlab']['gitlab-rails']['incoming_email_delivery_method']).to eql('webhook')
expect(node['gitlab']['gitlab-rails']['service_desk_email_delivery_method']).to eql('webhook')
......@@ -308,7 +308,9 @@
node = chef_run.node
expect(node['gitlab']['gitlab-rails']['incoming_email_delivery_method']).to eql('webhook')
expect(node['gitlab']['gitlab-rails']['service_desk_email_delivery_method']).to eql('webhook')
expect(chef_run).to create_templatesymlink('Create a gitlab_incoming_email_secret and create a symlink to Rails root')
expect(chef_run).to create_templatesymlink('Create a gitlab_service_desk_email_secret and create a symlink to Rails root')
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment