Commit 64b93372 authored by Stan Hu's avatar Stan Hu

Merge branch '204839-dont-raise-in-rake-task' into 'master'

Skip configure rake task if container registry is misconfigured

See merge request gitlab-org/gitlab!33631
parents b74a158a 2e9b88c1
......@@ -2,10 +2,15 @@ namespace :gitlab do
namespace :container_registry do
desc "GitLab | Container Registry | Configure"
task configure: :gitlab_environment do
configure
end
def configure
registry_config = Gitlab.config.registry
unless registry_config.enabled && registry_config.api_url.presence
raise 'Registry is not enabled or registry api url is not present.'
puts "Registry is not enabled or registry api url is not present.".color(:yellow)
return
end
warn_user_is_not_gitlab
......
......@@ -16,10 +16,21 @@ describe 'gitlab:container_registry namespace rake tasks' do
stub_container_registry_config(enabled: true, api_url: api_url)
end
subject { run_rake_task('gitlab:container_registry:configure') }
shared_examples 'invalid config' do
it 'does not update the application settings' do
expect { run_rake_task('gitlab:container_registry:configure') }
.to raise_error(/Registry is not enabled or registry api url is not present./)
expect(application_settings).not_to receive(:update!)
subject
end
it 'does not raise an error' do
expect { subject }.not_to raise_error
end
it 'prints a warning message' do
expect { subject }.to output(/Registry is not enabled or registry api url is not present./).to_stdout
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment