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
94b1d05a
Commit
94b1d05a
authored
Oct 27, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary config struct pointers
parent
b2de7e46
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
43 deletions
+32
-43
cable_test.go
cable_test.go
+4
-5
internal/config/config.go
internal/config/config.go
+20
-24
internal/config/config_test.go
internal/config/config_test.go
+4
-4
internal/imageresizer/image_resizer.go
internal/imageresizer/image_resizer.go
+1
-1
internal/lfs/lfs_test.go
internal/lfs/lfs_test.go
+1
-1
internal/upload/object_storage_preparer.go
internal/upload/object_storage_preparer.go
+1
-7
internal/upload/object_storage_preparer_test.go
internal/upload/object_storage_preparer_test.go
+1
-1
No files found.
cable_test.go
View file @
94b1d05a
...
...
@@ -85,10 +85,9 @@ func newUpstreamWithCableConfig(authBackend string, cableBackend string) *config
}
return
&
config
.
Config
{
Version
:
"123"
,
DocumentRoot
:
testDocumentRoot
,
Backend
:
helper
.
URLMustParse
(
authBackend
),
CableBackend
:
cableBackendURL
,
ImageResizerConfig
:
config
.
DefaultImageResizerConfig
,
Version
:
"123"
,
DocumentRoot
:
testDocumentRoot
,
Backend
:
helper
.
URLMustParse
(
authBackend
),
CableBackend
:
cableBackendURL
,
}
}
internal/config/config.go
View file @
94b1d05a
...
...
@@ -88,26 +88,26 @@ type ImageResizerConfig struct {
}
type
Config
struct
{
Redis
*
RedisConfig
`toml:"redis"`
Backend
*
url
.
URL
`toml:"-"`
CableBackend
*
url
.
URL
`toml:"-"`
Version
string
`toml:"-"`
DocumentRoot
string
`toml:"-"`
DevelopmentMode
bool
`toml:"-"`
Socket
string
`toml:"-"`
CableSocket
string
`toml:"-"`
ProxyHeadersTimeout
time
.
Duration
`toml:"-"`
APILimit
uint
`toml:"-"`
APIQueueLimit
uint
`toml:"-"`
APIQueueTimeout
time
.
Duration
`toml:"-"`
APICILongPollingDuration
time
.
Duration
`toml:"-"`
ObjectStorageConfig
ObjectStorageConfig
`toml:"-"`
ObjectStorageCredentials
*
ObjectStorageCredentials
`toml:"object_storage"`
PropagateCorrelationID
bool
`toml:"-"`
ImageResizerConfig
*
ImageResizerConfig
`toml:"image_resizer"`
}
var
DefaultImageResizerConfig
=
&
ImageResizerConfig
{
Redis
*
RedisConfig
`toml:"redis"`
Backend
*
url
.
URL
`toml:"-"`
CableBackend
*
url
.
URL
`toml:"-"`
Version
string
`toml:"-"`
DocumentRoot
string
`toml:"-"`
DevelopmentMode
bool
`toml:"-"`
Socket
string
`toml:"-"`
CableSocket
string
`toml:"-"`
ProxyHeadersTimeout
time
.
Duration
`toml:"-"`
APILimit
uint
`toml:"-"`
APIQueueLimit
uint
`toml:"-"`
APIQueueTimeout
time
.
Duration
`toml:"-"`
APICILongPollingDuration
time
.
Duration
`toml:"-"`
ObjectStorageConfig
ObjectStorageConfig
`toml:"-"`
ObjectStorageCredentials
ObjectStorageCredentials
`toml:"object_storage"`
PropagateCorrelationID
bool
`toml:"-"`
ImageResizerConfig
ImageResizerConfig
`toml:"image_resizer"`
}
var
DefaultImageResizerConfig
=
ImageResizerConfig
{
MaxScalerProcs
:
uint32
(
math
.
Max
(
2
,
float64
(
runtime
.
NumCPU
())
/
2
)),
MaxFilesize
:
250
*
1000
,
// 250kB,
}
...
...
@@ -126,10 +126,6 @@ func (c *Config) RegisterGoCloudURLOpeners() error {
c
.
ObjectStorageConfig
.
URLMux
=
new
(
blob
.
URLMux
)
creds
:=
c
.
ObjectStorageCredentials
if
creds
==
nil
{
return
nil
}
if
strings
.
EqualFold
(
creds
.
Provider
,
"AzureRM"
)
&&
creds
.
AzureCredentials
.
AccountName
!=
""
&&
creds
.
AzureCredentials
.
AccountKey
!=
""
{
accountName
:=
azureblob
.
AccountName
(
creds
.
AzureCredentials
.
AccountName
)
accountKey
:=
azureblob
.
AccountKey
(
creds
.
AzureCredentials
.
AccountKey
)
...
...
internal/config/config_test.go
View file @
94b1d05a
...
...
@@ -24,7 +24,7 @@ func TestLoadEmptyConfig(t *testing.T) {
require
.
Equal
(
t
,
cfg
.
ImageResizerConfig
.
MaxFilesize
,
uint64
(
250000
))
require
.
GreaterOrEqual
(
t
,
cfg
.
ImageResizerConfig
.
MaxScalerProcs
,
uint32
(
2
))
require
.
Nil
(
t
,
cfg
.
ObjectStorageCredentials
)
require
.
Equal
(
t
,
ObjectStorageCredentials
{}
,
cfg
.
ObjectStorageCredentials
)
require
.
NoError
(
t
,
cfg
.
RegisterGoCloudURLOpeners
())
}
...
...
@@ -51,7 +51,7 @@ aws_secret_access_key = "gdk-minio"
},
}
require
.
Equal
(
t
,
expected
,
*
cfg
.
ObjectStorageCredentials
)
require
.
Equal
(
t
,
expected
,
cfg
.
ObjectStorageCredentials
)
}
func
TestRegisterGoCloudURLOpeners
(
t
*
testing
.
T
)
{
...
...
@@ -68,7 +68,7 @@ func TestRegisterGoCloudURLOpeners(t *testing.T) {
},
}
require
.
Equal
(
t
,
expected
,
*
cfg
.
ObjectStorageCredentials
)
require
.
Equal
(
t
,
expected
,
cfg
.
ObjectStorageCredentials
)
require
.
Nil
(
t
,
cfg
.
ObjectStorageConfig
.
URLMux
)
require
.
NoError
(
t
,
cfg
.
RegisterGoCloudURLOpeners
())
...
...
@@ -95,5 +95,5 @@ max_filesize = 350000
MaxFilesize
:
350000
,
}
require
.
Equal
(
t
,
expected
,
*
cfg
.
ImageResizerConfig
)
require
.
Equal
(
t
,
expected
,
cfg
.
ImageResizerConfig
)
}
internal/imageresizer/image_resizer.go
View file @
94b1d05a
...
...
@@ -255,7 +255,7 @@ func (r *Resizer) unpackParameters(paramsData string) (*resizeParams, error) {
}
// Attempts to rescale the given image data, or in case of errors, falls back to the original image.
func
(
r
*
Resizer
)
tryResizeImage
(
req
*
http
.
Request
,
reader
io
.
Reader
,
errorWriter
io
.
Writer
,
params
*
resizeParams
,
fileSize
int64
,
cfg
*
config
.
ImageResizerConfig
)
(
io
.
Reader
,
*
exec
.
Cmd
,
error
)
{
func
(
r
*
Resizer
)
tryResizeImage
(
req
*
http
.
Request
,
reader
io
.
Reader
,
errorWriter
io
.
Writer
,
params
*
resizeParams
,
fileSize
int64
,
cfg
config
.
ImageResizerConfig
)
(
io
.
Reader
,
*
exec
.
Cmd
,
error
)
{
if
fileSize
>
int64
(
cfg
.
MaxFilesize
)
{
return
reader
,
nil
,
fmt
.
Errorf
(
"ImageResizer: %db exceeds maximum file size of %db"
,
fileSize
,
cfg
.
MaxFilesize
)
}
...
...
internal/lfs/lfs_test.go
View file @
94b1d05a
...
...
@@ -19,7 +19,7 @@ func TestLfsUploadPreparerWithConfig(t *testing.T) {
}
c
:=
config
.
Config
{
ObjectStorageCredentials
:
&
config
.
ObjectStorageCredentials
{
ObjectStorageCredentials
:
config
.
ObjectStorageCredentials
{
Provider
:
"AWS"
,
S3Credentials
:
creds
,
},
...
...
internal/upload/object_storage_preparer.go
View file @
94b1d05a
...
...
@@ -12,13 +12,7 @@ type ObjectStoragePreparer struct {
}
func
NewObjectStoragePreparer
(
c
config
.
Config
)
Preparer
{
creds
:=
c
.
ObjectStorageCredentials
if
creds
==
nil
{
creds
=
&
config
.
ObjectStorageCredentials
{}
}
return
&
ObjectStoragePreparer
{
credentials
:
*
creds
,
config
:
c
.
ObjectStorageConfig
}
return
&
ObjectStoragePreparer
{
credentials
:
c
.
ObjectStorageCredentials
,
config
:
c
.
ObjectStorageConfig
}
}
func
(
p
*
ObjectStoragePreparer
)
Prepare
(
a
*
api
.
Response
)
(
*
filestore
.
SaveFileOpts
,
Verifier
,
error
)
{
...
...
internal/upload/object_storage_preparer_test.go
View file @
94b1d05a
...
...
@@ -19,7 +19,7 @@ func TestPrepareWithS3Config(t *testing.T) {
}
c
:=
config
.
Config
{
ObjectStorageCredentials
:
&
config
.
ObjectStorageCredentials
{
ObjectStorageCredentials
:
config
.
ObjectStorageCredentials
{
Provider
:
"AWS"
,
S3Credentials
:
creds
,
},
...
...
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