From 67935c407c91106879ecd6d6014a5996076c3d2b Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 14 Nov 2016 14:18:15 -0800 Subject: [PATCH] fixing default records size for changefeed Signed-off-by: David Lawrence (github: endophage) --- CHANGELOG.md | 3 +++ NOTARY_VERSION | 2 +- server/handlers/changefeed.go | 23 +++++++++++++---------- server/handlers/changefeed_test.go | 10 ++++++++++ 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4797b05..a9338bd71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [v0.5.1](https://github.com/docker/notary/releases/tag/v0.5.1) 11/14/2016 ++ If no `records` parameter is provided in a request for the changefeed, a default value of 100 is used. + ## [v0.5.0](https://github.com/docker/notary/releases/tag/v0.5.0) 11/14/2016 + Non-certificate public keys in PEM format can now be added to delegation roles [#965](https://github.com/docker/notary/pull/965) + PostgreSQL support as a storage backend for Server and Signer [#920](https://github.com/docker/notary/pull/920) diff --git a/NOTARY_VERSION b/NOTARY_VERSION index 8f0916f76..4b9fcbec1 100644 --- a/NOTARY_VERSION +++ b/NOTARY_VERSION @@ -1 +1 @@ -0.5.0 +0.5.1 diff --git a/server/handlers/changefeed.go b/server/handlers/changefeed.go index fa9a30c1f..f79280e30 100644 --- a/server/handlers/changefeed.go +++ b/server/handlers/changefeed.go @@ -67,16 +67,19 @@ func checkChangefeedInputs(logger ctxu.Logger, s interface{}, r string) ( err = errors.ErrNoStorage.WithDetail(nil) return } - pageSize, err = strconv.ParseInt(r, 10, 32) - if err != nil { - logger.Errorf("400 GET invalid pageSize: %s", r) - err = errors.ErrInvalidParams.WithDetail( - fmt.Sprintf("invalid records parameter: %s", err.Error()), - ) - return - } - if pageSize == 0 { - pageSize = notary.DefaultPageSize + pageSize = notary.DefaultPageSize + if r != "" { + pageSize, err = strconv.ParseInt(r, 10, 32) + if err != nil { + logger.Errorf("400 GET invalid records: %s", r) + err = errors.ErrInvalidParams.WithDetail( + fmt.Sprintf("invalid records parameter: %s", err.Error()), + ) + return + } + if pageSize == 0 { + pageSize = notary.DefaultPageSize + } } return } diff --git a/server/handlers/changefeed_test.go b/server/handlers/changefeed_test.go index e2a77183c..7b0b05098 100644 --- a/server/handlers/changefeed_test.go +++ b/server/handlers/changefeed_test.go @@ -134,6 +134,16 @@ func Test_checkChangefeedInputs(t *testing.T) { wantStore: s, wantPageSize: -10, }, + { + name: "Empty string records", + args: args{ + logger: logrus.New(), + s: s, + ps: "", + }, + wantStore: s, + wantPageSize: 100, + }, } for _, tt := range tests { gotStore, gotPageSize, err := checkChangefeedInputs(tt.args.logger, tt.args.s, tt.args.ps)