Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalasankar "Balu" C <balasankarc@autistici.org>2021-03-01 08:58:34 +0300
committerBalasankar "Balu" C <balasankarc@autistici.org>2021-03-01 08:58:34 +0300
commit2e9503fff8dfbc34399264e28a0738eab565fe9d (patch)
tree48cee9ef470699df0f28df0b9a7ca726887f252f /internal
parentf8a1639beb6cbaf2f63f42ba362be4a4c9294a97 (diff)
Use actual structs in Config struct instead of pointers to them
Signed-off-by: Balasankar "Balu" C <balasankarc@autistici.org>
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config.go40
-rw-r--r--internal/serving/disk/zip/serving_test.go2
-rw-r--r--internal/vfs/zip/archive_test.go12
-rw-r--r--internal/vfs/zip/vfs_test.go12
4 files changed, 33 insertions, 33 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 5696b12a..7e44abbc 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -16,16 +16,16 @@ import (
// Config stores all the config options relevant to GitLab Pages.
type Config struct {
- General *General
- ArtifactsServer *ArtifactsServer
- Authentication *Auth
- Daemon *Daemon
- GitLab *GitLab
- Listeners *Listeners
- Log *Log
- Sentry *Sentry
- TLS *TLS
- Zip *ZipServing
+ General General
+ ArtifactsServer ArtifactsServer
+ Authentication Auth
+ Daemon Daemon
+ GitLab GitLab
+ Listeners Listeners
+ Log Log
+ Sentry Sentry
+ TLS TLS
+ Zip ZipServing
// Fields used to share information between files. These are not directly
// set by command line flags, but rather populated based on info from them.
@@ -257,7 +257,7 @@ func (config Config) DomainConfigSource() string {
func loadConfig() *Config {
config := &Config{
- General: &General{
+ General: General{
Domain: strings.ToLower(*pagesDomain),
DomainConfigurationSource: *domainConfigSource,
HTTP2: *useHTTP2,
@@ -272,39 +272,39 @@ func loadConfig() *Config {
CustomHeaders: header.Split(),
ShowVersion: *showVersion,
},
- GitLab: &GitLab{
+ GitLab: GitLab{
ClientHTTPTimeout: *gitlabClientHTTPTimeout,
JWTTokenExpiration: *gitlabClientJWTExpiry,
},
- ArtifactsServer: &ArtifactsServer{
+ ArtifactsServer: ArtifactsServer{
TimeoutSeconds: *artifactsServerTimeout,
URL: *artifactsServer,
},
- Authentication: &Auth{
+ Authentication: Auth{
Secret: *secret,
ClientID: *clientID,
ClientSecret: *clientSecret,
RedirectURI: *redirectURI,
Scope: *authScope,
},
- Daemon: &Daemon{
+ Daemon: Daemon{
UID: *daemonUID,
GID: *daemonGID,
InplaceChroot: *daemonInplaceChroot,
},
- Log: &Log{
+ Log: Log{
Format: *logFormat,
Verbose: *logVerbose,
},
- Sentry: &Sentry{
+ Sentry: Sentry{
DSN: *sentryDSN,
Environment: *sentryEnvironment,
},
- TLS: &TLS{
+ TLS: TLS{
MinVersion: tlsconfig.AllTLSVersions[*tlsMinVersion],
MaxVersion: tlsconfig.AllTLSVersions[*tlsMaxVersion],
},
- Zip: &ZipServing{
+ Zip: ZipServing{
ExpirationInterval: *zipCacheExpiration,
CleanupInterval: *zipCacheCleanup,
RefreshInterval: *zipCacheRefresh,
@@ -318,7 +318,7 @@ func loadConfig() *Config {
ListenHTTPSStrings: listenHTTPS,
ListenProxyStrings: listenProxy,
ListenHTTPSProxyv2Strings: listenHTTPSProxyv2,
- Listeners: &Listeners{},
+ Listeners: Listeners{},
}
// Populating remaining General settings
diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go
index 249dae1f..2cbee18d 100644
--- a/internal/serving/disk/zip/serving_test.go
+++ b/internal/serving/disk/zip/serving_test.go
@@ -86,7 +86,7 @@ func TestZip_ServeFileHTTP(t *testing.T) {
}
cfg := &config.Config{
- Zip: &config.ZipServing{
+ Zip: config.ZipServing{
ExpirationInterval: 10 * time.Second,
CleanupInterval: 5 * time.Second,
RefreshInterval: 5 * time.Second,
diff --git a/internal/vfs/zip/archive_test.go b/internal/vfs/zip/archive_test.go
index 421990db..23fe0583 100644
--- a/internal/vfs/zip/archive_test.go
+++ b/internal/vfs/zip/archive_test.go
@@ -24,7 +24,7 @@ import (
var (
chdirSet = false
- zipCfg = &config.ZipServing{
+ zipCfg = config.ZipServing{
ExpirationInterval: 10 * time.Second,
CleanupInterval: 5 * time.Second,
RefreshInterval: 5 * time.Second,
@@ -91,7 +91,7 @@ func TestOpenCached(t *testing.T) {
testServerURL, cleanup := newZipFileServerURL(t, "group/zip.gitlab.io/public-without-dirs.zip", &requests)
defer cleanup()
- fs := New(zipCfg)
+ fs := New(&zipCfg)
// We use array instead of map to ensure
// predictable ordering of test execution
@@ -342,7 +342,7 @@ func TestArchiveCanBeReadAfterOpenCtxCanceled(t *testing.T) {
testServerURL, cleanup := newZipFileServerURL(t, "group/zip.gitlab.io/public.zip", nil)
defer cleanup()
- fs := New(zipCfg).(*zipVFS)
+ fs := New(&zipCfg).(*zipVFS)
zip := newArchive(fs, time.Second)
ctx, cancel := context.WithCancel(context.Background())
cancel()
@@ -365,7 +365,7 @@ func TestReadArchiveFails(t *testing.T) {
testServerURL, cleanup := newZipFileServerURL(t, "group/zip.gitlab.io/public.zip", nil)
defer cleanup()
- fs := New(zipCfg).(*zipVFS)
+ fs := New(&zipCfg).(*zipVFS)
zip := newArchive(fs, time.Second)
err := zip.openArchive(context.Background(), testServerURL+"/unkown.html")
@@ -390,7 +390,7 @@ func openZipArchive(t *testing.T, requests *int64, fromDisk bool) (*zipArchive,
zipCfg.AllowedPaths = []string{wd}
- fs := New(zipCfg).(*zipVFS)
+ fs := New(&zipCfg).(*zipVFS)
err = fs.Reconfigure(&config.Config{Zip: zipCfg})
require.NoError(t, err)
@@ -466,7 +466,7 @@ func benchmarkArchiveRead(b *testing.B, size int64) {
ts := httptest.NewServer(m)
defer ts.Close()
- fs := New(zipCfg).(*zipVFS)
+ fs := New(&zipCfg).(*zipVFS)
b.ReportAllocs()
b.ResetTimer()
diff --git a/internal/vfs/zip/vfs_test.go b/internal/vfs/zip/vfs_test.go
index 5d7015f5..22cc5c6b 100644
--- a/internal/vfs/zip/vfs_test.go
+++ b/internal/vfs/zip/vfs_test.go
@@ -38,7 +38,7 @@ func TestVFSRoot(t *testing.T) {
},
}
- vfs := New(zipCfg)
+ vfs := New(&zipCfg)
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
@@ -76,7 +76,7 @@ func TestVFSFindOrOpenArchiveConcurrentAccess(t *testing.T) {
path := testServerURL + "/public.zip"
- vfs := New(zipCfg).(*zipVFS)
+ vfs := New(&zipCfg).(*zipVFS)
root, err := vfs.Root(context.Background(), path)
require.NoError(t, err)
@@ -161,7 +161,7 @@ func TestVFSFindOrOpenArchiveRefresh(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
withExpectedArchiveCount(t, 1, func(t *testing.T) {
- cfg := *zipCfg
+ cfg := *&zipCfg
cfg.ExpirationInterval = test.expirationInterval
cfg.RefreshInterval = test.refreshInterval
@@ -223,7 +223,7 @@ func TestVFSReconfigureTransport(t *testing.T) {
fileURL := testhelpers.ToFileProtocol(t, "group/zip.gitlab.io/public.zip")
- vfs := New(zipCfg)
+ vfs := New(&zipCfg)
// try to open a file URL without registering the file protocol
_, err := vfs.Root(context.Background(), fileURL)
@@ -231,10 +231,10 @@ func TestVFSReconfigureTransport(t *testing.T) {
require.Contains(t, err.Error(), "unsupported protocol scheme \"file\"")
// reconfigure VFS with allowed paths and try to open file://
- cfg := *zipCfg
+ cfg := zipCfg
cfg.AllowedPaths = []string{testhelpers.Getwd(t)}
- err = vfs.Reconfigure(&config.Config{Zip: &cfg})
+ err = vfs.Reconfigure(&config.Config{Zip: cfg})
require.NoError(t, err)
root, err := vfs.Root(context.Background(), fileURL)