Add enablerepos option

This commit is contained in:
kota kanbe
2016-08-08 10:38:46 +09:00
committed by Kota Kanbe
parent e6ec6920ad
commit cd81e6eab2
5 changed files with 58 additions and 19 deletions

View File

@@ -252,6 +252,9 @@ type ServerInfo struct {
// Optional key-value set that will be outputted to JSON
Optional [][]interface{}
// For CentOS, RHEL, Amazon
Enablerepo string
// used internal
LogMsgAnsiColor string // DebugLog Color
Container Container

View File

@@ -20,6 +20,7 @@ package config
import (
"fmt"
"os"
"strings"
"github.com/BurntSushi/toml"
log "github.com/Sirupsen/logrus"
@@ -156,6 +157,23 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
}
}
s.Enablerepo = v.Enablerepo
if len(s.Enablerepo) == 0 {
s.Enablerepo = d.Enablerepo
}
if len(s.Enablerepo) != 0 {
for _, repo := range strings.Split(s.Enablerepo, ",") {
switch repo {
case "base", "updates":
// nop
default:
return fmt.Errorf(
"For now, enablerepo have to be base or updates: %s, servername: %s",
s.Enablerepo, name)
}
}
}
s.LogMsgAnsiColor = Colors[i%len(Colors)]
i++