Skip to content

Commit

Permalink
api/v2: return empty array of peers when disabled (prometheus#2203)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Pasquier <[email protected]>
  • Loading branch information
simonpasquier committed Mar 10, 2020
1 parent 99e5cbf commit e347c31
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (api *API) getStatusHandler(params general_ops.GetStatusParams) middleware.
},
Cluster: &open_api_models.ClusterStatus{
Status: &status,
Peers: []*open_api_models.PeerStatus{},
},
}

Expand Down
7 changes: 5 additions & 2 deletions api/v2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ func TestGetStatusHandlerWithNilPeer(t *testing.T) {
t.Fatal("expected cluster status not to be nil, violating the openapi specification")
}

if c.Peers != nil {
t.Fatal("expected cluster peers to be nil when api.peer is nil, violating the openapi specification")
if c.Peers == nil {
t.Fatal("expected cluster peers to be not nil when api.peer is nil, violating the openapi specification")
}
if len(c.Peers) != 0 {
t.Fatal("expected cluster peers to be empty when api.peer is nil, violating the openapi specification")
}

if c.Name != "" {
Expand Down
1 change: 0 additions & 1 deletion api/v2/models/cluster_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ definitions:
enum: ["ready", "settling", "disabled"]
peers:
type: array
minimum: 0
items:
$ref: '#/definitions/peerStatus'
required:
Expand Down
1 change: 0 additions & 1 deletion api/v2/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e347c31

Please sign in to comment.