refactoring: move logic in different files
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval

This commit is contained in:
Simon Vieille 2024-07-31 12:38:34 +02:00
commit 098b04f5a5
Signed by: deblan
GPG key ID: 579388D585F70417
5 changed files with 108 additions and 49 deletions

29
config.go Normal file
View file

@ -0,0 +1,29 @@
package main
import (
"os"
"gopkg.in/yaml.v3"
)
type Config struct {
Default string `yaml:"default"`
Workspaces map[string]string `yaml:"workspaces"`
}
func LoadConfiguration(file string) (Config, error) {
data, err := os.ReadFile(os.Args[1])
config := Config{}
if err != nil {
return config, err
}
err = yaml.Unmarshal(data, &config)
if err != nil {
return config, err
}
return config, nil
}