Commit 941941ed authored by Stan Hu's avatar Stan Hu

Fix nil pointer exception when no object storage config is defined

This is a regression that was caused if the `[object_storage]` config
section were omitted.
parent 76ebf63b
---
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