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
b27f9848
Commit
b27f9848
authored
Jun 06, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add license checks for object storage feature
parent
2a5cafe0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
2 deletions
+61
-2
app/models/license.rb
app/models/license.rb
+6
-2
app/uploaders/object_store_uploader.rb
app/uploaders/object_store_uploader.rb
+8
-0
spec/support/stub_artifacts.rb
spec/support/stub_artifacts.rb
+2
-0
spec/uploaders/object_store_uploader_spec.rb
spec/uploaders/object_store_uploader_spec.rb
+45
-0
No files found.
app/models/license.rb
View file @
b27f9848
...
@@ -6,11 +6,13 @@ class License < ActiveRecord::Base
...
@@ -6,11 +6,13 @@ class License < ActiveRecord::Base
GEO_FEATURE
=
'GitLab_Geo'
.
freeze
GEO_FEATURE
=
'GitLab_Geo'
.
freeze
AUDITOR_USER_FEATURE
=
'GitLab_Auditor_User'
.
freeze
AUDITOR_USER_FEATURE
=
'GitLab_Auditor_User'
.
freeze
SERVICE_DESK_FEATURE
=
'GitLab_ServiceDesk'
.
freeze
SERVICE_DESK_FEATURE
=
'GitLab_ServiceDesk'
.
freeze
OBJECT_STORAGE_FEATURE
=
'GitLab_ObjectStorage'
.
freeze
FEATURE_CODES
=
{
FEATURE_CODES
=
{
geo:
GEO_FEATURE
,
geo:
GEO_FEATURE
,
auditor_user:
AUDITOR_USER_FEATURE
,
auditor_user:
AUDITOR_USER_FEATURE
,
service_desk:
SERVICE_DESK_FEATURE
,
service_desk:
SERVICE_DESK_FEATURE
,
object_storage:
OBJECT_STORAGE_FEATURE
,
# Features that make sense to Namespace:
# Features that make sense to Namespace:
deploy_board:
DEPLOY_BOARD_FEATURE
,
deploy_board:
DEPLOY_BOARD_FEATURE
,
file_lock:
FILE_LOCK_FEATURE
file_lock:
FILE_LOCK_FEATURE
...
@@ -31,7 +33,8 @@ class License < ActiveRecord::Base
...
@@ -31,7 +33,8 @@ class License < ActiveRecord::Base
{
FILE_LOCK_FEATURE
=>
1
},
{
FILE_LOCK_FEATURE
=>
1
},
{
GEO_FEATURE
=>
1
},
{
GEO_FEATURE
=>
1
},
{
AUDITOR_USER_FEATURE
=>
1
},
{
AUDITOR_USER_FEATURE
=>
1
},
{
SERVICE_DESK_FEATURE
=>
1
}
{
SERVICE_DESK_FEATURE
=>
1
},
{
OBJECT_STORAGE_FEATURE
=>
1
}
].
freeze
].
freeze
EEU_FEATURES
=
[
EEU_FEATURES
=
[
...
@@ -52,7 +55,8 @@ class License < ActiveRecord::Base
...
@@ -52,7 +55,8 @@ class License < ActiveRecord::Base
{
FILE_LOCK_FEATURE
=>
1
},
{
FILE_LOCK_FEATURE
=>
1
},
{
GEO_FEATURE
=>
1
},
{
GEO_FEATURE
=>
1
},
{
AUDITOR_USER_FEATURE
=>
1
},
{
AUDITOR_USER_FEATURE
=>
1
},
{
SERVICE_DESK_FEATURE
=>
1
}
{
SERVICE_DESK_FEATURE
=>
1
},
{
OBJECT_STORAGE_FEATURE
=>
1
}
].
freeze
].
freeze
FEATURES_BY_PLAN
=
{
FEATURES_BY_PLAN
=
{
...
...
app/uploaders/object_store_uploader.rb
View file @
b27f9848
...
@@ -3,6 +3,7 @@ require 'carrierwave/storage/fog'
...
@@ -3,6 +3,7 @@ require 'carrierwave/storage/fog'
class
ObjectStoreUploader
<
GitlabUploader
class
ObjectStoreUploader
<
GitlabUploader
before
:store
,
:set_default_local_store
before
:store
,
:set_default_local_store
before
:store
,
:verify_license!
LOCAL_STORE
=
1
LOCAL_STORE
=
1
REMOTE_STORE
=
2
REMOTE_STORE
=
2
...
@@ -104,6 +105,13 @@ class ObjectStoreUploader < GitlabUploader
...
@@ -104,6 +105,13 @@ class ObjectStoreUploader < GitlabUploader
file
.
try
(
:storage
)
==
cache_storage
file
.
try
(
:storage
)
==
cache_storage
end
end
# We block storing artifacts on Object Storage, not receiving
def
verify_license!
(
new_file
)
return
if
file_storage?
raise
'Object Storage feature is missing'
unless
subject
.
project
.
feature_available?
(
:object_storage
)
end
private
private
def
set_default_local_store
(
new_file
)
def
set_default_local_store
(
new_file
)
...
...
spec/support/stub_artifacts.rb
View file @
b27f9848
...
@@ -12,6 +12,8 @@ module StubConfiguration
...
@@ -12,6 +12,8 @@ module StubConfiguration
}
}
)
)
allow_any_instance_of
(
ArtifactUploader
).
to
receive
(
:verify_license!
)
{
true
}
::
Fog
::
Storage
.
new
(
Gitlab
.
config
.
artifacts
.
object_store
.
connection
).
tap
do
|
connection
|
::
Fog
::
Storage
.
new
(
Gitlab
.
config
.
artifacts
.
object_store
.
connection
).
tap
do
|
connection
|
begin
begin
connection
.
directories
.
create
(
key:
'artifacts'
)
connection
.
directories
.
create
(
key:
'artifacts'
)
...
...
spec/uploaders/object_store_uploader_spec.rb
View file @
b27f9848
...
@@ -186,4 +186,49 @@ describe ObjectStoreUploader do
...
@@ -186,4 +186,49 @@ describe ObjectStoreUploader do
it
{
is_expected
.
to
eq
(
false
)
}
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'#verify_license!'
do
subject
{
uploader
.
verify_license!
(
nil
)
}
context
'when using local storage'
do
before
do
expect
(
object
).
to
receive
(
:artifacts_file_store
)
{
described_class
::
LOCAL_STORE
}
end
it
"does not raise an error"
do
expect
{
subject
}.
not_to
raise_error
end
end
context
'when using remote storage'
do
let
(
:project
)
{
double
}
before
do
uploader_class
.
storage_options
double
(
object_store:
double
(
enabled:
true
))
expect
(
object
).
to
receive
(
:artifacts_file_store
)
{
described_class
::
REMOTE_STORE
}
expect
(
object
).
to
receive
(
:project
)
{
project
}
end
context
'feature is not available'
do
before
do
expect
(
project
).
to
receive
(
:feature_available?
).
with
(
:object_storage
)
{
false
}
end
it
"does raise an error"
do
expect
{
subject
}.
to
raise_error
(
/Object Storage feature is missing/
)
end
end
context
'feature is available'
do
before
do
expect
(
project
).
to
receive
(
:feature_available?
).
with
(
:object_storage
)
{
true
}
end
it
"does not raise an error"
do
expect
{
subject
}.
not_to
raise_error
end
end
end
end
end
end
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