From 5bfe950a1460877f1fc3d776ee0f868f5f89b1f8 Mon Sep 17 00:00:00 2001 From: Richard Kettelerij Date: Thu, 20 Jun 2024 14:26:51 +0200 Subject: [PATCH] feat(pingdom): linting --- internal/service/providers/pingdom.go | 12 ++++++------ internal/service/providers/pingdom_test.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/providers/pingdom.go b/internal/service/providers/pingdom.go index 5ac4c10..ba1b9d5 100644 --- a/internal/service/providers/pingdom.go +++ b/internal/service/providers/pingdom.go @@ -18,7 +18,7 @@ import ( const pingdomURL = "https://api.pingdom.com/api/3.1/checks" const checkNotFound = int64(-1) -const customIdPrefix = "id:" +const customIDPrefix = "id:" type PingdomSettings struct { APIToken string @@ -86,7 +86,7 @@ func (m *PingdomUptimeProvider) DeleteCheck(check model.UptimeCheck) error { func (m *PingdomUptimeProvider) findCheck(check model.UptimeCheck) (int64, error) { result := checkNotFound - req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s?include_tags=true", pingdomURL), nil) + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf(pingdomURL+"?include_tags=true"), nil) if err != nil { return result, err } @@ -134,7 +134,7 @@ func (m *PingdomUptimeProvider) findCheck(check model.UptimeCheck) (int64, error func (m *PingdomUptimeProvider) createCheck(check model.UptimeCheck) error { log.Printf("creating check %v\n", check) - message, err := m.checkToJson(check, true) + message, err := m.checkToJSON(check, true) if err != nil { return err } @@ -152,7 +152,7 @@ func (m *PingdomUptimeProvider) createCheck(check model.UptimeCheck) error { func (m *PingdomUptimeProvider) updateCheck(existingPingdomID int64, check model.UptimeCheck) error { log.Printf("updating check %v\n, using pingdom ID %d", check, existingPingdomID) - message, err := m.checkToJson(check, false) + message, err := m.checkToJSON(check, false) if err != nil { return err } @@ -167,7 +167,7 @@ func (m *PingdomUptimeProvider) updateCheck(existingPingdomID int64, check model return nil } -func (m *PingdomUptimeProvider) checkToJson(check model.UptimeCheck, includeType bool) ([]byte, error) { +func (m *PingdomUptimeProvider) checkToJSON(check model.UptimeCheck, includeType bool) ([]byte, error) { checkURL, err := url.ParseRequestURI(check.URL) if err != nil { return nil, err @@ -182,7 +182,7 @@ func (m *PingdomUptimeProvider) checkToJson(check model.UptimeCheck, includeType } // add the check id (from the k8s annotation) as a tag, so we can latter retrieve the check it during update or delete. - check.Tags = append(check.Tags, customIdPrefix+check.ID) + check.Tags = append(check.Tags, customIDPrefix+check.ID) message := map[string]any{ "name": check.Name, diff --git a/internal/service/providers/pingdom_test.go b/internal/service/providers/pingdom_test.go index 6845c55..add516b 100644 --- a/internal/service/providers/pingdom_test.go +++ b/internal/service/providers/pingdom_test.go @@ -68,8 +68,8 @@ func TestAgainstREALPingdomAPI(t *testing.T) { settings := PingdomSettings{APIToken: os.Getenv("PINGDOM_API_TOKEN")} if os.Getenv("PINGDOM_USER_ID") != "" { - userId, _ := strconv.Atoi(os.Getenv("PINGDOM_USER_ID")) - settings.UserIDs = []int{userId} + userID, _ := strconv.Atoi(os.Getenv("PINGDOM_USER_ID")) + settings.UserIDs = []int{userID} } if os.Getenv("PINGDOM_INTEGRATION_ID") != "" { integrationID, _ := strconv.Atoi(os.Getenv("PINGDOM_INTEGRATION_ID"))