pgraph: Clean up pgraph module to get ready for clean lib status
The graph of dependencies in golang is a DAG, and as such doesn't allow cycles. Clean up this lib so that it eventually doesn't import our resources module or anything else which might want to import it. This patch makes adjacency private, and adds a generalized key store to the graph struct.
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/purpleidea/mgmt/pgraph"
|
||||
"github.com/purpleidea/mgmt/resources"
|
||||
|
||||
errwrap "github.com/pkg/errors"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@@ -95,8 +96,12 @@ func (c *GraphConfig) Parse(data []byte) error {
|
||||
func (c *GraphConfig) NewGraphFromConfig(hostname string, world resources.World, noop bool) (*pgraph.Graph, error) {
|
||||
// hostname is the uuid for the host
|
||||
|
||||
var graph *pgraph.Graph // new graph to return
|
||||
graph = pgraph.NewGraph("Graph") // give graph a default name
|
||||
var graph *pgraph.Graph // new graph to return
|
||||
var err error
|
||||
graph, err = pgraph.NewGraph("Graph") // give graph a default name
|
||||
if err != nil {
|
||||
return nil, errwrap.Wrapf(err, "could not run NewGraphFromConfig() properly")
|
||||
}
|
||||
|
||||
var lookup = make(map[string]map[string]*pgraph.Vertex)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user