diff --git a/gapi/gapi.go b/gapi/gapi.go index 94fce41c..d2c2efb0 100644 --- a/gapi/gapi.go +++ b/gapi/gapi.go @@ -23,24 +23,10 @@ import ( "github.com/purpleidea/mgmt/resources" ) -// World is an interface to the rest of the different graph state. It allows -// the GAPI to store state and exchange information throughout the cluster. It -// is the interface each machine uses to communicate with the rest of the world. -type World interface { // TODO: is there a better name for this interface? - ResExport([]resources.Res) error - // FIXME: should this method take a "filter" data struct instead of many args? - ResCollect(hostnameFilter, kindFilter []string) ([]resources.Res, error) - - StrWatch(namespace string) chan error - StrGet(namespace string) (map[string]string, error) - StrSet(namespace, value string) error - StrDel(namespace string) error -} - // Data is the set of input values passed into the GAPI structs via Init. type Data struct { Hostname string // uuid for the host, required for GAPI - World World + World resources.World Noop bool NoWatch bool // NOTE: we can add more fields here if needed by GAPI endpoints diff --git a/lib/main.go b/lib/main.go index 7c624fe8..778fe6c4 100644 --- a/lib/main.go +++ b/lib/main.go @@ -443,6 +443,7 @@ func (obj *Main) Run() error { Hostname: hostname, Converger: converger, Prometheus: prom, + World: world, Prefix: pgraphPrefix, Debug: obj.Flags.Debug, }) diff --git a/resources/resources.go b/resources/resources.go index 84c39108..05293e29 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -56,12 +56,27 @@ const ( const refreshPathToken = "refresh" +// World is an interface to the rest of the different graph state. It allows +// the GAPI to store state and exchange information throughout the cluster. It +// is the interface each machine uses to communicate with the rest of the world. +type World interface { // TODO: is there a better name for this interface? + ResExport([]Res) error + // FIXME: should this method take a "filter" data struct instead of many args? + ResCollect(hostnameFilter, kindFilter []string) ([]Res, error) + + StrWatch(namespace string) chan error + StrGet(namespace string) (map[string]string, error) + StrSet(namespace, value string) error + StrDel(namespace string) error +} + // Data is the set of input values passed into the pgraph for the resources. type Data struct { Hostname string // uuid for the host //Noop bool Converger converger.Converger Prometheus *prometheus.Prometheus + World World Prefix string // the prefix to be used for the pgraph namespace Debug bool // NOTE: we can add more fields here if needed for the resources. diff --git a/yamlgraph/gconfig.go b/yamlgraph/gconfig.go index efa16290..95e55674 100644 --- a/yamlgraph/gconfig.go +++ b/yamlgraph/gconfig.go @@ -26,7 +26,6 @@ import ( "reflect" "strings" - "github.com/purpleidea/mgmt/gapi" "github.com/purpleidea/mgmt/pgraph" "github.com/purpleidea/mgmt/resources" "github.com/purpleidea/mgmt/util" @@ -93,7 +92,7 @@ func (c *GraphConfig) Parse(data []byte) error { // NewGraphFromConfig transforms a GraphConfig struct into a new graph. // FIXME: remove any possibly left over, now obsolete graph diff code from here! -func (c *GraphConfig) NewGraphFromConfig(hostname string, world gapi.World, noop bool) (*pgraph.Graph, 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