mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
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:
committed by
Aaron Schlesinger
parent
79ef098804
commit
d9e0df8643
@@ -2,6 +2,9 @@
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# Defaults to "go"
|
||||
# Env override: GO_BINARY_PATH
|
||||
|
||||
+15
-5
@@ -13,6 +13,8 @@ import (
|
||||
validator "gopkg.in/go-playground/validator.v9"
|
||||
)
|
||||
|
||||
const defaultConfigFile = "athens.toml"
|
||||
|
||||
// Config provides configuration values for all components
|
||||
type Config struct {
|
||||
TimeoutConf
|
||||
@@ -47,14 +49,22 @@ type Config struct {
|
||||
// Load loads the config from a file.
|
||||
// If file is not present returns default config
|
||||
func Load(configFile string) (*Config, error) {
|
||||
if configFile == "" {
|
||||
log.Print("config file not provided - using default settings")
|
||||
return createDefault(), nil
|
||||
}
|
||||
// User explicitly specified a config file
|
||||
if configFile != "" {
|
||||
return ParseConfigFile(configFile)
|
||||
}
|
||||
|
||||
func createDefault() *Config {
|
||||
// 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 defaultConfig() *Config {
|
||||
return &Config{
|
||||
GoBinary: "go",
|
||||
GoEnv: "development",
|
||||
|
||||
@@ -413,7 +413,7 @@ func TestDefaultConfigMatchesConfigFile(t *testing.T) {
|
||||
t.Errorf("Unable to parse example config file: %+v", err)
|
||||
}
|
||||
|
||||
defConf := createDefault()
|
||||
defConf := defaultConfig()
|
||||
|
||||
ignoreStorageOpts := cmpopts.IgnoreTypes(&StorageConfig{})
|
||||
ignoreGoEnvOpts := cmpopts.IgnoreFields(Config{}, "GoEnv")
|
||||
|
||||
Reference in New Issue
Block a user