diff --git a/lib/main.go b/lib/main.go index 584320a2..a41d8e2a 100644 --- a/lib/main.go +++ b/lib/main.go @@ -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 + } +} diff --git a/pgraph/pgraph.go b/pgraph/pgraph.go index 1956c025..adacc5d9 100644 --- a/pgraph/pgraph.go +++ b/pgraph/pgraph.go @@ -24,7 +24,6 @@ import ( "sync" "github.com/purpleidea/mgmt/event" - "github.com/purpleidea/mgmt/prometheus" "github.com/purpleidea/mgmt/resources" errwrap "github.com/pkg/errors" @@ -58,8 +57,6 @@ type Graph struct { fastPause bool // used to disable pokes for a fast pause mutex *sync.Mutex // used when modifying graph State variable wg *sync.WaitGroup - - prometheus *prometheus.Prometheus // the prometheus instance } // Vertex is the primary vertex struct in this library. @@ -151,8 +148,6 @@ func (g *Graph) Copy() *Graph { mutex: g.mutex, wg: g.wg, fastPause: g.fastPause, - - prometheus: g.prometheus, } for k, v := range g.adjacency { newGraph.adjacency[k] = v // copy @@ -687,16 +682,6 @@ func (g *Graph) GraphSync(oldGraph *Graph) (*Graph, error) { return oldGraph, nil } -// AssociateData associates some data with the object in the graph in question. -func (g *Graph) AssociateData(data *resources.Data) { - // prometheus needs to be associated to this graph as well - g.prometheus = data.Prometheus - - for k := range g.adjacency { - *k.Res.Data() = *data - } -} - // VertexContains is an "in array" function to test for a vertex in a slice of vertices. func VertexContains(needle *Vertex, haystack []*Vertex) bool { for _, v := range haystack {