From 5264152f487960505fa9b1f2a72d5d933f222cc8 Mon Sep 17 00:00:00 2001 From: Husni Mansour Date: Mon, 24 Jun 2024 16:15:36 +0200 Subject: [PATCH] cleanup --- .golangci.yml | 6 +++--- opsmngr/accesslist_api_keys_test.go | 2 +- opsmngr/agents_api_keys_test.go | 8 ++++---- opsmngr/agents_test.go | 8 ++++---- opsmngr/alert_configurations_test.go | 4 ++-- opsmngr/alerts_test.go | 2 +- opsmngr/blockstore_config_test.go | 2 +- opsmngr/checkpoints_test.go | 4 ++-- opsmngr/clusters_test.go | 2 +- opsmngr/continuous_snapshots_test.go | 4 ++-- opsmngr/daemon_config_test.go | 2 +- opsmngr/deployments_hosts_test.go | 2 +- opsmngr/events_test.go | 2 +- opsmngr/file_system_store_config_test.go | 2 +- opsmngr/global_alerts_test.go | 6 +++--- opsmngr/global_api_key_whitelists_test.go | 4 ++-- opsmngr/global_api_keys_test.go | 2 +- opsmngr/live_data_migration_test.go | 2 +- opsmngr/logs_test.go | 6 +++--- opsmngr/maintenance_test.go | 4 ++-- opsmngr/oplog_store_config_test.go | 2 +- opsmngr/opsmngr_test.go | 4 ++-- opsmngr/organization_api_keys.go | 8 ++++---- opsmngr/organization_api_keys_test.go | 2 +- opsmngr/organization_invitations_test.go | 2 +- opsmngr/organizations_test.go | 6 +++--- opsmngr/project_api_keys_test.go | 4 ++-- opsmngr/project_invitations_test.go | 2 +- opsmngr/projects.go | 16 ++++++++-------- opsmngr/projects_test.go | 12 ++++++------ opsmngr/s3_blockstore_config_test.go | 2 +- opsmngr/server_usage_test.go | 2 +- opsmngr/sync_store_config_test.go | 2 +- opsmngr/teams_test.go | 8 ++++---- opsmngr/unauth_users_test.go | 2 +- opsmngr/users.go | 2 +- opsmngr/users_test.go | 4 ++-- 37 files changed, 77 insertions(+), 77 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e22faa6..86dd34e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,7 +14,8 @@ linters-settings: gocyclo: min-complexity: 15 govet: - check-shadowing: true + enable: + - shadow tagliatelle: # check the struck tag name case case: @@ -75,12 +76,11 @@ linters: - godot # Check if comments end in a period [fast: true, auto-fix: true] - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true] - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true] - - gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false] + - mnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false] - goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false] - gosec # Inspects source code for security problems [fast: false, auto-fix: false] - gosimple # Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false] - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false] - - ifshort # Checks that your code uses short syntax for if-statements whenever possible [fast: true, auto-fix: false] - ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false] - misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true] - nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false] diff --git a/opsmngr/accesslist_api_keys_test.go b/opsmngr/accesslist_api_keys_test.go index 9cd822f..bb81c55 100644 --- a/opsmngr/accesslist_api_keys_test.go +++ b/opsmngr/accesslist_api_keys_test.go @@ -293,7 +293,7 @@ func TestAccessListAPIKeys_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/"+accessListAPIKeysPath+"/%s", orgID, apiKeyID, ipAddress), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/"+accessListAPIKeysPath+"/%s", orgID, apiKeyID, ipAddress), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/agents_api_keys_test.go b/opsmngr/agents_api_keys_test.go index fa29212..e2db305 100644 --- a/opsmngr/agents_api_keys_test.go +++ b/opsmngr/agents_api_keys_test.go @@ -22,7 +22,7 @@ import ( "github.com/go-test/deep" ) -const projectID = "5e66185d917b220fbd8bb4d1" //nolint:gosec // not a credential +const projectID = "5e66185d917b220fbd8bb4d1" // not a credential func TestAgentsServiceOp_ListAgentAPIKeys(t *testing.T) { client, mux, teardown := setup() @@ -33,7 +33,7 @@ func TestAgentsServiceOp_ListAgentAPIKeys(t *testing.T) { t.Error("expected an error but got nil") } - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agentapikeys", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agentapikeys", projectID), func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, ` [{ "_id" : "1", @@ -114,7 +114,7 @@ func TestAgentsServiceOp_CreateAgentAPIKey(t *testing.T) { t.Error("expected an error but got nil") } - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agentapikeys", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agentapikeys", projectID), func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "_id" : "1", "createdBy" : "PUBLIC_API", @@ -158,7 +158,7 @@ func TestAgentsServiceOp_DeleteAgentAPIKey(t *testing.T) { agentAPIKey := "1" - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agentapikeys/%s", projectID, agentAPIKey), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agentapikeys/%s", projectID, agentAPIKey), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/agents_test.go b/opsmngr/agents_test.go index a2a613b..f02d079 100644 --- a/opsmngr/agents_test.go +++ b/opsmngr/agents_test.go @@ -31,7 +31,7 @@ func TestAgentsServiceOp_ListAgentLinks(t *testing.T) { t.Error("expected an error but got nil") } - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agents", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agents", projectID), func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "results" :[], "links": [ @@ -112,7 +112,7 @@ func TestAgentsServiceOp_ListAgentsByType(t *testing.T) { t.Error("expected an error but got nil") } - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agents/%s", projectID, agentType), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agents/%s", projectID, agentType), func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "links" : [], "results": [ @@ -163,7 +163,7 @@ func TestAgentsServiceOp_GlobalVersions(t *testing.T) { defer teardown() - mux.HandleFunc("/api/public/v1.0/softwareComponents/versions", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/softwareComponents/versions", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "automationVersion": "10.14.0.6304", "automationMinimumVersion": "10.2.17.5964", @@ -212,7 +212,7 @@ func TestAgentsServiceOp_ProjectVersions(t *testing.T) { t.Error("expected an error but got nil") } - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agents/versions", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/agents/versions", projectID), func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "count": 0, "entries": [], diff --git a/opsmngr/alert_configurations_test.go b/opsmngr/alert_configurations_test.go index d287522..6771c9f 100644 --- a/opsmngr/alert_configurations_test.go +++ b/opsmngr/alert_configurations_test.go @@ -24,7 +24,7 @@ import ( atlas "go.mongodb.org/atlas/mongodbatlas" ) -const alertConfigID = "57b76ddc96e8215c017ceafb" //nolint:gosec // not a credential +const alertConfigID = "57b76ddc96e8215c017ceafb" // not a credential func TestAlertConfiguration_Create(t *testing.T) { client, mux, teardown := setup() @@ -610,7 +610,7 @@ func TestAlertConfiguration_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/alertConfigs/%s", projectID, alertConfigID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/alertConfigs/%s", projectID, alertConfigID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/alerts_test.go b/opsmngr/alerts_test.go index 76cf8ba..32537af 100644 --- a/opsmngr/alerts_test.go +++ b/opsmngr/alerts_test.go @@ -23,7 +23,7 @@ import ( atlas "go.mongodb.org/atlas/mongodbatlas" ) -const alertID = "57b76ddc96e8215c017ceafb" //nolint:gosec // not a credential +const alertID = "57b76ddc96e8215c017ceafb" // not a credential func TestAlert_Get(t *testing.T) { client, mux, teardown := setup() diff --git a/opsmngr/blockstore_config_test.go b/opsmngr/blockstore_config_test.go index 7c77f12..cc4aa59 100644 --- a/opsmngr/blockstore_config_test.go +++ b/opsmngr/blockstore_config_test.go @@ -267,7 +267,7 @@ func TestBlockstoreConfigServiceOp_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/snapshot/mongoConfigs/%s", ID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/snapshot/mongoConfigs/%s", ID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/checkpoints_test.go b/opsmngr/checkpoints_test.go index 8377a71..2090538 100644 --- a/opsmngr/checkpoints_test.go +++ b/opsmngr/checkpoints_test.go @@ -22,7 +22,7 @@ import ( "github.com/go-test/deep" ) -const clusterID = "6b8cd61180eef547110159d9" //nolint:gosec // not a credential +const clusterID = "6b8cd61180eef547110159d9" // not a credential func TestCheckpoints_List(t *testing.T) { client, mux, teardown := setup() @@ -263,7 +263,7 @@ func TestCheckpoints_Get(t *testing.T) { client, mux, teardown := setup() defer teardown() - const checkpointID = "6b8cd61180eef547110159d9" //nolint:gosec // not a credential + const checkpointID = "6b8cd61180eef547110159d9" // not a credential path := fmt.Sprintf("/api/public/v1.0/groups/%s/clusters/%s/checkpoints/%s", projectID, clusterID, checkpointID) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { diff --git a/opsmngr/clusters_test.go b/opsmngr/clusters_test.go index 242e50f..6238e0c 100644 --- a/opsmngr/clusters_test.go +++ b/opsmngr/clusters_test.go @@ -111,7 +111,7 @@ func TestClusters_ListAll(t *testing.T) { defer teardown() - mux.HandleFunc("/api/public/v1.0/clusters", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/clusters", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintf(w, `{ "results": [ { diff --git a/opsmngr/continuous_snapshots_test.go b/opsmngr/continuous_snapshots_test.go index 50b12f9..5f35d54 100644 --- a/opsmngr/continuous_snapshots_test.go +++ b/opsmngr/continuous_snapshots_test.go @@ -25,7 +25,7 @@ import ( const ( clusterName = "Cluster0" - snapshotID = "6b5380e6jvn128560506942b" //nolint:gosec // not a credential + snapshotID = "6b5380e6jvn128560506942b" // not a credential ) func TestContinuousSnapshots_List(t *testing.T) { @@ -337,7 +337,7 @@ func TestContinuousSnapshots_Delete(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/groups/%s/clusters/%s/snapshots/%s", projectID, clusterName, snapshotID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/daemon_config_test.go b/opsmngr/daemon_config_test.go index d80f299..f4e20e0 100644 --- a/opsmngr/daemon_config_test.go +++ b/opsmngr/daemon_config_test.go @@ -217,7 +217,7 @@ func TestDaemonConfigServiceOp_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/daemon/configs/%s", ID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/daemon/configs/%s", ID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/deployments_hosts_test.go b/opsmngr/deployments_hosts_test.go index 0146b2b..87ad2bf 100644 --- a/opsmngr/deployments_hosts_test.go +++ b/opsmngr/deployments_hosts_test.go @@ -466,7 +466,7 @@ func TestDeployments_StopMonitoring(t *testing.T) { hostID := "22" path := fmt.Sprintf("/api/public/v1.0/groups/%s/hosts/%s", projectID, hostID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/events_test.go b/opsmngr/events_test.go index 1632b08..8978dcc 100644 --- a/opsmngr/events_test.go +++ b/opsmngr/events_test.go @@ -23,7 +23,7 @@ import ( atlas "go.mongodb.org/atlas/mongodbatlas" ) -const eventID = "b3ad04e680eef540be141abe" //nolint:gosec // not a credential +const eventID = "b3ad04e680eef540be141abe" // not a credential func TestEvents_ListOrganizationEvents(t *testing.T) { client, mux, teardown := setup() diff --git a/opsmngr/file_system_store_config_test.go b/opsmngr/file_system_store_config_test.go index 825f576..71b89d5 100644 --- a/opsmngr/file_system_store_config_test.go +++ b/opsmngr/file_system_store_config_test.go @@ -241,7 +241,7 @@ func TestFileSystemStoreConfigServiceOp_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/snapshot/fileSystemConfigs/%s", ID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/snapshot/fileSystemConfigs/%s", ID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/global_alerts_test.go b/opsmngr/global_alerts_test.go index 977bad4..3b4fa6d 100644 --- a/opsmngr/global_alerts_test.go +++ b/opsmngr/global_alerts_test.go @@ -28,7 +28,7 @@ func TestGlobalAlerts_List(t *testing.T) { defer teardown() - mux.HandleFunc("/api/public/v1.0/globalAlerts", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/globalAlerts", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "links" : [], "results" : [ { @@ -108,7 +108,7 @@ func TestGlobalAlerts_Get(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/globalAlerts/%s", alertID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "alertConfigId" : "5730f5e1e4b030a9634a3f69", "clusterId" : "572a00f2e4b051814b144e90", @@ -165,7 +165,7 @@ func TestGlobalAlerts_Acknowledge(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/globalAlerts/%s", alertID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "alertConfigId" : "5730f5e1e4b030a9634a3f69", "clusterId" : "572a00f2e4b051814b144e90", diff --git a/opsmngr/global_api_key_whitelists_test.go b/opsmngr/global_api_key_whitelists_test.go index b38f2b7..9323dd2 100644 --- a/opsmngr/global_api_key_whitelists_test.go +++ b/opsmngr/global_api_key_whitelists_test.go @@ -24,7 +24,7 @@ import ( atlas "go.mongodb.org/atlas/mongodbatlas" ) -const accessListID = "5f3cf81b89034c6b3c0a528e" //nolint:gosec // not a credential +const accessListID = "5f3cf81b89034c6b3c0a528e" // not a credential func TestWhitelistAPIKeys_List(t *testing.T) { client, mux, teardown := setup() @@ -176,7 +176,7 @@ func TestWhitelistAPIKeys_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/whitelist/%s", accessListID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/whitelist/%s", accessListID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/global_api_keys_test.go b/opsmngr/global_api_keys_test.go index 58c17e2..0344d34 100644 --- a/opsmngr/global_api_keys_test.go +++ b/opsmngr/global_api_keys_test.go @@ -238,7 +238,7 @@ func TestAPIKeys_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/apiKeys/%s", apiKeyID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/apiKeys/%s", apiKeyID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/live_data_migration_test.go b/opsmngr/live_data_migration_test.go index 3d14a38..8ed5173 100644 --- a/opsmngr/live_data_migration_test.go +++ b/opsmngr/live_data_migration_test.go @@ -78,7 +78,7 @@ func TestLiveMigration_DeleteConnection(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/orgs/%s/liveExport/migrationLink", orgID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/logs_test.go b/opsmngr/logs_test.go index ac3c86f..99a5e48 100644 --- a/opsmngr/logs_test.go +++ b/opsmngr/logs_test.go @@ -332,7 +332,7 @@ func TestLogs_Extend(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/groups/%s/logCollectionJobs/%s", projectID, ID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPatch) }) @@ -354,7 +354,7 @@ func TestLogs_Retry(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/groups/%s/logCollectionJobs/%s/retry", projectID, ID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) }) @@ -370,7 +370,7 @@ func TestLogs_Delete(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/groups/%s/logCollectionJobs/%s", projectID, ID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/maintenance_test.go b/opsmngr/maintenance_test.go index 1f6efe8..c1963d7 100644 --- a/opsmngr/maintenance_test.go +++ b/opsmngr/maintenance_test.go @@ -22,7 +22,7 @@ import ( "github.com/go-test/deep" ) -const ID = "5628faffd4c606594adaa3b2" //nolint:gosec // not a credential +const ID = "5628faffd4c606594adaa3b2" // not a credential func TestMaintenanceWindows_List(t *testing.T) { client, mux, teardown := setup() @@ -230,7 +230,7 @@ func TestMaintenanceWindows_Delete(t *testing.T) { path := fmt.Sprintf("/api/public/v1.0/groups/%s/maintenanceWindows/%s", projectID, ID) - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/oplog_store_config_test.go b/opsmngr/oplog_store_config_test.go index 5ea93cc..96ec774 100644 --- a/opsmngr/oplog_store_config_test.go +++ b/opsmngr/oplog_store_config_test.go @@ -252,7 +252,7 @@ func TestOplogStoreConfigServiceOp_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/oplog/mongoConfigs/%s", ID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/oplog/mongoConfigs/%s", ID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/opsmngr_test.go b/opsmngr/opsmngr_test.go index 1a19948..c645084 100644 --- a/opsmngr/opsmngr_test.go +++ b/opsmngr/opsmngr_test.go @@ -348,7 +348,7 @@ func TestDo_noContent(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) }) @@ -365,7 +365,7 @@ func TestClient_Do_httpError(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { http.Error(w, "Bad Request", http.StatusBadRequest) }) diff --git a/opsmngr/organization_api_keys.go b/opsmngr/organization_api_keys.go index 51bce2c..0578ac2 100644 --- a/opsmngr/organization_api_keys.go +++ b/opsmngr/organization_api_keys.go @@ -73,7 +73,7 @@ func (s *APIKeysServiceOp) List(ctx context.Context, orgID string, listOptions * // See more: https://docs.opsmanager.mongodb.com/current/reference/api/api-keys/org/get-one-org-api-key/ func (s *APIKeysServiceOp) Get(ctx context.Context, orgID, apiKeyID string) (*APIKey, *Response, error) { if apiKeyID == "" { - return nil, nil, atlas.NewArgError("name", "must be set") + return nil, nil, NewArgError("name", "must be set") } basePath := fmt.Sprintf(apiKeysOrgPath, orgID) @@ -99,7 +99,7 @@ func (s *APIKeysServiceOp) Get(ctx context.Context, orgID, apiKeyID string) (*AP // See more: https://docs.opsmanager.mongodb.com/current/reference/api/api-keys/org/create-one-org-api-key/ func (s *APIKeysServiceOp) Create(ctx context.Context, orgID string, createRequest *APIKeyInput) (*APIKey, *Response, error) { if createRequest == nil { - return nil, nil, atlas.NewArgError("createRequest", "cannot be nil") + return nil, nil, NewArgError("createRequest", "cannot be nil") } path := fmt.Sprintf(apiKeysOrgPath, orgID) @@ -123,7 +123,7 @@ func (s *APIKeysServiceOp) Create(ctx context.Context, orgID string, createReque // See more: https://docs.opsmanager.mongodb.com/current/reference/api/api-keys/org/update-one-org-api-key/ func (s *APIKeysServiceOp) Update(ctx context.Context, orgID, apiKeyID string, updateRequest *APIKeyInput) (*APIKey, *Response, error) { if updateRequest == nil { - return nil, nil, atlas.NewArgError("updateRequest", "cannot be nil") + return nil, nil, NewArgError("updateRequest", "cannot be nil") } basePath := fmt.Sprintf(apiKeysOrgPath, orgID) @@ -148,7 +148,7 @@ func (s *APIKeysServiceOp) Update(ctx context.Context, orgID, apiKeyID string, u // See more: https://docs.opsmanager.mongodb.com/current/reference/api/api-keys/org/delete-one-api-key/ func (s *APIKeysServiceOp) Delete(ctx context.Context, orgID, apiKeyID string) (*Response, error) { if apiKeyID == "" { - return nil, atlas.NewArgError("apiKeyID", "must be set") + return nil, NewArgError("apiKeyID", "must be set") } basePath := fmt.Sprintf(apiKeysOrgPath, orgID) diff --git a/opsmngr/organization_api_keys_test.go b/opsmngr/organization_api_keys_test.go index c254c40..247950c 100644 --- a/opsmngr/organization_api_keys_test.go +++ b/opsmngr/organization_api_keys_test.go @@ -360,7 +360,7 @@ func TestOrganizationAPIKeys_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/apiKeys/%s", orgID, apiKeyID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/apiKeys/%s", orgID, apiKeyID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/organization_invitations_test.go b/opsmngr/organization_invitations_test.go index cb90062..e5dd40b 100644 --- a/opsmngr/organization_invitations_test.go +++ b/opsmngr/organization_invitations_test.go @@ -289,7 +289,7 @@ func TestOrganizations_DeleteInvitation(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/invites/%s", orgID, invitationID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/invites/%s", orgID, invitationID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/organizations_test.go b/opsmngr/organizations_test.go index f06b257..2b5eb2b 100644 --- a/opsmngr/organizations_test.go +++ b/opsmngr/organizations_test.go @@ -23,7 +23,7 @@ import ( "go.mongodb.org/atlas/mongodbatlas" ) -const orgID = "5a0a1e7e0f2912c554081adc" //nolint:gosec // not a credential +const orgID = "5a0a1e7e0f2912c554081adc" // not a credential func TestOrganizations_GetAllOrganizations(t *testing.T) { client, mux, teardown := setup() @@ -319,7 +319,7 @@ func TestOrganizations_Create(t *testing.T) { Name: "OrgFoobar", } - mux.HandleFunc("/api/public/v1.0/orgs", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/orgs", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "id": "5a0a1e7e0f2912c554081adc", "links": [{ @@ -355,7 +355,7 @@ func TestOrganizations_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s", orgID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s", orgID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/project_api_keys_test.go b/opsmngr/project_api_keys_test.go index a5d5f43..2a44844 100644 --- a/opsmngr/project_api_keys_test.go +++ b/opsmngr/project_api_keys_test.go @@ -118,7 +118,7 @@ func TestProjectAPIKeys_Assign(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/apiKeys/%s", projectID, apiKeyID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/apiKeys/%s", projectID, apiKeyID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPatch) }) @@ -132,7 +132,7 @@ func TestProjectAPIKeys_Unassign(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/apiKeys/%s", projectID, apiKeyID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/apiKeys/%s", projectID, apiKeyID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/project_invitations_test.go b/opsmngr/project_invitations_test.go index 5a845b8..55d665c 100644 --- a/opsmngr/project_invitations_test.go +++ b/opsmngr/project_invitations_test.go @@ -289,7 +289,7 @@ func TestProjects_DeleteInvitation(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/invites/%s", projectID, invitationID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/invites/%s", projectID, invitationID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/projects.go b/opsmngr/projects.go index ac0d90a..0d091dd 100644 --- a/opsmngr/projects.go +++ b/opsmngr/projects.go @@ -160,7 +160,7 @@ func (s *ProjectsServiceOp) ListUsers(ctx context.Context, projectID string, opt // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/get-one-group-by-id/ func (s *ProjectsServiceOp) Get(ctx context.Context, groupID string) (*Project, *Response, error) { if groupID == "" { - return nil, nil, atlas.NewArgError("groupID", "must be set") + return nil, nil, NewArgError("groupID", "must be set") } path := fmt.Sprintf("%s/%s", projectBasePath, groupID) @@ -184,7 +184,7 @@ func (s *ProjectsServiceOp) Get(ctx context.Context, groupID string) (*Project, // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/get-one-group-by-name/ func (s *ProjectsServiceOp) GetByName(ctx context.Context, groupName string) (*Project, *Response, error) { if groupName == "" { - return nil, nil, atlas.NewArgError("groupName", "must be set") + return nil, nil, NewArgError("groupName", "must be set") } path := fmt.Sprintf("%s/byName/%s", projectBasePath, groupName) @@ -208,7 +208,7 @@ func (s *ProjectsServiceOp) GetByName(ctx context.Context, groupName string) (*P // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/create-one-group/ func (s *ProjectsServiceOp) Create(ctx context.Context, createRequest *Project, opts *atlas.CreateProjectOptions) (*Project, *Response, error) { if createRequest == nil { - return nil, nil, atlas.NewArgError("createRequest", "cannot be nil") + return nil, nil, NewArgError("createRequest", "cannot be nil") } path, err := setQueryParams(projectBasePath, opts) @@ -235,7 +235,7 @@ func (s *ProjectsServiceOp) Create(ctx context.Context, createRequest *Project, // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/delete-one-group/ func (s *ProjectsServiceOp) Delete(ctx context.Context, projectID string) (*Response, error) { if projectID == "" { - return nil, atlas.NewArgError("projectID", "must be set") + return nil, NewArgError("projectID", "must be set") } basePath := fmt.Sprintf("%s/%s", projectBasePath, projectID) @@ -255,11 +255,11 @@ func (s *ProjectsServiceOp) Delete(ctx context.Context, projectID string) (*Resp // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/remove-one-user-from-one-group/ func (s *ProjectsServiceOp) RemoveUser(ctx context.Context, projectID, userID string) (*Response, error) { if projectID == "" { - return nil, atlas.NewArgError("projectID", "must be set") + return nil, NewArgError("projectID", "must be set") } if userID == "" { - return nil, atlas.NewArgError("userID", "must be set") + return nil, NewArgError("userID", "must be set") } basePath := fmt.Sprintf("%s/%s/users/%s", projectBasePath, projectID, userID) @@ -279,7 +279,7 @@ func (s *ProjectsServiceOp) RemoveUser(ctx context.Context, projectID, userID st // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/project-add-team/ func (s *ProjectsServiceOp) AddTeamsToProject(ctx context.Context, projectID string, createRequest []*atlas.ProjectTeam) (*atlas.TeamsAssigned, *Response, error) { if createRequest == nil { - return nil, nil, atlas.NewArgError("createRequest", "cannot be nil") + return nil, nil, NewArgError("createRequest", "cannot be nil") } path := fmt.Sprintf("%s/%s/teams", projectBasePath, projectID) @@ -303,7 +303,7 @@ func (s *ProjectsServiceOp) AddTeamsToProject(ctx context.Context, projectID str // See more: https://docs.opsmanager.mongodb.com/current/reference/api/groups/project-get-teams/ func (s *ProjectsServiceOp) GetTeams(ctx context.Context, projectID string, opts *ListOptions) (*atlas.TeamsAssigned, *Response, error) { if projectID == "" { - return nil, nil, atlas.NewArgError("projectID", "cannot be empty") + return nil, nil, NewArgError("projectID", "cannot be empty") } path := fmt.Sprintf("%s/%s/teams", projectBasePath, projectID) diff --git a/opsmngr/projects_test.go b/opsmngr/projects_test.go index 68de9d8..7263b58 100644 --- a/opsmngr/projects_test.go +++ b/opsmngr/projects_test.go @@ -397,7 +397,7 @@ func TestProject_Create(t *testing.T) { WithDefaultAlertsSettings: &withDefaultAlertsSettings, } - mux.HandleFunc("/api/public/v1.0/groups", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/groups", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "activeAgentCount": 0, "hostCounts": { @@ -471,7 +471,7 @@ func TestProject_Create_without_opts(t *testing.T) { Name: "ProjectFoobar", } - mux.HandleFunc("/api/public/v1.0/groups", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/groups", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "activeAgentCount": 0, "hostCounts": { @@ -539,7 +539,7 @@ func TestProject_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s", projectID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) @@ -556,7 +556,7 @@ func TestProject_RemoveUser(t *testing.T) { var str = fmt.Sprintf("/api/public/v1.0/groups/%s/users/%s", projectID, userID) fmt.Println(str) - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/users/%s", projectID, userID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/users/%s", projectID, userID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) @@ -575,7 +575,7 @@ func TestProject_AddTeamsToProject(t *testing.T) { RoleNames: []string{"GROUP_OWNER", "GROUP_READ_ONLY"}, }} - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/teams", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/teams", projectID), func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{ "links": [{ "href": "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/teams", @@ -629,7 +629,7 @@ func TestProject_GetTeams(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/teams", projectID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/teams", projectID), func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{ "links": [{ "href": "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/teams", diff --git a/opsmngr/s3_blockstore_config_test.go b/opsmngr/s3_blockstore_config_test.go index e87b11b..25b03c7 100644 --- a/opsmngr/s3_blockstore_config_test.go +++ b/opsmngr/s3_blockstore_config_test.go @@ -379,7 +379,7 @@ func TestS3BlockstoreConfigServiceOp_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/snapshot/s3Configs/%s", ID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/snapshot/s3Configs/%s", ID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/server_usage_test.go b/opsmngr/server_usage_test.go index 00934ec..ff0e546 100644 --- a/opsmngr/server_usage_test.go +++ b/opsmngr/server_usage_test.go @@ -27,7 +27,7 @@ func TestServerUsageServiceOp_GenerateDailyUsageSnapshot(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc("/api/public/v1.0/usage/dailyCapture", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/usage/dailyCapture", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) }) diff --git a/opsmngr/sync_store_config_test.go b/opsmngr/sync_store_config_test.go index f076d50..5b183f0 100644 --- a/opsmngr/sync_store_config_test.go +++ b/opsmngr/sync_store_config_test.go @@ -250,7 +250,7 @@ func TestSyncStoreConfigServiceOp_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/sync/mongoConfigs/%s", ID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/admin/backup/sync/mongoConfigs/%s", ID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/teams_test.go b/opsmngr/teams_test.go index 9b050f1..1bb1712 100644 --- a/opsmngr/teams_test.go +++ b/opsmngr/teams_test.go @@ -24,7 +24,7 @@ import ( "go.mongodb.org/atlas/mongodbatlas" ) -const teamID = "6b720e1087d9d66b272f1c86" //nolint:gosec // not a credential +const teamID = "6b720e1087d9d66b272f1c86" // not a credential func TestTeams_List(t *testing.T) { client, mux, teardown := setup() @@ -511,7 +511,7 @@ func TestTeams_RemoveUserToTeam(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/teams/%s/users/%s", orgID, teamID, userID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/teams/%s/users/%s", orgID, teamID, userID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) @@ -525,7 +525,7 @@ func TestTeams_RemoveTeamFromOrganization(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/teams/%s", orgID, teamID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/orgs/%s/teams/%s", orgID, teamID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) @@ -539,7 +539,7 @@ func TestTeams_RemoveTeamFromProject(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/teams/%s", projectID, teamID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/groups/%s/teams/%s", projectID, teamID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) diff --git a/opsmngr/unauth_users_test.go b/opsmngr/unauth_users_test.go index f25e265..385e4e4 100644 --- a/opsmngr/unauth_users_test.go +++ b/opsmngr/unauth_users_test.go @@ -34,7 +34,7 @@ func TestUnauth_CreateFirstUser(t *testing.T) { LastName: "Doe", } - mux.HandleFunc("/api/public/v1.0/unauth/users", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/public/v1.0/unauth/users", func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprint(w, `{ "apiKey": "1234abcd-ab12-cd34-ef56-1234abcd1234", "user": { diff --git a/opsmngr/users.go b/opsmngr/users.go index 1d2c8e2..2c4f5bc 100644 --- a/opsmngr/users.go +++ b/opsmngr/users.go @@ -51,7 +51,7 @@ type User struct { Links []*atlas.Link `json:"links,omitempty"` MobileNumber string `json:"mobileNumber,omitempty"` Password string `json:"password,omitempty"` - TeamIds []string `json:"teamIds,omitempty"` + TeamIds []string `json:"teamIds,omitempty"` //nolint Roles []*UserRole `json:"roles,omitempty"` Username string `json:"username"` Country string `json:"country,omitempty"` diff --git a/opsmngr/users_test.go b/opsmngr/users_test.go index df7b449..e15e2d7 100644 --- a/opsmngr/users_test.go +++ b/opsmngr/users_test.go @@ -23,7 +23,7 @@ import ( "go.mongodb.org/atlas/mongodbatlas" ) -const userID = "56a10a80e4b0fd3b9a9bb0c2" //nolint:gosec // not a credential +const userID = "56a10a80e4b0fd3b9a9bb0c2" // not a credential const userName = "someone@example.com" func TestUsers_Get(t *testing.T) { @@ -192,7 +192,7 @@ func TestUsers_Delete(t *testing.T) { client, mux, teardown := setup() defer teardown() - mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/users/%s", userID), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/api/public/v1.0/users/%s", userID), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) })