Skip to content

Commit 3b211b1

Browse files
committed
Make zone sync struct optional
1 parent 8f20f67 commit 3b211b1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

client/nginx.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type Stats struct {
8888
Upstreams Upstreams
8989
StreamServerZones StreamServerZones
9090
StreamUpstreams StreamUpstreams
91-
StreamZoneSync StreamZoneSync
91+
StreamZoneSync *StreamZoneSync
9292
}
9393

9494
// NginxInfo contains general information about NGINX Plus.
@@ -764,7 +764,7 @@ func (client *NginxClient) GetStats() (*Stats, error) {
764764
StreamServerZones: *streamZones,
765765
Upstreams: *upstreams,
766766
StreamUpstreams: *streamUpstreams,
767-
StreamZoneSync: *streamZoneSync,
767+
StreamZoneSync: streamZoneSync,
768768
}, nil
769769
}
770770

@@ -855,9 +855,8 @@ func (client *NginxClient) getStreamZoneSync() (*StreamZoneSync, error) {
855855
err := client.get("stream/zone_sync", &streamZoneSync)
856856
if err != nil {
857857
if err, ok := err.(*internalError); ok {
858-
859858
if err.Code == pathNotFoundCode {
860-
return &streamZoneSync, nil
859+
return nil, nil
861860
}
862861
}
863862
return nil, fmt.Errorf("failed to get stream zone sync: %v", err)

tests/client_no_stream_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ func TestStatsNoStream(t *testing.T) {
3434
if len(stats.StreamUpstreams) != 0 {
3535
t.Error("No stream block should result in no StreamUpstreams")
3636
}
37+
38+
if stats.StreamZoneSync != nil {
39+
t.Error("No stream block should result in StreamZoneSync = `nil`")
40+
}
3741
}

0 commit comments

Comments
 (0)