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
50864fd7
Commit
50864fd7
authored
Aug 25, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use switch statement instead of long if-else
parent
652d2c9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
internal/filestore/file_handler.go
internal/filestore/file_handler.go
+30
-7
No files found.
internal/filestore/file_handler.go
View file @
50864fd7
...
@@ -119,7 +119,8 @@ func SaveFileFromReader(ctx context.Context, reader io.Reader, size int64, opts
...
@@ -119,7 +119,8 @@ func SaveFileFromReader(ctx context.Context, reader io.Reader, size int64, opts
var
clientMode
string
var
clientMode
string
if
opts
.
IsRemote
()
{
if
opts
.
IsRemote
()
{
if
opts
.
UseWorkhorseClientEnabled
()
&&
opts
.
ObjectStorageConfig
.
IsGoCloud
()
{
switch
{
case
opts
.
UseWorkhorseClientEnabled
()
&&
opts
.
ObjectStorageConfig
.
IsGoCloud
()
:
clientMode
=
fmt
.
Sprintf
(
"go_cloud:%s"
,
opts
.
ObjectStorageConfig
.
Provider
)
clientMode
=
fmt
.
Sprintf
(
"go_cloud:%s"
,
opts
.
ObjectStorageConfig
.
Provider
)
p
:=
&
objectstore
.
GoCloudObjectParams
{
p
:=
&
objectstore
.
GoCloudObjectParams
{
Ctx
:
ctx
,
Ctx
:
ctx
,
...
@@ -129,15 +130,37 @@ func SaveFileFromReader(ctx context.Context, reader io.Reader, size int64, opts
...
@@ -129,15 +130,37 @@ func SaveFileFromReader(ctx context.Context, reader io.Reader, size int64, opts
Deadline
:
opts
.
Deadline
,
Deadline
:
opts
.
Deadline
,
}
}
remoteWriter
,
err
=
objectstore
.
NewGoCloudObject
(
p
)
remoteWriter
,
err
=
objectstore
.
NewGoCloudObject
(
p
)
}
else
if
opts
.
UseWorkhorseClientEnabled
()
&&
opts
.
ObjectStorageConfig
.
IsAWS
()
&&
opts
.
ObjectStorageConfig
.
IsValid
()
{
case
opts
.
UseWorkhorseClientEnabled
()
&&
opts
.
ObjectStorageConfig
.
IsAWS
()
&&
opts
.
ObjectStorageConfig
.
IsValid
()
:
clientMode
=
"s3"
clientMode
=
"s3"
remoteWriter
,
err
=
objectstore
.
NewS3Object
(
ctx
,
opts
.
RemoteTempObjectID
,
opts
.
ObjectStorageConfig
.
S3Credentials
,
opts
.
ObjectStorageConfig
.
S3Config
,
opts
.
Deadline
)
remoteWriter
,
err
=
objectstore
.
NewS3Object
(
}
else
if
opts
.
IsMultipart
()
{
ctx
,
opts
.
RemoteTempObjectID
,
opts
.
ObjectStorageConfig
.
S3Credentials
,
opts
.
ObjectStorageConfig
.
S3Config
,
opts
.
Deadline
,
)
case
opts
.
IsMultipart
()
:
clientMode
=
"multipart"
clientMode
=
"multipart"
remoteWriter
,
err
=
objectstore
.
NewMultipart
(
ctx
,
opts
.
PresignedParts
,
opts
.
PresignedCompleteMultipart
,
opts
.
PresignedAbortMultipart
,
opts
.
PresignedDelete
,
opts
.
PutHeaders
,
opts
.
Deadline
,
opts
.
PartSize
)
remoteWriter
,
err
=
objectstore
.
NewMultipart
(
}
else
{
ctx
,
opts
.
PresignedParts
,
opts
.
PresignedCompleteMultipart
,
opts
.
PresignedAbortMultipart
,
opts
.
PresignedDelete
,
opts
.
PutHeaders
,
opts
.
Deadline
,
opts
.
PartSize
,
)
default
:
clientMode
=
"http"
clientMode
=
"http"
remoteWriter
,
err
=
objectstore
.
NewObject
(
ctx
,
opts
.
PresignedPut
,
opts
.
PresignedDelete
,
opts
.
PutHeaders
,
opts
.
Deadline
,
size
)
remoteWriter
,
err
=
objectstore
.
NewObject
(
ctx
,
opts
.
PresignedPut
,
opts
.
PresignedDelete
,
opts
.
PutHeaders
,
opts
.
Deadline
,
size
,
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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