2022-04-26 13:51:49 +02:00
|
|
|
package main
|
|
|
|
|
2022-05-01 09:36:52 +02:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2022-04-26 13:51:49 +02:00
|
|
|
type Config struct {
|
2022-05-01 09:36:52 +02:00
|
|
|
Method string `json:method`
|
|
|
|
OutputDir string `json:outputdir`
|
|
|
|
BaseImage string `json:baseimage`
|
|
|
|
}
|
|
|
|
|
|
|
|
// loads configuration values from json file
|
|
|
|
func (c *Config) LoadConfigFromFile(filePath string) {
|
|
|
|
file, _ := os.Open("conf.json")
|
|
|
|
defer file.Close()
|
|
|
|
decoder := json.NewDecoder(file)
|
|
|
|
configuration := Config{}
|
|
|
|
err := decoder.Decode(&configuration)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("error:", err)
|
|
|
|
}
|
|
|
|
fmt.Println(configuration.Method)
|
|
|
|
fmt.Println(configuration.OutputDir)
|
2022-04-26 13:51:49 +02:00
|
|
|
}
|
|
|
|
|
2022-05-01 09:36:52 +02:00
|
|
|
// global register to acccess configuration values
|
2022-04-26 13:51:49 +02:00
|
|
|
var ConfigRegister Config
|