lib: examples: Update to most recent API

At some point in the past the API changed. Fixed now.
This commit is contained in:
James Shubin
2017-04-10 03:09:00 -04:00
parent 525a1e8140
commit 66d9c7091c
4 changed files with 12 additions and 18 deletions

View File

@@ -57,9 +57,11 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) {
return nil, fmt.Errorf("libmgmt: MyGAPI is not initialized") return nil, fmt.Errorf("libmgmt: MyGAPI is not initialized")
} }
n1, err := resources.NewNoopRes("noop1") n1 := &resources.NoopRes{
if err != nil { BaseRes: resources.BaseRes{
return nil, fmt.Errorf("can't create resource: %v", err) Name: "noop1",
MetaParams: resources.DefaultMetaParams,
},
} }
// we can still build a graph via the yaml method // we can still build a graph via the yaml method

View File

@@ -62,9 +62,11 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) {
g := pgraph.NewGraph(obj.Name) g := pgraph.NewGraph(obj.Name)
var vertex *pgraph.Vertex var vertex *pgraph.Vertex
for i := uint(0); i < obj.Count; i++ { for i := uint(0); i < obj.Count; i++ {
n, err := resources.NewNoopRes(fmt.Sprintf("noop%d", i)) n := &resources.NoopRes{
if err != nil { BaseRes: resources.BaseRes{
return nil, fmt.Errorf("can't create resource: %v", err) Name: fmt.Sprintf("noop%d", i),
MetaParams: resources.DefaultMetaParams,
},
} }
v := pgraph.NewVertex(n) v := pgraph.NewVertex(n)
g.AddVertex(v) g.AddVertex(v)

View File

@@ -14,8 +14,6 @@ import (
mgmt "github.com/purpleidea/mgmt/lib" mgmt "github.com/purpleidea/mgmt/lib"
"github.com/purpleidea/mgmt/pgraph" "github.com/purpleidea/mgmt/pgraph"
"github.com/purpleidea/mgmt/resources" "github.com/purpleidea/mgmt/resources"
"golang.org/x/time/rate"
) )
// MyGAPI implements the main GAPI interface. // MyGAPI implements the main GAPI interface.
@@ -61,10 +59,7 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) {
g := pgraph.NewGraph(obj.Name) g := pgraph.NewGraph(obj.Name)
// FIXME: these are being specified temporarily until it's the default! // FIXME: these are being specified temporarily until it's the default!
metaparams := resources.MetaParams{ metaparams := resources.DefaultMetaParams
Limit: rate.Inf,
Burst: 0,
}
content := "Delete me to trigger a notification!\n" content := "Delete me to trigger a notification!\n"
f0 := &resources.FileRes{ f0 := &resources.FileRes{

View File

@@ -13,8 +13,6 @@ import (
mgmt "github.com/purpleidea/mgmt/lib" mgmt "github.com/purpleidea/mgmt/lib"
"github.com/purpleidea/mgmt/pgraph" "github.com/purpleidea/mgmt/pgraph"
"github.com/purpleidea/mgmt/resources" "github.com/purpleidea/mgmt/resources"
"golang.org/x/time/rate"
) )
// MyGAPI implements the main GAPI interface. // MyGAPI implements the main GAPI interface.
@@ -58,10 +56,7 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) {
return nil, fmt.Errorf("%s: MyGAPI is not initialized", obj.Name) return nil, fmt.Errorf("%s: MyGAPI is not initialized", obj.Name)
} }
// FIXME: these are being specified temporarily until it's the default! // FIXME: these are being specified temporarily until it's the default!
metaparams := resources.MetaParams{ metaparams := resources.DefaultMetaParams
Limit: rate.Inf,
Burst: 0,
}
g := pgraph.NewGraph(obj.Name) g := pgraph.NewGraph(obj.Name)
n0 := &resources.NoopRes{ n0 := &resources.NoopRes{