api: Add Groups and GroupConfig with Requirements and Labels

* Add Group definitions to associate attribute matchers to particular
Spec specifications to supercede use of machine.json files
This commit is contained in:
Dalton Hubble
2016-01-07 14:17:28 -08:00
parent 64420c12b6
commit dae760e5bd
6 changed files with 192 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"flag"
"io/ioutil"
"net/http"
"net/url"
"os"
@@ -17,6 +18,7 @@ var log = capnslog.NewPackageLogger("github.com/coreos/coreos-baremetal/cmd/boot
func main() {
flags := flag.NewFlagSet("bootcfg", flag.ExitOnError)
address := flags.String("address", "127.0.0.1:8080", "HTTP listen address")
configPath := flags.String("config", "", "Path to config file")
dataPath := flags.String("data-path", "./data", "Path to data directory")
imagesPath := flags.String("images-path", "./images", "Path to static assets")
// available log levels https://godoc.org/github.com/coreos/pkg/capnslog#LogLevel
@@ -44,13 +46,28 @@ func main() {
// logging setup
lvl, err := capnslog.ParseLevel(strings.ToUpper(*logLevel))
if err != nil {
log.Fatalf("Invalid log-level: %s", err.Error())
log.Fatalf("Invalid log-level: %v", err.Error())
}
capnslog.SetGlobalLogLevel(lvl)
capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, false))
// storage
store := api.NewFileStore(http.Dir(*dataPath))
// bootstrap a group config
if *configPath != "" {
data, err := ioutil.ReadFile(*configPath)
if err != nil {
log.Fatalf("error reading config file: %v", err)
}
_, err = api.ParseGroupConfig(data)
if err != nil {
log.Fatalf("error parsing group config: %v", err)
}
}
config := &api.Config{
Store: api.NewFileStore(http.Dir(*dataPath)),
Store: store,
ImagePath: *imagesPath,
}