yamlgraph: Refactor parsing for dynamic resource registration

Avoid use of the reflect package, and use an extensible list of registred
resource kinds. This also has the benefit of removing the empty VirtRes and
AugeasRes struct types when compiling without libvirt and libaugeas.
This commit is contained in:
Mildred Ki'Lya
2017-03-24 22:38:06 +01:00
parent 64dc47d7e9
commit 525a1e8140
17 changed files with 474 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import (
"github.com/purpleidea/mgmt/puppet"
"github.com/purpleidea/mgmt/yamlgraph"
"github.com/purpleidea/mgmt/yamlgraph2"
"github.com/urfave/cli"
)
@@ -71,6 +72,14 @@ func run(c *cli.Context) error {
File: &y,
}
}
if y := c.String("yaml2"); c.IsSet("yaml2") {
if obj.GAPI != nil {
return fmt.Errorf("can't combine YAMLv2 GAPI with existing GAPI")
}
obj.GAPI = &yamlgraph2.GAPI{
File: &y,
}
}
if p := c.String("puppet"); c.IsSet("puppet") {
if obj.GAPI != nil {
return fmt.Errorf("can't combine puppet GAPI with existing GAPI")
@@ -205,6 +214,11 @@ func CLI(program, version string, flags Flags) error {
Value: "",
Usage: "yaml graph definition to run",
},
cli.StringFlag{
Name: "yaml2",
Value: "",
Usage: "yaml graph definition to run (parser v2)",
},
cli.StringFlag{
Name: "puppet, p",
Value: "",