Config improvements - rename file & remove default (#1103)

* Rename config.dev.toml to config-example.toml

* Updating helm docs to point to the new helm chart repository (#1102)

* Updating helm docs to point to the new helm chart repository

Fixes https://github.com/gomods/athens/issues/1099
Follow-up to https://github.com/gomods/athens/pull/1097/files

* fixes

* Helm chart: Fix ingress setup (#1086)

* Helm chart: Fix ingress setup

The ingress part of the Helm chart contained references to
not-existing templates and values. Additionally, the deployment used
some no longer available health-check URLs which prevented it from
being marked as ready.

* Make readiness and liveness paths depend on the image.tag

* Add read from .athens.toml (from pwd, then home)

* Remove config lookup from HOME

* Revert "Rename config.dev.toml to config-example.toml"

This reverts commit 9c02956406.

* Fix comment
This commit is contained in:
Pontus Leitzler
2019-03-26 21:56:18 +01:00
committed by Aaron Schlesinger
parent 79ef098804
commit d9e0df8643
3 changed files with 19 additions and 6 deletions
+3
View File
@@ -2,6 +2,9 @@
# Most properties can be overridden with environment variables specified in this file # Most properties can be overridden with environment variables specified in this file
# Most properties also have defaults (mentioned in this file) if they are not set in either the config file or the corresponding environment variable # Most properties also have defaults (mentioned in this file) if they are not set in either the config file or the corresponding environment variable
# If you put this file where you start Athens from as "athens.toml", athens will use it when starting.
# You can also start athens with -config_file as command line argument to point out a config file.
# GoBinary returns the path to the go binary to use. This value can be a name of a binary in your PATH, or the full path # GoBinary returns the path to the go binary to use. This value can be a name of a binary in your PATH, or the full path
# Defaults to "go" # Defaults to "go"
# Env override: GO_BINARY_PATH # Env override: GO_BINARY_PATH
+15 -5
View File
@@ -13,6 +13,8 @@ import (
validator "gopkg.in/go-playground/validator.v9" validator "gopkg.in/go-playground/validator.v9"
) )
const defaultConfigFile = "athens.toml"
// Config provides configuration values for all components // Config provides configuration values for all components
type Config struct { type Config struct {
TimeoutConf TimeoutConf
@@ -47,14 +49,22 @@ type Config struct {
// Load loads the config from a file. // Load loads the config from a file.
// If file is not present returns default config // If file is not present returns default config
func Load(configFile string) (*Config, error) { func Load(configFile string) (*Config, error) {
if configFile == "" { // User explicitly specified a config file
log.Print("config file not provided - using default settings") if configFile != "" {
return createDefault(), nil return ParseConfigFile(configFile)
} }
return ParseConfigFile(configFile)
// There is a config in the current directory
if fi, err := os.Stat(defaultConfigFile); err == nil {
return ParseConfigFile(fi.Name())
}
// Use default values
log.Println("Running dev mode with default settings, consult config when you're ready to run in production")
return defaultConfig(), nil
} }
func createDefault() *Config { func defaultConfig() *Config {
return &Config{ return &Config{
GoBinary: "go", GoBinary: "go",
GoEnv: "development", GoEnv: "development",
+1 -1
View File
@@ -413,7 +413,7 @@ func TestDefaultConfigMatchesConfigFile(t *testing.T) {
t.Errorf("Unable to parse example config file: %+v", err) t.Errorf("Unable to parse example config file: %+v", err)
} }
defConf := createDefault() defConf := defaultConfig()
ignoreStorageOpts := cmpopts.IgnoreTypes(&StorageConfig{}) ignoreStorageOpts := cmpopts.IgnoreTypes(&StorageConfig{})
ignoreGoEnvOpts := cmpopts.IgnoreFields(Config{}, "GoEnv") ignoreGoEnvOpts := cmpopts.IgnoreFields(Config{}, "GoEnv")