From 491d60e2677cdfebbc4c5525a8612532f5e4b16b Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 27 Jan 2017 18:41:09 -0500 Subject: [PATCH] examples: Have libmgmt work around the lack of rate defaults The rate limit lib needs a proper default. Until that's the case, specify this so it doesn't block the resources. --- examples/lib/libmgmt3.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/lib/libmgmt3.go b/examples/lib/libmgmt3.go index 830d1f36..7b28aa28 100644 --- a/examples/lib/libmgmt3.go +++ b/examples/lib/libmgmt3.go @@ -14,6 +14,8 @@ 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 +60,17 @@ 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, + } + content := "Delete me to trigger a notification!\n" f0 := &resources.FileRes{ BaseRes: resources.BaseRes{ - Name: "README", + Name: "README", + MetaParams: metaparams, }, Path: "/tmp/mgmt/README", Content: &content, @@ -73,7 +82,8 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { p1 := &resources.PasswordRes{ BaseRes: resources.BaseRes{ - Name: "password1", + Name: "password1", + MetaParams: metaparams, }, Length: 8, // generated string will have this many characters Saved: true, // this causes passwords to be stored in plain text! @@ -83,7 +93,8 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { f1 := &resources.FileRes{ BaseRes: resources.BaseRes{ - Name: "file1", + Name: "file1", + MetaParams: metaparams, // send->recv! Recv: map[string]*resources.Send{ "Content": {Res: p1, Key: "Password"}, @@ -99,7 +110,8 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { n1 := &resources.NoopRes{ BaseRes: resources.BaseRes{ - Name: "noop1", + Name: "noop1", + MetaParams: metaparams, }, }