Skip to content

Commit 06623db

Browse files
committed
go fmt
1 parent 55b9be8 commit 06623db

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package main
22

33
import (
4+
"fmt"
45
"log"
56
"os"
6-
"fmt"
77
)
88

99
const (
10-
LoggerLogPrefix = ""
10+
LoggerLogPrefix = ""
1111
LoggerLogPrefixError = "[ERROR] "
1212
)
1313

main.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package main
22

33
import (
4-
"os"
54
"fmt"
6-
"time"
7-
"strings"
8-
"net/url"
95
"github.com/jessevdk/go-flags"
6+
"net/url"
7+
"os"
8+
"strings"
9+
"time"
1010
)
1111

1212
const (
@@ -23,14 +23,14 @@ var (
2323

2424
var opts struct {
2525
// general options
26-
ServerBind string ` long:"bind" env:"SERVER_BIND" description:"Server address" default:":8080"`
27-
ScrapeTime time.Duration `long:"scrape-time" env:"SCRAPE_TIME" description:"Scrape time in seconds" default:"1m"`
28-
Verbose []bool ` long:"verbose" short:"v" env:"VERBOSE" description:"Verbose mode"`
26+
ServerBind string `long:"bind" env:"SERVER_BIND" description:"Server address" default:":8080"`
27+
ScrapeTime time.Duration `long:"scrape-time" env:"SCRAPE_TIME" description:"Scrape time in seconds" default:"1m"`
28+
Verbose []bool `long:"verbose" short:"v" env:"VERBOSE" description:"Verbose mode"`
2929

3030
// Api options
31-
ApiUrl string ` long:"api-url" env:"API_URL" description:"Azure ScheduledEvents API URL" default:"http://169.254.169.254/metadata/scheduledevents?api-version=2017-11-01"`
32-
ApiTimeout time.Duration `long:"api-timeout" env:"API_TIMEOUT" description:"Azure API timeout (seconds)" default:"30s"`
33-
ApiErrorThreshold int ` long:"api-error-threshold" env:"API_ERROR_THRESHOLD" description:"Azure API error threshold (after which app will panic)" default:"0"`
31+
ApiUrl string `long:"api-url" env:"API_URL" description:"Azure ScheduledEvents API URL" default:"http://169.254.169.254/metadata/scheduledevents?api-version=2017-11-01"`
32+
ApiTimeout time.Duration `long:"api-timeout" env:"API_TIMEOUT" description:"Azure API timeout (seconds)" default:"30s"`
33+
ApiErrorThreshold int `long:"api-error-threshold" env:"API_ERROR_THRESHOLD" description:"Azure API error threshold (after which app will panic)" default:"0"`
3434
}
3535

3636
func main() {
@@ -86,11 +86,11 @@ func initArgparser() {
8686
}
8787

8888
// validate --api-url scheme
89-
switch (strings.ToLower(apiUrl.Scheme)) {
89+
switch strings.ToLower(apiUrl.Scheme) {
9090
case "http":
91-
break;
91+
break
9292
case "https":
93-
break;
93+
break
9494
default:
9595
fmt.Println("ApiURL scheme not allowed (must be http or https)")
9696
fmt.Println()

metrics.go

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package main
22

33
import (
4-
"log"
5-
"fmt"
6-
"time"
7-
"net/http"
84
"encoding/json"
5+
"fmt"
96
"github.com/prometheus/client_golang/prometheus"
107
"github.com/prometheus/client_golang/prometheus/promhttp"
8+
"log"
9+
"net/http"
10+
"time"
1111
)
1212

1313
type AzureScheduledEventResponse struct {
14-
DocumentIncarnation int `json:"DocumentIncarnation"`
15-
Events []AzureScheduledEvent `json:"Events"`
14+
DocumentIncarnation int `json:"DocumentIncarnation"`
15+
Events []AzureScheduledEvent `json:"Events"`
1616
}
1717

1818
type AzureScheduledEvent struct {
19-
EventId string `json:"EventId"`
20-
EventType string `json:"EventType"`
21-
ResourceType string `json:"ResourceType"`
22-
Resources []string `json:"Resources"`
23-
EventStatus string `json:"EventStatus"`
24-
NotBefore string `json:"NotBefore"`
19+
EventId string `json:"EventId"`
20+
EventType string `json:"EventType"`
21+
ResourceType string `json:"ResourceType"`
22+
Resources []string `json:"Resources"`
23+
EventStatus string `json:"EventStatus"`
24+
NotBefore string `json:"NotBefore"`
2525
}
2626

2727
var (
@@ -69,7 +69,6 @@ var (
6969
apiErrorCount = 0
7070
)
7171

72-
7372
func setupMetricsCollection() {
7473
prometheus.MustRegister(scheduledEvent)
7574
prometheus.MustRegister(scheduledEventDocumentIncarnation)
@@ -132,30 +131,30 @@ func probeCollect() {
132131
for _, resource := range event.Resources {
133132
scheduledEvent.With(
134133
prometheus.Labels{
135-
"eventID": event.EventId,
136-
"eventType": event.EventType,
134+
"eventID": event.EventId,
135+
"eventType": event.EventType,
137136
"resourceType": event.ResourceType,
138-
"resource": resource,
139-
"eventStatus": event.EventStatus,
140-
"notBefore": event.NotBefore,
137+
"resource": resource,
138+
"eventStatus": event.EventStatus,
139+
"notBefore": event.NotBefore,
141140
}).Set(eventValue)
142141
}
143142
} else {
144143
scheduledEvent.With(
145144
prometheus.Labels{
146-
"eventID": event.EventId,
147-
"eventType": event.EventType,
145+
"eventID": event.EventId,
146+
"eventType": event.EventType,
148147
"resourceType": event.ResourceType,
149-
"resource": "",
150-
"eventStatus": event.EventStatus,
151-
"notBefore": event.NotBefore,
148+
"resource": "",
149+
"eventStatus": event.EventStatus,
150+
"notBefore": event.NotBefore,
152151
}).Set(eventValue)
153152
}
154153
}
155154

156155
scheduledEventDocumentIncarnation.With(prometheus.Labels{}).Set(float64(scheduledEvents.DocumentIncarnation))
157156

158-
Logger.Verbose("Fetched %v Azure ScheduledEvents",len(scheduledEvents.Events))
157+
Logger.Verbose("Fetched %v Azure ScheduledEvents", len(scheduledEvents.Events))
159158
}
160159

161160
func fetchApiUrl() (*AzureScheduledEventResponse, error) {

0 commit comments

Comments
 (0)