Commit 0f19719c authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-fix-nil-object-storage-creds' into 'master'

Fix nil pointer exception when no object storage config is defined

See merge request gitlab-org/gitlab-workhorse!565
parents 76ebf63b 941941ed
---
title: Fix nil pointer exception when no object storage config is defined
merge_request: 565
author:
type: fixed
......@@ -111,7 +111,11 @@ func LoadConfig(filename string) (*Config, error) {
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)
......
......@@ -8,6 +8,18 @@ import (
"github.com/stretchr/testify/require"
)
func TestLoadEmptyConfig(t *testing.T) {
config := ``
tmpFile, cfg := loadTempConfig(t, config)
defer os.Remove(tmpFile.Name())
require.Nil(t, cfg.ObjectStorageCredentials)
err := cfg.RegisterGoCloudURLOpeners()
require.NoError(t, err)
}
func TestLoadObjectStorageConfig(t *testing.T) {
config := `
[object_storage]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment