2021-10-29 18:55:33 +00:00
|
|
|
package main
|
|
|
|
|
2021-10-29 20:13:39 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
2021-10-29 18:55:33 +00:00
|
|
|
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repo) FullURL() string {
|
|
|
|
return strings.TrimSuffix(r.URL, "/") + "/" + r.Repo
|
|
|
|
}
|
|
|
|
|
|
|
|
type Workstreams struct {
|
|
|
|
OnlyIfTouching []string `yaml:"onlyIfTouching"`
|
|
|
|
NeverModify []string `yaml:"neverModify"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type sites struct {
|
|
|
|
Upstream Repo
|
|
|
|
Downstream Repo
|
|
|
|
}
|
|
|
|
|
|
|
|
type configFormat struct {
|
|
|
|
Sites sites `yaml:"sites"`
|
|
|
|
Workstreams map[string]Workstreams `yaml:"workstreams"`
|
|
|
|
}
|
2021-10-29 20:13:39 +00:00
|
|
|
|
|
|
|
func readConfig(configFile string) *configFormat {
|
|
|
|
file, err := os.Open(configFile)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not open '%s': %s", configFile, err))
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
cfg := new(configFormat)
|
|
|
|
|
|
|
|
configDecoder := yaml.NewDecoder(file)
|
|
|
|
err = configDecoder.Decode(&cfg)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Failed parsing '%s': %s", configFile, err))
|
|
|
|
}
|
|
|
|
|
|
|
|
return cfg
|
|
|
|
}
|