Skip to content

Commit fa32ba7

Browse files
committed
Renamed functions and testfiles to version number
Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com>
1 parent a85508d commit fa32ba7

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

pkg/probe/bgp_neighbors.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ import (
2222
"github.com/prometheus-community/fortigate_exporter/pkg/http"
2323
)
2424

25-
type BGPNeighborOld struct {
25+
type BGPNeighbor7_4 struct {
2626
NeighborIP string `json:"neighbor_ip"`
2727
LocalIP string `json:"local_ip"`
2828
RemoteAS int `json:"remote_as"`
2929
AdminStatus bool `json:"admin_status"`
3030
State string `json:"state"`
3131
}
3232

33-
type BGPNeighborResponseOld struct {
34-
Results []BGPNeighborOld `json:"results"`
33+
type BGPNeighborResponse7_4 struct {
34+
Results []BGPNeighbor7_4 `json:"results"`
3535
VDOM string `json:"vdom"`
3636
Version string `json:"version"`
3737
}
3838

39-
func probeBGPNeighborsIPv4Old(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
39+
func probeBGPNeighborsIPv47_4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
4040
if meta.VersionMajor < 7 {
4141
// not supported version. Before 7.0.0 the requested endpoint doesn't exist
4242
return nil, true
@@ -47,7 +47,7 @@ func probeBGPNeighborsIPv4Old(c http.FortiHTTP, meta *TargetMetadata) ([]prometh
4747
[]string{"vdom", "remote_as", "state", "admin_status", "local_ip", "neighbor_ip"}, nil,
4848
)
4949

50-
var rs []BGPNeighborResponseOld
50+
var rs []BGPNeighborResponse7_4
5151

5252
if err := c.Get("api/v2/monitor/router/bgp/neighbors", "vdom=*", &rs); err != nil {
5353
log.Printf("Error: %v", err)
@@ -65,7 +65,7 @@ func probeBGPNeighborsIPv4Old(c http.FortiHTTP, meta *TargetMetadata) ([]prometh
6565
return m, true
6666
}
6767

68-
func probeBGPNeighborsIPv6Old(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
68+
func probeBGPNeighborsIPv67_4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
6969
if meta.VersionMajor < 7 {
7070
// not supported version. Before 7.0.0 the requested endpoint doesn't exist
7171
return nil, true
@@ -77,7 +77,7 @@ func probeBGPNeighborsIPv6Old(c http.FortiHTTP, meta *TargetMetadata) ([]prometh
7777
[]string{"vdom", "remote_as", "state", "admin_status", "local_ip", "neighbor_ip"}, nil,
7878
)
7979

80-
var rs []BGPNeighborResponseOld
80+
var rs []BGPNeighborResponse7_4
8181

8282
if err := c.Get("api/v2/monitor/router/bgp/neighbors6", "vdom=*", &rs); err != nil {
8383
log.Printf("Error: %v", err)
@@ -130,7 +130,7 @@ type BGPNeighborResponse struct {
130130

131131
func probeBGPNeighborsIPv4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
132132
if meta.VersionMajor == 7 && meta.VersionMinor < 6 {
133-
return probeBGPNeighborsIPv4Old(c, meta)
133+
return probeBGPNeighborsIPv47_4(c, meta)
134134
}
135135

136136
mBGPNeighborState := prometheus.NewDesc(
@@ -181,7 +181,7 @@ func probeBGPNeighborsIPv4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus
181181

182182
func probeBGPNeighborsIPv6(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
183183
if meta.VersionMajor == 7 && meta.VersionMinor < 6 {
184-
return probeBGPNeighborsIPv6Old(c, meta)
184+
return probeBGPNeighborsIPv67_4(c, meta)
185185
}
186186

187187
mBGPNeighborState := prometheus.NewDesc(

pkg/probe/bgp_neighbors_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
func TestBGPNeighborsIPv4Old(t *testing.T) {
2525
c := newFakeClient()
26-
c.prepare("api/v2/monitor/router/bgp/neighbors", "testdata/router-bgp-neighbors-v4old.jsonnet")
26+
c.prepare("api/v2/monitor/router/bgp/neighbors", "testdata/router-bgp-neighbors-v4-7.4.jsonnet")
2727
r := prometheus.NewPedanticRegistry()
2828
meta := &TargetMetadata{
2929
VersionMajor: 7,
@@ -46,7 +46,7 @@ func TestBGPNeighborsIPv4Old(t *testing.T) {
4646

4747
func TestBGPNeighborsIPv6Old(t *testing.T) {
4848
c := newFakeClient()
49-
c.prepare("api/v2/monitor/router/bgp/neighbors6", "testdata/router-bgp-neighbors-v6old.jsonnet")
49+
c.prepare("api/v2/monitor/router/bgp/neighbors6", "testdata/router-bgp-neighbors-v6-7.4.jsonnet")
5050
r := prometheus.NewPedanticRegistry()
5151
meta := &TargetMetadata{
5252
VersionMajor: 7,
@@ -120,7 +120,7 @@ func TestBGPNeighborsIPv6(t *testing.T) {
120120
}
121121

122122
em := `
123-
# HELP fortigate_bgp_neighbor_ipv6_state Configured bgp neighbor over ipv4 state
123+
# HELP fortigate_bgp_neighbor_ipv6_state Configured bgp neighbor over ipv6 state
124124
# TYPE fortigate_bgp_neighbor_ipv6_state gauge
125125
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Active",vdom="root"} 0
126126
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Connect",vdom="root"} 0

pkg/probe/testdata/router-bgp-neighbors-v4old.jsonnet renamed to pkg/probe/testdata/router-bgp-neighbors-v4-7.4.jsonnet

File renamed without changes.

pkg/probe/testdata/router-bgp-neighbors-v6old.jsonnet renamed to pkg/probe/testdata/router-bgp-neighbors-v6-7.4.jsonnet

File renamed without changes.

0 commit comments

Comments
 (0)