diff options
| author | xengineering <me@xengineering.eu> | 2024-05-12 00:12:55 +0200 | 
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2024-05-12 00:12:55 +0200 | 
| commit | 642fed1cbf5160c89a93deab810bd44fb49d2a4a (patch) | |
| tree | a676ee90aef8f67640af6ce49792782de33b3165 | |
| parent | 938ab103727688b73f2d7b3ef4d9e1b1c85c6628 (diff) | |
| download | ceres-642fed1cbf5160c89a93deab810bd44fb49d2a4a.tar ceres-642fed1cbf5160c89a93deab810bd44fb49d2a4a.tar.zst ceres-642fed1cbf5160c89a93deab810bd44fb49d2a4a.zip | |
Move config path from config to flags struct
This is metadata about the config and thus does not belong to the config
itself. Moving it to the struct holding flag values is straight forward
since it is defined by flags.
| -rw-r--r-- | config.go | 5 | ||||
| -rw-r--r-- | flags.go | 7 | ||||
| -rw-r--r-- | main.go | 4 | 
3 files changed, 8 insertions, 8 deletions
| @@ -11,7 +11,6 @@ import (  var defaultConfig string  type CeresConfig struct { -	Path            string  	HttpAddress     string `json:"http_address"`  	StorageFilePath string `json:"storage_file_path"`  } @@ -25,8 +24,8 @@ func init() {  	}  } -func (c *CeresConfig) Read() { -	data, err := os.ReadFile(c.Path) +func (c *CeresConfig) Read(path string) { +	data, err := os.ReadFile(path)  	if err != nil {  		log.Fatal(err)  	} @@ -17,7 +17,8 @@ Usage: ceres [-h | --help] [-v | --version] [-c | --config]  `  var flags struct { -	version   bool +	version  bool +	config   string  	examples bool  } @@ -25,8 +26,8 @@ func init() {  	flag.BoolVar(&flags.version, "version", false, "print version information")  	flag.BoolVar(&flags.version, "v",       false, "print version information") -	flag.StringVar(&config.Path, "config", "", "file path to configuration file") -	flag.StringVar(&config.Path, "c",      "", "file path to configuration file") +	flag.StringVar(&flags.config, "config", "", "file path to configuration file") +	flag.StringVar(&flags.config, "c",      "", "file path to configuration file")  	flag.BoolVar(&flags.examples, "examples", false, "inject example recipes on startup")  	flag.BoolVar(&flags.examples, "e",        false, "inject example recipes on startup") @@ -24,8 +24,8 @@ func main() {  	defer log.Println("Ceres recipe server stopped")  	log.Printf("Version: %s", version) -	if config.Path != "" { -		config.Read() +	if flags.config != "" { +		config.Read(flags.config)  	}  	storage := model.NewStorage(config.StorageFilePath) | 
