package main
// Base Repository "class"
type RepositoryInfo struct {
Name string
Path string
}
type Repository interface {
GetName() string
GetPath() string
GetFile(id string) []byte
GetFileExists(id string) bool
}
Repository
package main
import (
"encoding/json"
"log"
"io/ioutil"
)
var Repos []Repository
// Loads the configuration file. The configuration file is assumed to
// be a json file. Currently just loads all repositories with their
// corresponding file paths. It also reads in the SCM type, which
// I intend to identify through the program in the future without
// needing it to be specified in the config
func LoadConfig() {
const CONF_PATH = "config.json"
type JsonRepo struct {
Name string
Path string
Scm string
}
type Configuration struct {
Repositories []JsonRepo
}
var conf Configuration
content, err := ioutil.ReadFile(CONF_PATH)
if err != nil {
log.Fatal("ReadFile: ", err)
}
if json.Unmarshal(content, &conf) != nil {
log.Fatal("Unmarshal: ", err)
}
for _, r := range conf.Repositories {
switch r.Scm {
// to implement more later.. for now it's just git
Util
This change has been discarded.
Opening a new review request that points at rb-gateway