~blu/artemis

34b9b6654c7f674347c0c64653462890afad16fc — Bryant Conquest 1 year, 4 months ago a85d1ff
use config file
1 files changed, 14 insertions(+), 0 deletions(-)

M config/config.go
M config/config.go => config/config.go +14 -0
@@ 1,9 1,13 @@
package config

import (
	"os"

	"github.com/BurntSushi/toml"
)

// PREFERS to use environmental variables
// ARTEMIS_APP_ID & ARTEMIS_KEY_SECRET
type b2 struct {
	AppID     string `toml:"app_id"`
	KeySecret string `toml:"key_secret"`


@@ 22,5 26,15 @@ func Load(path string) (*Config, error) {
	var config Config

	_, err := toml.DecodeFile(path, &config)
	if err != nil {
		return &config, err
	}

	config.B2.AppID = os.Getenv("ARTEMIS_APP_ID")
	config.B2.KeySecret = os.Getenv("ARTEMIS_KEY_SECRET")

	if config.Cache.Pattern == "" {
		config.Cache.Pattern = "artemis-*"
	}
	return &config, err
}