Commit 3c546acf authored by Sean McGivern's avatar Sean McGivern

Allow disabling usage ping in `gitlab.yml`

Setting `usage_ping_enabled` to false in `gitlab.yml`:

1. Disables the usage ping, regardless of the value stored in the database.
2. Prevents the usage ping from being enabled through the admin panel. It can
   only be enabled by either removing the line from `gitlab.yml` and configuring
   through the admin panel, or setting it to true in `gitlab.yml`.
parent 4067dd4f
......@@ -246,7 +246,7 @@ class ApplicationSetting < ActiveRecord::Base
two_factor_grace_period: 48,
user_default_external: false,
polling_interval_multiplier: 1,
usage_ping_enabled: true
usage_ping_enabled: Settings.gitlab['usage_ping_enabled']
}
end
......@@ -349,6 +349,14 @@ class ApplicationSetting < ActiveRecord::Base
sidekiq_throttling_enabled
end
def usage_ping_can_be_configured?
Settings.gitlab.usage_ping_enabled
end
def usage_ping_enabled
usage_ping_can_be_configured? && super
end
private
def ensure_uuid!
......
......@@ -502,17 +502,24 @@
Let GitLab inform you when an update is available.
.form-group
.col-sm-offset-2.col-sm-10
- can_be_configured = @application_setting.usage_ping_can_be_configured?
.checkbox
= f.label :usage_ping_enabled do
= f.check_box :usage_ping_enabled
= f.check_box :usage_ping_enabled, disabled: !can_be_configured
Usage ping enabled
= link_to icon('question-circle'), help_page_path("user/admin_area/settings/usage_statistics", anchor: "usage-data")
= link_to icon('question-circle'), help_page_path("user/admin_area/settings/usage_statistics", anchor: "usage-ping")
.help-block
Every week GitLab will report license usage back to GitLab, Inc.
Disable this option if you do not want this to occur. To see the
JSON payload that will be sent, visit the
= succeed '.' do
= link_to "Cohorts page", admin_cohorts_path(anchor: 'usage-ping')
- if can_be_configured
Every week GitLab will report license usage back to GitLab, Inc.
Disable this option if you do not want this to occur. To see the
JSON payload that will be sent, visit the
= succeed '.' do
= link_to "Cohorts page", admin_cohorts_path(anchor: 'usage-ping')
- else
The usage ping is disabled, and cannot be configured through this
form. For more information, see the documentation on
= succeed '.' do
= link_to 'deactivating the usage ping', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'deactivate-the-usage-ping')
%fieldset
%legend Email
......
---
title: Allow usage ping to be disabled completely in gitlab.yml
merge_request:
author:
......@@ -241,6 +241,7 @@ Settings.gitlab['domain_whitelist'] ||= []
Settings.gitlab['import_sources'] ||= %w[github bitbucket gitlab google_code fogbugz git gitlab_project gitea]
Settings.gitlab['trusted_proxies'] ||= []
Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml'))
Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil?
#
# CI
......
......@@ -89,6 +89,24 @@ By default, usage ping is opt-out. If you want to deactivate this feature, go to
the Settings page of your administration panel and uncheck the Usage ping
checkbox.
To disable the usage ping and prevent it from being configured from the
administration panel, Omnibus installs can set the following in
[`gitlab.rb`](https://docs.gitlab.com/omnibus/settings/configuration.html#configuration-options):
```ruby
gitlab_rails['usage_ping_enabled'] = false
```
And source installs can set the following in `gitlab.yml`:
```yaml
production: &base
# ...
gitlab:
# ...
usage_ping_enabled: false
```
## Privacy policy
GitLab Inc. does **not** collect any sensitive information, like project names
......
......@@ -211,4 +211,66 @@ describe ApplicationSetting, models: true do
expect(setting.domain_blacklist).to contain_exactly('example.com', 'test.com', 'foo.bar')
end
end
describe 'usage ping settings' do
context 'when the usage ping is disabled in gitlab.yml' do
before do
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false)
end
it 'does not allow the usage ping to be configured' do
expect(setting.usage_ping_can_be_configured?).to be_falsey
end
context 'when the usage ping is disabled in the DB' do
before do
setting.usage_ping_enabled = false
end
it 'returns false for usage_ping_enabled' do
expect(setting.usage_ping_enabled).to be_falsey
end
end
context 'when the usage ping is enabled in the DB' do
before do
setting.usage_ping_enabled = true
end
it 'returns false for usage_ping_enabled' do
expect(setting.usage_ping_enabled).to be_falsey
end
end
end
context 'when the usage ping is enabled in gitlab.yml' do
before do
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true)
end
it 'allows the usage ping to be configured' do
expect(setting.usage_ping_can_be_configured?).to be_truthy
end
context 'when the usage ping is disabled in the DB' do
before do
setting.usage_ping_enabled = false
end
it 'returns false for usage_ping_enabled' do
expect(setting.usage_ping_enabled).to be_falsey
end
end
context 'when the usage ping is enabled in the DB' do
before do
setting.usage_ping_enabled = true
end
it 'returns true for usage_ping_enabled' do
expect(setting.usage_ping_enabled).to be_truthy
end
end
end
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