Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Set viper config to our own, or this will crash #19

Merged
merged 3 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix golangci errors
  • Loading branch information
chmouel committed Oct 11, 2018
commit 59040f48f817380f63f458e68ac52344fefb4ffb
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ ignored = [
[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"
16 changes: 14 additions & 2 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package configuration

import (
"fmt"
"os"
"strings"
"time"

Expand Down Expand Up @@ -55,13 +56,24 @@ func New(configFilePath string) (*Config, error) {
return &c, nil
}

// Registry encapsulates the Viper configuration registry which stores the
// Config encapsulates the Viper configuration registry which stores the
// configuration data in-memory.

type Config struct {
v *viper.Viper
}

// GetConfig is a wrapper over NewConfigurationData which reads configuration file path
// from the environment variable.
func GetConfig() (*Config, error) {
return New(getMainConfigFile())
}

func getMainConfigFile() string {
// This was either passed as a env var or set inside main.go from --config
envConfigPath, _ := os.LookupEnv("BUILD_CONFIG_FILE_PATH")
return envConfigPath
}

func (c *Config) setConfigDefaults() {
c.v.SetTypeByDefaultValue(true)

Expand Down