From 66d9c7091c7e397a8e904b494c7e2165ac25e3b8 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 10 Apr 2017 03:09:00 -0400 Subject: [PATCH] lib: examples: Update to most recent API At some point in the past the API changed. Fixed now. --- examples/lib/libmgmt1.go | 8 +++++--- examples/lib/libmgmt2.go | 8 +++++--- examples/lib/libmgmt3.go | 7 +------ test/shell/libmgmt-change1.go | 7 +------ 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/examples/lib/libmgmt1.go b/examples/lib/libmgmt1.go index 45fa13ae..510bb7ac 100644 --- a/examples/lib/libmgmt1.go +++ b/examples/lib/libmgmt1.go @@ -57,9 +57,11 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { return nil, fmt.Errorf("libmgmt: MyGAPI is not initialized") } - n1, err := resources.NewNoopRes("noop1") - if err != nil { - return nil, fmt.Errorf("can't create resource: %v", err) + n1 := &resources.NoopRes{ + BaseRes: resources.BaseRes{ + Name: "noop1", + MetaParams: resources.DefaultMetaParams, + }, } // we can still build a graph via the yaml method diff --git a/examples/lib/libmgmt2.go b/examples/lib/libmgmt2.go index 90ba1018..9d815846 100644 --- a/examples/lib/libmgmt2.go +++ b/examples/lib/libmgmt2.go @@ -62,9 +62,11 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { g := pgraph.NewGraph(obj.Name) var vertex *pgraph.Vertex for i := uint(0); i < obj.Count; i++ { - n, err := resources.NewNoopRes(fmt.Sprintf("noop%d", i)) - if err != nil { - return nil, fmt.Errorf("can't create resource: %v", err) + n := &resources.NoopRes{ + BaseRes: resources.BaseRes{ + Name: fmt.Sprintf("noop%d", i), + MetaParams: resources.DefaultMetaParams, + }, } v := pgraph.NewVertex(n) g.AddVertex(v) diff --git a/examples/lib/libmgmt3.go b/examples/lib/libmgmt3.go index 55c05764..c6fd090d 100644 --- a/examples/lib/libmgmt3.go +++ b/examples/lib/libmgmt3.go @@ -14,8 +14,6 @@ import ( mgmt "github.com/purpleidea/mgmt/lib" "github.com/purpleidea/mgmt/pgraph" "github.com/purpleidea/mgmt/resources" - - "golang.org/x/time/rate" ) // MyGAPI implements the main GAPI interface. @@ -61,10 +59,7 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { g := pgraph.NewGraph(obj.Name) // FIXME: these are being specified temporarily until it's the default! - metaparams := resources.MetaParams{ - Limit: rate.Inf, - Burst: 0, - } + metaparams := resources.DefaultMetaParams content := "Delete me to trigger a notification!\n" f0 := &resources.FileRes{ diff --git a/test/shell/libmgmt-change1.go b/test/shell/libmgmt-change1.go index 53b6ab4b..e13feb0d 100644 --- a/test/shell/libmgmt-change1.go +++ b/test/shell/libmgmt-change1.go @@ -13,8 +13,6 @@ import ( mgmt "github.com/purpleidea/mgmt/lib" "github.com/purpleidea/mgmt/pgraph" "github.com/purpleidea/mgmt/resources" - - "golang.org/x/time/rate" ) // 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) } // FIXME: these are being specified temporarily until it's the default! - metaparams := resources.MetaParams{ - Limit: rate.Inf, - Burst: 0, - } + metaparams := resources.DefaultMetaParams g := pgraph.NewGraph(obj.Name) n0 := &resources.NoopRes{