pgraph: Move GraphMetas function out of package

This removes a dependency on the resources package which wasn't
necessary.
This commit is contained in:
James Shubin
2017-05-15 10:02:04 -04:00
parent cc8e2e40dd
commit c2cb1c9168
2 changed files with 12 additions and 12 deletions

View File

@@ -453,7 +453,7 @@ func (obj *Main) Run() error {
Debug: obj.Flags.Debug, Debug: obj.Flags.Debug,
}) })
for _, m := range newGraph.GraphMetas() { for _, m := range graphMetas(newGraph) {
// apply the global noop parameter if requested // apply the global noop parameter if requested
if obj.Noop { if obj.Noop {
m.Noop = obj.Noop m.Noop = obj.Noop
@@ -614,3 +614,14 @@ func (obj *Main) Run() error {
log.Println("Goodbye!") log.Println("Goodbye!")
return reterr return reterr
} }
// graphMetas returns a list of pointers to each of the resource MetaParams.
func graphMetas(g *pgraph.Graph) []*resources.MetaParams {
metas := []*resources.MetaParams{}
for _, v := range g.Vertices() { // loop through the vertices (resources)
res := v.Res // resource
meta := res.Meta()
metas = append(metas, meta)
}
return metas
}

View File

@@ -687,17 +687,6 @@ func (g *Graph) GraphSync(oldGraph *Graph) (*Graph, error) {
return oldGraph, nil return oldGraph, nil
} }
// GraphMetas returns a list of pointers to each of the resource MetaParams.
func (g *Graph) GraphMetas() []*resources.MetaParams {
metas := []*resources.MetaParams{}
for v := range g.adjacency { // loop through the vertices (resources))
res := v.Res // resource
meta := res.Meta()
metas = append(metas, meta)
}
return metas
}
// AssociateData associates some data with the object in the graph in question. // AssociateData associates some data with the object in the graph in question.
func (g *Graph) AssociateData(data *resources.Data) { func (g *Graph) AssociateData(data *resources.Data) {
// prometheus needs to be associated to this graph as well // prometheus needs to be associated to this graph as well