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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
eea26a93
Commit
eea26a93
authored
Jun 04, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update validator
parent
b8370c9f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
39 deletions
+22
-39
config/initializers/direct_upload_support.rb
config/initializers/direct_upload_support.rb
+15
-9
lib/object_storage/direct_upload.rb
lib/object_storage/direct_upload.rb
+1
-1
spec/initializers/direct_upload_support_spec.rb
spec/initializers/direct_upload_support_spec.rb
+4
-3
spec/lib/object_storage/direct_upload_spec.rb
spec/lib/object_storage/direct_upload_spec.rb
+0
-24
spec/support/helpers/stub_object_storage.rb
spec/support/helpers/stub_object_storage.rb
+2
-2
No files found.
config/initializers/direct_upload_support.rb
View file @
eea26a93
SUPPORTED_DIRECT_UPLOAD_PROVIDERS
=
%w(Google AWS)
.
freeze
class
DirectUploadsValidator
SUPPORTED_DIRECT_UPLOAD_PROVIDERS
=
%w(Google AWS)
.
freeze
def
verify_provider_support!
(
object_store
)
ValidationError
=
Class
.
new
(
StandardError
)
def
verify!
(
object_store
)
return
unless
object_store
.
enabled
return
unless
object_store
.
enabled
return
unless
object_store
.
direct_upload
return
unless
object_store
.
direct_upload
return
if
SUPPORTED_DIRECT_UPLOAD_PROVIDERS
.
include?
(
object_store
.
connection
&
.
provider
.
to_s
)
return
if
SUPPORTED_DIRECT_UPLOAD_PROVIDERS
.
include?
(
object_store
.
connection
&
.
provider
.
to_s
)
raise
"Only
#{
SUPPORTED_DIRECT_UPLOAD_PROVIDERS
.
join
(
','
)
}
are supported as a object storage provider when 'direct_upload' is used"
raise
ValidationError
,
"Only
#{
SUPPORTED_DIRECT_UPLOAD_PROVIDERS
.
join
(
','
)
}
are supported as a object storage provider when 'direct_upload' is used"
end
end
end
verify_provider_support!
(
Gitlab
.
config
.
artifacts
.
object_store
)
DirectUploadsValidator
.
new
.
tap
do
|
validator
|
verify_provider_support!
(
Gitlab
.
config
.
uploads
.
object_store
)
[
Gitlab
.
config
.
artifacts
,
Gitlab
.
config
.
uploads
,
Gitlab
.
config
.
lfs
].
each
do
|
uploader
|
verify_provider_support!
(
Gitlab
.
config
.
lfs
.
object_store
)
validator
.
verify!
(
uploader
.
object_store
)
end
end
lib/object_storage/direct_upload.rb
View file @
eea26a93
spec/initializers/direct_upload_support_spec.rb
View file @
eea26a93
...
@@ -6,7 +6,7 @@ describe 'Direct upload support' do
...
@@ -6,7 +6,7 @@ describe 'Direct upload support' do
end
end
where
(
:config_name
)
do
where
(
:config_name
)
do
[
'lfs'
,
'artifacts'
,
'uploads'
]
%w(lfs artifacts uploads)
end
end
with_them
do
with_them
do
...
@@ -23,8 +23,9 @@ describe 'Direct upload support' do
...
@@ -23,8 +23,9 @@ describe 'Direct upload support' do
end
end
before
do
before
do
allow
(
Gitlab
.
config
).
to
receive_messages
(
to_settings
(
allow
(
Gitlab
.
config
).
to
receive_messages
(
to_settings
(
config_name
=>
{
config_name
=>
{
object_store:
object_store
}))
object_store:
object_store
}))
end
end
context
'when object storage is enabled'
do
context
'when object storage is enabled'
do
...
...
spec/lib/object_storage/direct_upload_spec.rb
View file @
eea26a93
...
@@ -161,28 +161,4 @@ describe ObjectStorage::DirectUpload do
...
@@ -161,28 +161,4 @@ describe ObjectStorage::DirectUpload do
end
end
end
end
end
end
describe
'#get_url'
do
# this method can only be tested with integration tests
end
describe
'#delete_url'
do
# this method can only be tested with integration tests
end
describe
'#store_url'
do
# this method can only be tested with integration tests
end
describe
'#multipart_part_upload_url'
do
# this method can only be tested with integration tests
end
describe
'#multipart_complete_url'
do
# this method can only be tested with integration tests
end
describe
'#multipart_abort_url'
do
# this method can only be tested with integration tests
end
end
end
spec/support/helpers/stub_object_storage.rb
View file @
eea26a93
...
@@ -47,8 +47,8 @@ module StubObjectStorage
...
@@ -47,8 +47,8 @@ module StubObjectStorage
end
end
def
stub_object_storage_multipart_init
(
endpoint
,
upload_id
=
"upload_id"
)
def
stub_object_storage_multipart_init
(
endpoint
,
upload_id
=
"upload_id"
)
stub_request
(
:post
,
%r{
\A
#{
endpoint
}
tmp/uploads/[a-z0-9-]*
\?
uploads
\z
}
)
.
stub_request
(
:post
,
%r{
\A
#{
endpoint
}
tmp/uploads/[a-z0-9-]*
\?
uploads
\z
}
)
to_return
status:
200
,
body:
<<-
EOS
.
strip_heredoc
.
to_return
status:
200
,
body:
<<-
EOS
.
strip_heredoc
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<InitiateMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<InitiateMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Bucket>example-bucket</Bucket>
<Bucket>example-bucket</Bucket>
...
...
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