pgraph: Move AssociateData function out of the package

This removes another dependency on the resource package.
This commit is contained in:
James Shubin
2017-05-15 10:06:52 -04:00
parent c2cb1c9168
commit 1c59712cbf
2 changed files with 11 additions and 16 deletions

View File

@@ -444,7 +444,7 @@ func (obj *Main) Run() error {
}
newGraph.SetValue("debug", obj.Flags.Debug)
// pass in the information we need
newGraph.AssociateData(&resources.Data{
associateData(newGraph, &resources.Data{
Hostname: hostname,
Converger: converger,
Prometheus: prom,
@@ -625,3 +625,13 @@ func graphMetas(g *pgraph.Graph) []*resources.MetaParams {
}
return metas
}
// associateData associates some data with the object in the graph in question.
func associateData(g *pgraph.Graph, data *resources.Data) {
// prometheus needs to be associated to this graph as well
g.SetValue("prometheus", data.Prometheus)
for _, v := range g.Vertices() {
*v.Res.Data() = *data
}
}