Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a69be90a
Commit
a69be90a
authored
Jun 12, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add explicit licensing for Elasticsearch
parent
77531aa1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
56 deletions
+104
-56
app/models/application_setting.rb
app/models/application_setting.rb
+10
-0
app/models/license.rb
app/models/license.rb
+5
-1
app/views/admin/application_settings/_elasticsearch_form.html.haml
.../admin/application_settings/_elasticsearch_form.html.haml
+56
-55
changelogs/unreleased-ee/2581-elastic-license-checks.yml
changelogs/unreleased-ee/2581-elastic-license-checks.yml
+4
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+29
-0
No files found.
app/models/application_setting.rb
View file @
a69be90a
...
...
@@ -276,6 +276,16 @@ class ApplicationSetting < ActiveRecord::Base
end
end
def
elasticsearch_indexing
License
.
feature_available?
(
:elastic_search
)
&&
super
end
alias_method
:elasticsearch_indexing?
,
:elasticsearch_indexing
def
elasticsearch_search
License
.
feature_available?
(
:elastic_search
)
&&
super
end
alias_method
:elasticsearch_search?
,
:elasticsearch_search
def
elasticsearch_url
read_attribute
(
:elasticsearch_url
).
split
(
','
).
map
(
&
:strip
)
end
...
...
app/models/license.rb
View file @
a69be90a
...
...
@@ -7,12 +7,14 @@ class License < ActiveRecord::Base
AUDITOR_USER_FEATURE
=
'GitLab_Auditor_User'
.
freeze
SERVICE_DESK_FEATURE
=
'GitLab_ServiceDesk'
.
freeze
OBJECT_STORAGE_FEATURE
=
'GitLab_ObjectStorage'
.
freeze
ELASTIC_SEARCH_FEATURE
=
'GitLab_ElasticSearch'
.
freeze
FEATURE_CODES
=
{
geo:
GEO_FEATURE
,
auditor_user:
AUDITOR_USER_FEATURE
,
service_desk:
SERVICE_DESK_FEATURE
,
object_storage:
OBJECT_STORAGE_FEATURE
,
elastic_search:
ELASTIC_SEARCH_FEATURE
,
# Features that make sense to Namespace:
deploy_board:
DEPLOY_BOARD_FEATURE
,
file_lock:
FILE_LOCK_FEATURE
...
...
@@ -24,7 +26,7 @@ class License < ActiveRecord::Base
EARLY_ADOPTER_PLAN
=
'early_adopter'
.
freeze
EES_FEATURES
=
[
# ..
{
ELASTIC_SEARCH_FEATURE
=>
1
}
].
freeze
EEP_FEATURES
=
[
...
...
@@ -91,6 +93,8 @@ class License < ActiveRecord::Base
end
end
delegate
:feature_available?
,
to: :current
,
allow_nil:
true
def
reset_current
RequestStore
.
delete
(
:current_license
)
end
...
...
app/views/admin/application_settings/_elasticsearch_form.html.haml
View file @
a69be90a
%fieldset
-
if
License
.
feature_available?
(
:elastic_search
)
%fieldset
%legend
Elasticsearch
.form-group
.col-sm-offset-2.col-sm-10
...
...
@@ -31,7 +32,7 @@
.help-block
The url to use for connecting to Elasticsearch. Use a comma-separated list to support clustering (e.g., "http://localhost:9200, http://localhost:9201").
%fieldset
%fieldset
%legend
Elasticsearch AWS IAM credentials
.form-group
.col-sm-offset-2.col-sm-10
...
...
changelogs/unreleased-ee/2581-elastic-license-checks.yml
0 → 100644
View file @
a69be90a
---
title
:
Add explicit licensing for Elasticsearch
merge_request
:
2108
author
:
spec/models/application_setting_spec.rb
View file @
a69be90a
...
...
@@ -303,6 +303,35 @@ describe ApplicationSetting, models: true do
end
end
describe
'elasticsearch licensing'
do
before
do
setting
.
elasticsearch_search
=
true
setting
.
elasticsearch_indexing
=
true
end
def
expect_is_es_licensed
expect
(
License
).
to
receive
(
:feature_available?
).
with
(
:elastic_search
).
at_least
(
:once
)
end
it
'disables elasticsearch when unlicensed'
do
expect_is_es_licensed
.
and_return
(
false
)
expect
(
setting
.
elasticsearch_indexing?
).
to
be_falsy
expect
(
setting
.
elasticsearch_indexing
).
to
be_falsy
expect
(
setting
.
elasticsearch_search?
).
to
be_falsy
expect
(
setting
.
elasticsearch_search
).
to
be_falsy
end
it
'enables elasticsearch when licensed'
do
expect_is_es_licensed
.
and_return
(
true
)
expect
(
setting
.
elasticsearch_indexing?
).
to
be_truthy
expect
(
setting
.
elasticsearch_indexing
).
to
be_truthy
expect
(
setting
.
elasticsearch_search?
).
to
be_truthy
expect
(
setting
.
elasticsearch_search
).
to
be_truthy
end
end
describe
'#elasticsearch_url'
do
it
'presents a single URL as a one-element array'
do
setting
.
elasticsearch_url
=
'http://example.com'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment