gerritcp/gerritcp.go
Patrick Georgi 65c9d16717 Add initial code
Enough to read and dump the config file
2021-10-29 20:21:25 +02:00

50 lines
1.1 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"gopkg.in/yaml.v2"
)
type Repo struct {
Url string `yaml:"url"`
Repo string `yaml:"repo"`
Branch string `yaml:"branch"`
Authentication string `yaml:"authentication"`
CookieName string `yaml:"cookieName"`
CookieValue string `yaml:"cookieValue"`
}
type Workstreams struct {
OnlyIfTouching []string `yaml:"onlyIfTouching"`
NeverModify []string `yaml:"neverModify"`
}
type configFormat struct {
Sites map[string]Repo `yaml:"sites"`
Workstreams map[string]Workstreams `yaml:"workstreams"`
}
func main() {
// dir := flag.String("dir", "repo", "path to local git repo")
configFile := flag.String("config", "config.yaml", "path to configuration")
flag.Parse()
file, err := os.Open(*configFile)
if err != nil {
panic(fmt.Sprintf("Could not open '%s': %s", *configFile, err))
}
defer file.Close()
config := new(configFormat)
configDecoder := yaml.NewDecoder(file)
err = configDecoder.Decode(&config)
if err != nil {
panic(fmt.Sprintf("Failed parsing '%s': %s", *configFile, err))
}
fmt.Println(config)
}