From 15e3cc0638c013599b7ea8d11d1c542150e32def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Brod=C3=A9n?= Date: Wed, 15 May 2024 17:01:35 +0200 Subject: [PATCH] Use any alias instead of interface{} Updates map[string]interface{} and similar to instead use the any alias. --- api/account.go | 16 ++++++------ api/alarms.go | 30 +++++++++++------------ api/api.go | 6 ++--- api/aws_eventbridge.go | 24 ++++++++---------- api/credentials.go | 10 ++++---- api/custom_domain.go | 22 +++++++---------- api/disk.go | 12 ++++----- api/instance.go | 42 ++++++++++++++++---------------- api/integration.go | 26 +++++++++----------- api/metadata.go | 6 ++--- api/nodes.go | 18 +++++++------- api/notifications.go | 28 +++++++++------------ api/plugins.go | 30 +++++++++++------------ api/plugins_community.go | 31 +++++++++++------------ api/privatelink.go | 22 ++++++++--------- api/rabbitmq_configuration.go | 19 ++++++++------- api/security_firewall.go | 39 +++++++++++++++-------------- api/upgrade_rabbitmq.go | 14 +++++------ api/vpc.go | 28 ++++++++++----------- api/vpc_connect.go | 18 +++++++------- api/vpc_gcp_peering.go | 36 +++++++++++++-------------- api/vpc_gcp_peering_withvpcid.go | 12 ++++----- api/vpc_peering.go | 28 ++++++++++----------- api/vpc_peering_withvpcid.go | 10 ++++---- api/webhook.go | 36 +++++++++++++-------------- 25 files changed, 271 insertions(+), 292 deletions(-) diff --git a/api/account.go b/api/account.go index ab01af0b..3eca4be7 100644 --- a/api/account.go +++ b/api/account.go @@ -6,10 +6,10 @@ import ( "strconv" ) -func (api *API) ListInstances() ([]map[string]interface{}, error) { +func (api *API) ListInstances() ([]map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any ) response, err := api.sling.New().Path("api/instances").Receive(&data, &failed) @@ -30,10 +30,10 @@ func (api *API) ListInstances() ([]map[string]interface{}, error) { } } -func (api *API) ListVpcs() ([]map[string]interface{}, error) { +func (api *API) ListVpcs() ([]map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = "/api/vpcs" ) @@ -58,7 +58,7 @@ func (api *API) ListVpcs() ([]map[string]interface{}, error) { func (api *API) RotatePassword(instanceID int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/instances/%d/account/rotate-password", instanceID) ) @@ -80,7 +80,7 @@ func (api *API) RotatePassword(instanceID int) error { func (api *API) RotateApiKey(instanceID int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/instances/%d/account/rotate-apikey", instanceID) ) diff --git a/api/alarms.go b/api/alarms.go index 397225e0..5b194099 100644 --- a/api/alarms.go +++ b/api/alarms.go @@ -7,12 +7,10 @@ import ( "time" ) -func (api *API) CreateAlarm(instanceID int, params map[string]interface{}) ( - map[string]interface{}, error) { - +func (api *API) CreateAlarm(instanceID int, params map[string]any) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms", instanceID) ) @@ -37,10 +35,10 @@ func (api *API) CreateAlarm(instanceID int, params map[string]interface{}) ( } } -func (api *API) ReadAlarm(instanceID int, alarmID string) (map[string]interface{}, error) { +func (api *API) ReadAlarm(instanceID int, alarmID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/%s", instanceID, alarmID) ) @@ -60,10 +58,10 @@ func (api *API) ReadAlarm(instanceID int, alarmID string) (map[string]interface{ } } -func (api *API) ListAlarms(instanceID int) ([]map[string]interface{}, error) { +func (api *API) ListAlarms(instanceID int) ([]map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms", instanceID) ) @@ -83,9 +81,9 @@ func (api *API) ListAlarms(instanceID int) ([]map[string]interface{}, error) { } } -func (api *API) UpdateAlarm(instanceID int, params map[string]interface{}) error { +func (api *API) UpdateAlarm(instanceID int, params map[string]any) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/%s", instanceID, params["id"].(string)) ) @@ -105,7 +103,7 @@ func (api *API) UpdateAlarm(instanceID int, params map[string]interface{}) error func (api *API) DeleteAlarm(instanceID int, alarmID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/%s", instanceID, alarmID) ) @@ -125,8 +123,8 @@ func (api *API) DeleteAlarm(instanceID int, alarmID string) error { func (api *API) waitUntilAlarmDeletion(instanceID int, alarmID string) error { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::alarms#waitUntilAlarmDeletion waiting") diff --git a/api/api.go b/api/api.go index 38a273dc..7ccb1819 100644 --- a/api/api.go +++ b/api/api.go @@ -11,10 +11,10 @@ type API struct { client *http.Client } -func (api *API) DefaultRmqVersion() (map[string]interface{}, error) { +func (api *API) DefaultRmqVersion() (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) _, err := api.sling.New().Get("/api/default_rabbitmq_version").Receive(&data, &failed) diff --git a/api/aws_eventbridge.go b/api/aws_eventbridge.go index 01ca52d8..d7edd321 100644 --- a/api/aws_eventbridge.go +++ b/api/aws_eventbridge.go @@ -6,12 +6,10 @@ import ( "strconv" ) -func (api *API) CreateAwsEventBridge(instanceID int, params map[string]interface{}) ( - map[string]interface{}, error) { - +func (api *API) CreateAwsEventBridge(instanceID int, params map[string]any) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/eventbridges", instanceID) ) @@ -36,12 +34,10 @@ func (api *API) CreateAwsEventBridge(instanceID int, params map[string]interface } } -func (api *API) ReadAwsEventBridge(instanceID int, eventbridgeID string) ( - map[string]interface{}, error) { - +func (api *API) ReadAwsEventBridge(instanceID int, eventbridgeID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/eventbridges/%s", instanceID, eventbridgeID) ) @@ -59,10 +55,10 @@ func (api *API) ReadAwsEventBridge(instanceID int, eventbridgeID string) ( } } -func (api *API) ReadAwsEventBridges(instanceID int) (map[string]interface{}, error) { +func (api *API) ReadAwsEventBridges(instanceID int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/eventbridges", instanceID) ) @@ -82,7 +78,7 @@ func (api *API) ReadAwsEventBridges(instanceID int) (map[string]interface{}, err func (api *API) DeleteAwsEventBridge(instanceID int, eventbridgeID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/eventbridges/%s", instanceID, eventbridgeID) ) diff --git a/api/credentials.go b/api/credentials.go index 2659fcd1..2dd86340 100644 --- a/api/credentials.go +++ b/api/credentials.go @@ -6,10 +6,10 @@ import ( "strconv" ) -func (api *API) ReadCredentials(id int) (map[string]interface{}, error) { +func (api *API) ReadCredentials(id int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any instanceID = strconv.Itoa(id) ) @@ -27,8 +27,8 @@ func (api *API) ReadCredentials(id int) (map[string]interface{}, error) { } } -func extractInfo(url string) map[string]interface{} { - paramsMap := make(map[string]interface{}) +func extractInfo(url string) map[string]any { + paramsMap := make(map[string]any) r := regexp.MustCompile(`^.*:\/\/(?P(.*)):(?P(.*))@`) match := r.FindStringSubmatch(url) diff --git a/api/custom_domain.go b/api/custom_domain.go index 939a5632..6cc16a62 100644 --- a/api/custom_domain.go +++ b/api/custom_domain.go @@ -7,7 +7,7 @@ import ( ) func (api *API) waitUntilCustomDomainConfigured(instanceID int, configured bool) ( - map[string]interface{}, error) { + map[string]any, error) { for { response, err := api.ReadCustomDomain(instanceID) @@ -26,11 +26,9 @@ func (api *API) waitUntilCustomDomainConfigured(instanceID int, configured bool) } } -func (api *API) CreateCustomDomain(instanceID int, hostname string) ( - map[string]interface{}, error) { - +func (api *API) CreateCustomDomain(instanceID int, hostname string) (map[string]any, error) { var ( - failed map[string]interface{} + failed map[string]any params = make(map[string]string) path = fmt.Sprintf("/api/instances/%d/custom-domain", instanceID) ) @@ -52,10 +50,10 @@ func (api *API) CreateCustomDomain(instanceID int, hostname string) ( } } -func (api *API) ReadCustomDomain(instanceID int) (map[string]interface{}, error) { +func (api *API) ReadCustomDomain(instanceID int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/custom-domain", instanceID) ) @@ -75,9 +73,7 @@ func (api *API) ReadCustomDomain(instanceID int) (map[string]interface{}, error) } } -func (api *API) UpdateCustomDomain(instanceID int, hostname string) ( - map[string]interface{}, error) { - +func (api *API) UpdateCustomDomain(instanceID int, hostname string) (map[string]any, error) { log.Printf("[DEBUG] go-api::custom_domain#update instanceID: %d, hostname: %s", instanceID, hostname) @@ -99,9 +95,9 @@ func (api *API) UpdateCustomDomain(instanceID int, hostname string) ( return api.waitUntilCustomDomainConfigured(instanceID, true) } -func (api *API) DeleteCustomDomain(instanceID int) (map[string]interface{}, error) { +func (api *API) DeleteCustomDomain(instanceID int) (map[string]any, error) { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/custom-domain", instanceID) ) diff --git a/api/disk.go b/api/disk.go index 19f45d32..d5dd023b 100644 --- a/api/disk.go +++ b/api/disk.go @@ -7,8 +7,8 @@ import ( "time" ) -func (api *API) ResizeDisk(instanceID int, params map[string]interface{}, sleep, timeout int) ( - map[string]interface{}, error) { +func (api *API) ResizeDisk(instanceID int, params map[string]any, sleep, timeout int) ( + map[string]any, error) { var ( id = strconv.Itoa(instanceID) @@ -19,12 +19,12 @@ func (api *API) ResizeDisk(instanceID int, params map[string]interface{}, sleep, return api.resizeDiskWithRetry(id, params, 1, sleep, timeout) } -func (api *API) resizeDiskWithRetry(id string, params map[string]interface{}, attempt, sleep, - timeout int) (map[string]interface{}, error) { +func (api *API) resizeDiskWithRetry(id string, params map[string]any, attempt, sleep, + timeout int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%s/disk", id) ) diff --git a/api/instance.go b/api/instance.go index b9dd9ae0..ef47ef43 100644 --- a/api/instance.go +++ b/api/instance.go @@ -8,10 +8,10 @@ import ( "time" ) -func (api *API) waitUntilReady(instanceID string) (map[string]interface{}, error) { +func (api *API) waitUntilReady(instanceID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%s", instanceID) ) @@ -38,8 +38,8 @@ func (api *API) waitUntilReady(instanceID string) (map[string]interface{}, error func (api *API) waitUntilAllNodesReady(instanceID string) error { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%v/nodes", instanceID) ) @@ -67,13 +67,13 @@ func (api *API) waitWithTimeoutUntilAllNodesConfigured(instanceID string, attemp timeout int) error { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%v/nodes", instanceID) ) + log.Printf("[DEBUG] api::instance#waitWithTimeoutUntilAllNodesConfigured not yet ready, "+ "will try again, attempt: %d, until timeout: %d", attempt, (timeout - (attempt * sleep))) - _, err := api.sling.New().Path(path).Receive(&data, &failed) if err != nil { return err @@ -98,8 +98,8 @@ func (api *API) waitWithTimeoutUntilAllNodesConfigured(instanceID string, attemp func (api *API) waitUntilDeletion(instanceID string) error { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%s", instanceID) ) @@ -123,10 +123,10 @@ func (api *API) waitUntilDeletion(instanceID string) error { } } -func (api *API) CreateInstance(params map[string]interface{}) (map[string]interface{}, error) { +func (api *API) CreateInstance(params map[string]any) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::instance#create params: %v", params) @@ -151,10 +151,10 @@ func (api *API) CreateInstance(params map[string]interface{}) (map[string]interf } } -func (api *API) ReadInstance(instanceID string) (map[string]interface{}, error) { +func (api *API) ReadInstance(instanceID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%s", instanceID) ) @@ -177,9 +177,9 @@ func (api *API) ReadInstance(instanceID string) (map[string]interface{}, error) } } -func (api *API) UpdateInstance(instanceID string, params map[string]interface{}) error { +func (api *API) UpdateInstance(instanceID string, params map[string]any) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/instances/%v", instanceID) ) @@ -203,7 +203,7 @@ func (api *API) UpdateInstance(instanceID string, params map[string]interface{}) func (api *API) DeleteInstance(instanceID string, keep_vpc bool) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/instances/%s?keep_vpc=%v", instanceID, keep_vpc) ) @@ -225,8 +225,8 @@ func (api *API) DeleteInstance(instanceID string, keep_vpc bool) error { } } -func (api *API) UrlInformation(url string) map[string]interface{} { - paramsMap := make(map[string]interface{}) +func (api *API) UrlInformation(url string) map[string]any { + paramsMap := make(map[string]any) r := regexp.MustCompile(`^.*:\/\/(?P(.*)):(?P(.*))@(?P(.*))\/(?P(.*))`) match := r.FindStringSubmatch(url) diff --git a/api/integration.go b/api/integration.go index dbe06f13..b2337d18 100644 --- a/api/integration.go +++ b/api/integration.go @@ -8,11 +8,11 @@ import ( // CreateIntegration enables integration communication, either for logs or metrics. func (api *API) CreateIntegration(instanceID int, intType string, intName string, - params map[string]interface{}) (map[string]interface{}, error) { + params map[string]any) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/integrations/%s/%s", instanceID, intType, intName) ) @@ -40,12 +40,10 @@ func (api *API) CreateIntegration(instanceID int, intType string, intName string } // ReadIntegration retrieves a specific logs or metrics integration -func (api *API) ReadIntegration(instanceID int, intType, intID string) ( - map[string]interface{}, error) { - +func (api *API) ReadIntegration(instanceID int, intType, intID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/integrations/%s/%s", instanceID, intType, intID) ) @@ -59,14 +57,14 @@ func (api *API) ReadIntegration(instanceID int, intType, intID string) ( case 200: log.Printf("[DEBUG] api::integration#read data: %v", data) // Convert API response body, config part, into single map - convertedData := make(map[string]interface{}) + convertedData := make(map[string]any) for k, v := range data { if k == "id" { convertedData[k] = v } else if k == "type" { convertedData[k] = v } else if k == "config" { - for configK, configV := range data["config"].(map[string]interface{}) { + for configK, configV := range data["config"].(map[string]any) { convertedData[configK] = configV } } @@ -80,11 +78,9 @@ func (api *API) ReadIntegration(instanceID int, intType, intID string) ( } // UpdateIntegration updated the integration with new information -func (api *API) UpdateIntegration(instanceID int, intType, intID string, - params map[string]interface{}) error { - +func (api *API) UpdateIntegration(instanceID int, intType, intID string, params map[string]any) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/integrations/%s/%s", instanceID, intType, intID) ) @@ -106,7 +102,7 @@ func (api *API) UpdateIntegration(instanceID int, intType, intID string, // DeleteIntegration removes log or metric integration. func (api *API) DeleteIntegration(instanceID int, intType, intID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/integrations/%s/%s", instanceID, intType, intID) ) diff --git a/api/metadata.go b/api/metadata.go index b5f9d2a4..0a31161f 100644 --- a/api/metadata.go +++ b/api/metadata.go @@ -19,7 +19,7 @@ type Region struct { func (api *API) ValidatePlan(name string) error { var ( data []Plan - failed map[string]interface{} + failed map[string]any path = "api/plans" ) @@ -46,7 +46,7 @@ func (api *API) ValidatePlan(name string) error { func (api *API) PlanTypes(old, new string) (string, string, error) { var ( data []Plan - failed map[string]interface{} + failed map[string]any path = "api/plans" oldPlanType string newPlanType string @@ -85,7 +85,7 @@ func planType(shared bool) string { func (api *API) ValidateRegion(region string) error { var ( data []Region - failed map[string]interface{} + failed map[string]any path = "api/regions" platform string ) diff --git a/api/nodes.go b/api/nodes.go index f8734d65..1eba528d 100644 --- a/api/nodes.go +++ b/api/nodes.go @@ -7,10 +7,10 @@ import ( ) // ListNodes - list all nodes of the cluster -func (api *API) ListNodes(instanceID int) ([]map[string]interface{}, error) { +func (api *API) ListNodes(instanceID int) ([]map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%d/nodes", instanceID) ) @@ -30,9 +30,9 @@ func (api *API) ListNodes(instanceID int) ([]map[string]interface{}, error) { } // ReadNode - read out node information of a single node -func (api *API) ReadNode(instanceID int, nodeName string) (map[string]interface{}, error) { +func (api *API) ReadNode(instanceID int, nodeName string) (map[string]any, error) { var ( - data map[string]interface{} + data map[string]any ) log.Printf("[DEBUG] go-api::nodes#read_node instance id: %d node name: %s", instanceID, nodeName) @@ -52,11 +52,11 @@ func (api *API) ReadNode(instanceID int, nodeName string) (map[string]interface{ // PostAction - request an action for the node (e.g. start/stop/restart RabbitMQ) func (api *API) PostAction(instanceID int, nodeName string, action string) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any actionAsRoute string params = make(map[string][]string) path = fmt.Sprintf("api/instances/%d/actions/%s", instanceID, actionAsRoute) @@ -85,7 +85,7 @@ func (api *API) PostAction(instanceID int, nodeName string, action string) ( } func (api *API) waitOnNodeAction(instanceID int, nodeName string, action string) ( - map[string]interface{}, error) { + map[string]any, error) { log.Printf("[DEBUG] api::nodes#waitOnNodeAction waiting") for { diff --git a/api/notifications.go b/api/notifications.go index c8c53c1d..c48f567f 100644 --- a/api/notifications.go +++ b/api/notifications.go @@ -6,12 +6,10 @@ import ( "strconv" ) -func (api *API) CreateNotification(instanceID int, params map[string]interface{}) ( - map[string]interface{}, error) { - +func (api *API) CreateNotification(instanceID int, params map[string]any) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/recipients", instanceID) ) @@ -36,12 +34,10 @@ func (api *API) CreateNotification(instanceID int, params map[string]interface{} } } -func (api *API) ReadNotification(instanceID int, recipientID string) ( - map[string]interface{}, error) { - +func (api *API) ReadNotification(instanceID int, recipientID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/recipients/%s", instanceID, recipientID) ) @@ -61,10 +57,10 @@ func (api *API) ReadNotification(instanceID int, recipientID string) ( } } -func (api *API) ListNotifications(instanceID int) ([]map[string]interface{}, error) { +func (api *API) ListNotifications(instanceID int) ([]map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/recipients", instanceID) ) @@ -85,10 +81,10 @@ func (api *API) ListNotifications(instanceID int) ([]map[string]interface{}, err } func (api *API) UpdateNotification(instanceID int, recipientID string, - params map[string]interface{}) error { + params map[string]any) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/recipients/%s", instanceID, recipientID) ) @@ -109,7 +105,7 @@ func (api *API) UpdateNotification(instanceID int, recipientID string, func (api *API) DeleteNotification(instanceID int, recipientID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/alarms/recipients/%s", instanceID, recipientID) ) diff --git a/api/plugins.go b/api/plugins.go index dfa857c7..ab318b43 100644 --- a/api/plugins.go +++ b/api/plugins.go @@ -9,11 +9,11 @@ import ( // EnablePlugin: enable a plugin on an instance. func (api *API) EnablePlugin(instanceID int, pluginName string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - failed map[string]interface{} - params = make(map[string]interface{}) + failed map[string]any + params = make(map[string]any) path = fmt.Sprintf("/api/instances/%d/plugins?async=true", instanceID) ) @@ -35,7 +35,7 @@ func (api *API) EnablePlugin(instanceID int, pluginName string, sleep, timeout i // ReadPlugin: reads a specific plugin from an instance. func (api *API) ReadPlugin(instanceID int, pluginName string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { log.Printf("[DEBUG] api::plugin#read instance id: %d, name: %s", instanceID, pluginName) data, err := api.ListPlugins(instanceID, sleep, timeout) @@ -54,17 +54,17 @@ func (api *API) ReadPlugin(instanceID int, pluginName string, sleep, timeout int } // ListPlugins: list plugins from an instance. -func (api *API) ListPlugins(instanceID, sleep, timeout int) ([]map[string]interface{}, error) { +func (api *API) ListPlugins(instanceID, sleep, timeout int) ([]map[string]any, error) { return api.listPluginsWithRetry(instanceID, 1, sleep, timeout) } // listPluginsWithRetry: list plugins from an instance, with retry if backend is busy. func (api *API) listPluginsWithRetry(instanceID, attempt, sleep, timeout int) ( - []map[string]interface{}, error) { + []map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/plugins", instanceID) ) @@ -93,11 +93,11 @@ func (api *API) listPluginsWithRetry(instanceID, attempt, sleep, timeout int) ( // UpdatePlugin: updates a plugin from an instance. func (api *API) UpdatePlugin(instanceID int, pluginName string, enabled bool, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - failed map[string]interface{} - params = make(map[string]interface{}) + failed map[string]any + params = make(map[string]any) path = fmt.Sprintf("/api/instances/%d/plugins?async=true", instanceID) ) @@ -120,10 +120,10 @@ func (api *API) UpdatePlugin(instanceID int, pluginName string, enabled bool, sl // DisablePlugin: disables a plugin from an instance. func (api *API) DisablePlugin(instanceID int, pluginName string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/plugins/%s?async=true", instanceID, pluginName) ) @@ -145,7 +145,7 @@ func (api *API) DisablePlugin(instanceID int, pluginName string, sleep, timeout // DeletePlugin: deletes a plugin from an instance. func (api *API) DeletePlugin(instanceID int, pluginName string, sleep, timeout int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/plugins/%s?async=true", instanceID, pluginName) ) @@ -167,7 +167,7 @@ func (api *API) DeletePlugin(instanceID int, pluginName string, sleep, timeout i // waitUntilPluginChanged: wait until plugin changed. func (api *API) waitUntilPluginChanged(instanceID int, pluginName string, enabled bool, - attempt, sleep, timeout int) (map[string]interface{}, error) { + attempt, sleep, timeout int) (map[string]any, error) { for { if attempt*sleep > timeout { diff --git a/api/plugins_community.go b/api/plugins_community.go index 0576f073..3c4766f9 100644 --- a/api/plugins_community.go +++ b/api/plugins_community.go @@ -9,11 +9,11 @@ import ( // InstallPluginCommunity: install a community plugin on an instance. func (api *API) InstallPluginCommunity(instanceID int, pluginName string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - failed map[string]interface{} - params = make(map[string]interface{}) + failed map[string]any + params = make(map[string]any) path = fmt.Sprintf("/api/instances/%d/plugins/community?async=true", instanceID) ) @@ -35,7 +35,7 @@ func (api *API) InstallPluginCommunity(instanceID int, pluginName string, sleep, // ReadPluginCommunity: reads a specific community plugin from an instance. func (api *API) ReadPluginCommunity(instanceID int, pluginName string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { log.Printf("[DEBUG] api::plugin_community#read instance ID: %v, name: %v", instanceID, pluginName) data, err := api.ListPluginsCommunity(instanceID, sleep, timeout) @@ -54,26 +54,23 @@ func (api *API) ReadPluginCommunity(instanceID int, pluginName string, sleep, ti } // ListPluginsCommunity: list all community plugins for an instance. -func (api *API) ListPluginsCommunity(instanceID, sleep, timeout int) ( - []map[string]interface{}, error) { - +func (api *API) ListPluginsCommunity(instanceID, sleep, timeout int) ([]map[string]any, error) { return api.listPluginsCommunityWithRetry(instanceID, 1, sleep, timeout) } // listPluginsCommunityWithRetry: list all community plugins for an instance, // with retry if the backend is busy. func (api *API) listPluginsCommunityWithRetry(instanceID, attempt, sleep, timeout int) ( - []map[string]interface{}, error) { + []map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/plugins/community", instanceID) ) log.Printf("[DEBUG] api::plugin_community#listPluginsCommunityWithRetry path: %s", path) response, err := api.sling.New().Get(path).Receive(&data, &failed) - if err != nil { return nil, err } else if attempt*sleep > timeout { @@ -100,11 +97,11 @@ func (api *API) listPluginsCommunityWithRetry(instanceID, attempt, sleep, timeou // UpdatePluginCommunity: updates a community plugin from an instance. func (api *API) UpdatePluginCommunity(instanceID int, pluginName string, enabled bool, - sleep, timeout int) (map[string]interface{}, error) { + sleep, timeout int) (map[string]any, error) { var ( - failed map[string]interface{} - params = make(map[string]interface{}) + failed map[string]any + params = make(map[string]any) path = fmt.Sprintf("/api/instances/%d/plugins/community?async=true", instanceID) ) @@ -127,10 +124,10 @@ func (api *API) UpdatePluginCommunity(instanceID int, pluginName string, enabled // UninstallPluginCommunity: uninstall a community plugin from an instance. func (api *API) UninstallPluginCommunity(instanceID int, pluginName string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/plugins/community/%s?async=true", instanceID, pluginName) ) @@ -151,7 +148,7 @@ func (api *API) UninstallPluginCommunity(instanceID int, pluginName string, slee // waitUntilPluginUninstalled: wait until a community plugin been uninstalled. func (api *API) waitUntilPluginUninstalled(instanceID int, pluginName string, - attempt, sleep, timeout int) (map[string]interface{}, error) { + attempt, sleep, timeout int) (map[string]any, error) { log.Printf("[DEBUG] api::plugin_community#waitUntilPluginUninstalled instance id: %v, name: %v", instanceID, pluginName) diff --git a/api/privatelink.go b/api/privatelink.go index 65f9c492..469e375b 100644 --- a/api/privatelink.go +++ b/api/privatelink.go @@ -10,11 +10,11 @@ import ( // EnablePrivatelink: Enable PrivateLink and wait until finished. // Need to enable VPC for an instance, if no standalone VPC used. // Wait until finished with configureable sleep and timeout. -func (api *API) EnablePrivatelink(instanceID int, params map[string][]interface{}, +func (api *API) EnablePrivatelink(instanceID int, params map[string][]any, sleep, timeout int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/privatelink", instanceID) ) @@ -37,16 +37,16 @@ func (api *API) EnablePrivatelink(instanceID int, params map[string][]interface{ } // ReadPrivatelink: Reads PrivateLink information -func (api *API) ReadPrivatelink(instanceID, sleep, timeout int) (map[string]interface{}, error) { +func (api *API) ReadPrivatelink(instanceID, sleep, timeout int) (map[string]any, error) { return api.readPrivateLinkWithRetry(instanceID, 1, sleep, timeout) } func (api *API) readPrivateLinkWithRetry(instanceID, attempt, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/privatelink", instanceID) ) @@ -75,9 +75,9 @@ func (api *API) readPrivateLinkWithRetry(instanceID, attempt, sleep, timeout int } // UpdatePrivatelink: Update allowed principals or subscriptions -func (api *API) UpdatePrivatelink(instanceID int, params map[string][]interface{}) error { +func (api *API) UpdatePrivatelink(instanceID int, params map[string][]any) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/privatelink", instanceID) ) @@ -98,7 +98,7 @@ func (api *API) UpdatePrivatelink(instanceID int, params map[string][]interface{ // DisablePrivatelink: Disable the PrivateLink feature func (api *API) DisablePrivatelink(instanceID int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/privatelink", instanceID) ) @@ -119,8 +119,8 @@ func (api *API) DisablePrivatelink(instanceID int) error { // waitForEnablePrivatelinkWithRetry: Wait until status change from pending to enable func (api *API) waitForEnablePrivatelinkWithRetry(instanceID, attempt, sleep, timeout int) error { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/privatelink", instanceID) ) diff --git a/api/rabbitmq_configuration.go b/api/rabbitmq_configuration.go index 5e32eb39..93fb846a 100644 --- a/api/rabbitmq_configuration.go +++ b/api/rabbitmq_configuration.go @@ -7,20 +7,19 @@ import ( "time" ) -func (api *API) ReadRabbitMqConfiguration(instanceID, sleep, timeout int) ( - map[string]interface{}, error) { - +func (api *API) ReadRabbitMqConfiguration(instanceID, sleep, timeout int) (map[string]any, error) { return api.readRabbitMqConfigurationWithRetry(instanceID, 1, sleep, timeout) } func (api *API) readRabbitMqConfigurationWithRetry(instanceID, attempt, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/config", instanceID) ) + response, err := api.sling.New().Get(path).Receive(&data, &failed) if err != nil { return nil, err @@ -51,17 +50,19 @@ func (api *API) readRabbitMqConfigurationWithRetry(instanceID, attempt, sleep, t response.StatusCode, failed) } -func (api *API) UpdateRabbitMqConfiguration(instanceID int, params map[string]interface{}, +func (api *API) UpdateRabbitMqConfiguration(instanceID int, params map[string]any, sleep, timeout int) error { return api.updateRabbitMqConfigurationWithRetry(instanceID, params, 1, sleep, timeout) } -func (api *API) updateRabbitMqConfigurationWithRetry(instanceID int, params map[string]interface{}, +func (api *API) updateRabbitMqConfigurationWithRetry(instanceID int, params map[string]any, attempt, sleep, timeout int) error { + var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/instances/%d/config", instanceID) ) + response, err := api.sling.New().Put(path).BodyJSON(params).Receive(nil, &failed) if err != nil { return err diff --git a/api/security_firewall.go b/api/security_firewall.go index 5cf0bba3..24c41926 100644 --- a/api/security_firewall.go +++ b/api/security_firewall.go @@ -8,8 +8,8 @@ import ( func (api *API) waitUntilFirewallConfigured(instanceID, attempt, sleep, timeout int) error { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/security/firewall/configured", instanceID) ) @@ -39,8 +39,8 @@ func (api *API) waitUntilFirewallConfigured(instanceID, attempt, sleep, timeout } } -func (api *API) CreateFirewallSettings(instanceID int, params []map[string]interface{}, sleep, - timeout int) ([]map[string]interface{}, error) { +func (api *API) CreateFirewallSettings(instanceID int, params []map[string]any, sleep, timeout int) ( + []map[string]any, error) { attempt, err := api.createFirewallSettingsWithRetry(instanceID, params, 1, sleep, timeout) if err != nil { @@ -55,10 +55,11 @@ func (api *API) CreateFirewallSettings(instanceID int, params []map[string]inter return api.ReadFirewallSettings(instanceID) } -func (api *API) createFirewallSettingsWithRetry(instanceID int, params []map[string]interface{}, +func (api *API) createFirewallSettingsWithRetry(instanceID int, params []map[string]any, attempt, sleep, timeout int) (int, error) { + var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/security/firewall", instanceID) ) @@ -93,10 +94,10 @@ func (api *API) createFirewallSettingsWithRetry(instanceID int, params []map[str response.StatusCode, failed) } -func (api *API) ReadFirewallSettings(instanceID int) ([]map[string]interface{}, error) { +func (api *API) ReadFirewallSettings(instanceID int) ([]map[string]any, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/security/firewall", instanceID) ) @@ -115,8 +116,8 @@ func (api *API) ReadFirewallSettings(instanceID int) ([]map[string]interface{}, } } -func (api *API) UpdateFirewallSettings(instanceID int, params []map[string]interface{}, - sleep, timeout int) ([]map[string]interface{}, error) { +func (api *API) UpdateFirewallSettings(instanceID int, params []map[string]any, + sleep, timeout int) ([]map[string]any, error) { log.Printf("[DEBUG] api::security_firewall#update instance id: %d, params: %v, sleep: %d, "+ "timeout: %d", instanceID, params, sleep, timeout) @@ -131,11 +132,11 @@ func (api *API) UpdateFirewallSettings(instanceID int, params []map[string]inter return api.ReadFirewallSettings(instanceID) } -func (api *API) updateFirewallSettingsWithRetry(instanceID int, params []map[string]interface{}, +func (api *API) updateFirewallSettingsWithRetry(instanceID int, params []map[string]any, attempt, sleep, timeout int) (int, error) { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/security/firewall", instanceID) ) @@ -169,9 +170,7 @@ func (api *API) updateFirewallSettingsWithRetry(instanceID int, params []map[str response.StatusCode, failed) } -func (api *API) DeleteFirewallSettings(instanceID, sleep, timeout int) ( - []map[string]interface{}, error) { - +func (api *API) DeleteFirewallSettings(instanceID, sleep, timeout int) ([]map[string]any, error) { log.Printf("[DEBUG] api::security_firewall#delete instance id: %d, sleep: %d, timeout: %d", instanceID, sleep, timeout) attempt, err := api.deleteFirewallSettingsWithRetry(instanceID, 1, sleep, timeout) @@ -191,8 +190,8 @@ func (api *API) deleteFirewallSettingsWithRetry(instanceID, attempt, sleep, time int, error) { var ( - params [1]map[string]interface{} - failed map[string]interface{} + params [1]map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/security/firewall", instanceID) ) @@ -229,8 +228,8 @@ func (api *API) deleteFirewallSettingsWithRetry(instanceID, attempt, sleep, time response.StatusCode, failed) } -func DefaultFirewallSettings() map[string]interface{} { - defaultRule := map[string]interface{}{ +func DefaultFirewallSettings() map[string]any { + defaultRule := map[string]any{ "services": []string{"AMQP", "AMQPS", "STOMP", "STOMPS", "MQTT", "MQTTS", "HTTPS", "STREAM", "STREAM_SSL"}, "ports": []int{}, diff --git a/api/upgrade_rabbitmq.go b/api/upgrade_rabbitmq.go index ecd98135..0e86c958 100644 --- a/api/upgrade_rabbitmq.go +++ b/api/upgrade_rabbitmq.go @@ -7,10 +7,10 @@ import ( ) // ReadVersions - Read versions RabbitMQ and Erlang can upgrade to -func (api *API) ReadVersions(instanceID int) (map[string]interface{}, error) { +func (api *API) ReadVersions(instanceID int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%d/actions/new-rabbitmq-erlang-versions", instanceID) ) @@ -32,8 +32,8 @@ func (api *API) ReadVersions(instanceID int) (map[string]interface{}, error) { // UpgradeRabbitMQ - Upgrade to latest possible versions for both RabbitMQ and Erlang. func (api *API) UpgradeRabbitMQ(instanceID int) (string, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%d/actions/upgrade-rabbitmq-erlang", instanceID) ) @@ -59,8 +59,8 @@ func (api *API) UpgradeRabbitMQ(instanceID int) (string, error) { func (api *API) waitUntilUpgraded(instanceID int) (string, error) { var ( - data []map[string]interface{} - failed map[string]interface{} + data []map[string]any + failed map[string]any path = fmt.Sprintf("api/instances/%d/nodes", instanceID) ) diff --git a/api/vpc.go b/api/vpc.go index 8d0280ca..9153c11c 100644 --- a/api/vpc.go +++ b/api/vpc.go @@ -9,8 +9,8 @@ import ( func (api *API) waitUntilVpcReady(vpcID string) error { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("api/vpcs/%s/vpc-peering/info", vpcID) ) @@ -35,10 +35,10 @@ func (api *API) waitUntilVpcReady(vpcID string) error { } } -func (api *API) readVpcName(vpcID string) (map[string]interface{}, error) { +func (api *API) readVpcName(vpcID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("api/vpcs/%s/vpc-peering/info", vpcID) ) @@ -56,10 +56,10 @@ func (api *API) readVpcName(vpcID string) (map[string]interface{}, error) { } } -func (api *API) CreateVpcInstance(params map[string]interface{}) (map[string]interface{}, error) { +func (api *API) CreateVpcInstance(params map[string]any) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc#create params: %v", params) @@ -83,10 +83,10 @@ func (api *API) CreateVpcInstance(params map[string]interface{}) (map[string]int } } -func (api *API) ReadVpcInstance(vpcID string) (map[string]interface{}, error) { +func (api *API) ReadVpcInstance(vpcID string) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/vpcs/%s", vpcID) ) @@ -109,9 +109,9 @@ func (api *API) ReadVpcInstance(vpcID string) (map[string]interface{}, error) { } } -func (api *API) UpdateVpcInstance(vpcID string, params map[string]interface{}) error { +func (api *API) UpdateVpcInstance(vpcID string, params map[string]any) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/vpcs/%s", vpcID) ) @@ -134,7 +134,7 @@ func (api *API) UpdateVpcInstance(vpcID string, params map[string]interface{}) e func (api *API) DeleteVpcInstance(vpcID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("api/vpcs/%s", vpcID) ) diff --git a/api/vpc_connect.go b/api/vpc_connect.go index b1aa2890..9c6bfe97 100644 --- a/api/vpc_connect.go +++ b/api/vpc_connect.go @@ -13,7 +13,7 @@ func (api *API) EnableVpcConnect(instanceID int, params map[string][]interface{} sleep, timeout int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-connect", instanceID) ) @@ -36,10 +36,10 @@ func (api *API) EnableVpcConnect(instanceID int, params map[string][]interface{} } // ReadVpcConnect: Reads VPC Connect information -func (api *API) ReadVpcConnect(instanceID int) (map[string]interface{}, error) { +func (api *API) ReadVpcConnect(instanceID int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-connect", instanceID) ) @@ -60,7 +60,7 @@ func (api *API) ReadVpcConnect(instanceID int) (map[string]interface{}, error) { // UpdateVpcConnect: Update allowlist for the VPC Connect func (api *API) UpdateVpcConnect(instanceID int, params map[string][]interface{}) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-connect", instanceID) ) @@ -81,7 +81,7 @@ func (api *API) UpdateVpcConnect(instanceID int, params map[string][]interface{} // DisableVpcConnect: Disable the VPC Connect feature func (api *API) DisableVpcConnect(instanceID int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-connect", instanceID) ) @@ -102,8 +102,8 @@ func (api *API) DisableVpcConnect(instanceID int) error { // waitForEnableVpcConnectWithRetry: Wait until status change from pending to enable func (api *API) waitForEnableVpcConnectWithRetry(instanceID, attempt, sleep, timeout int) error { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-connect", instanceID) ) @@ -137,7 +137,7 @@ func (api *API) waitForEnableVpcConnectWithRetry(instanceID, attempt, sleep, tim // Check if the instance already have a standalone VPC func (api *API) EnableVPC(instanceID int) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc", instanceID) ) diff --git a/api/vpc_gcp_peering.go b/api/vpc_gcp_peering.go index 1dd16bc1..e6ec3e53 100644 --- a/api/vpc_gcp_peering.go +++ b/api/vpc_gcp_peering.go @@ -12,7 +12,7 @@ func (api *API) waitForGcpPeeringStatus(path, peerID string, attempt, sleep, timeout int) error { var ( - data map[string]interface{} + data map[string]any err error ) @@ -29,7 +29,7 @@ func (api *API) waitForGcpPeeringStatus(path, peerID string, rows := data["rows"].([]interface{}) if len(rows) > 0 { for _, row := range rows { - tempRow := row.(map[string]interface{}) + tempRow := row.(map[string]any) if tempRow["name"] != peerID { continue } @@ -46,8 +46,8 @@ func (api *API) waitForGcpPeeringStatus(path, peerID string, } // RequestVpcGcpPeering: requests a VPC peering from an instance. -func (api *API) RequestVpcGcpPeering(instanceID int, params map[string]interface{}, - waitOnStatus bool, sleep, timeout int) (map[string]interface{}, error) { +func (api *API) RequestVpcGcpPeering(instanceID int, params map[string]any, + waitOnStatus bool, sleep, timeout int) (map[string]any, error) { path := fmt.Sprintf("api/instances/%v/vpc-peering", instanceID) attempt, data, err := api.requestVpcGcpPeeringWithRetry(path, params, waitOnStatus, 1, sleep, timeout) @@ -67,11 +67,11 @@ func (api *API) RequestVpcGcpPeering(instanceID int, params map[string]interface } // requestVpcGcpPeeringWithRetry: requests a VPC peering from a path with retry logic -func (api *API) requestVpcGcpPeeringWithRetry(path string, params map[string]interface{}, - waitOnStatus bool, attempt, sleep, timeout int) (int, map[string]interface{}, error) { +func (api *API) requestVpcGcpPeeringWithRetry(path string, params map[string]any, + waitOnStatus bool, attempt, sleep, timeout int) (int, map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc_gcp_peering#request path: %s, params: %v", path, params) @@ -101,7 +101,7 @@ func (api *API) requestVpcGcpPeeringWithRetry(path string, params map[string]int // ReadVpcGcpPeering: reads the VPC peering from the API func (api *API) ReadVpcGcpPeering(instanceID, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { path := fmt.Sprintf("/api/instances/%v/vpc-peering", instanceID) _, data, err := api.readVpcGcpPeeringWithRetry(path, 1, sleep, timeout) @@ -110,11 +110,11 @@ func (api *API) ReadVpcGcpPeering(instanceID, sleep, timeout int) ( // readVpcGcpPeeringWithRetry: reads the VPC peering from the API with retry logic func (api *API) readVpcGcpPeeringWithRetry(path string, attempt, sleep, timeout int) ( - int, map[string]interface{}, error) { + int, map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc_gcp_peering#read path: %s", path) @@ -143,7 +143,7 @@ func (api *API) readVpcGcpPeeringWithRetry(path string, attempt, sleep, timeout // UpdateVpcGcpPeering: updates a VPC peering from an instance. func (api *API) UpdateVpcGcpPeering(instanceID int, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { // NOP just read out the VPC peering return api.ReadVpcGcpPeering(instanceID, sleep, timeout) @@ -152,7 +152,7 @@ func (api *API) UpdateVpcGcpPeering(instanceID int, sleep, timeout int) ( // RemoveVpcGcpPeering: removes a VPC peering from an instance. func (api *API) RemoveVpcGcpPeering(instanceID int, peerID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-peering/%s", instanceID, peerID) ) @@ -172,18 +172,18 @@ func (api *API) RemoveVpcGcpPeering(instanceID int, peerID string) error { } // ReadVpcGcpInfo: reads the VPC info from the API -func (api *API) ReadVpcGcpInfo(instanceID, sleep, timeout int) (map[string]interface{}, error) { +func (api *API) ReadVpcGcpInfo(instanceID, sleep, timeout int) (map[string]any, error) { path := fmt.Sprintf("/api/instances/%d/vpc-peering/info", instanceID) return api.readVpcGcpInfoWithRetry(path, 1, sleep, timeout) } // readVpcGcpInfoWithRetry: reads the VPC info from the API with retry logic func (api *API) readVpcGcpInfoWithRetry(path string, attempt, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc_gcp_peering#info path: %s", path) diff --git a/api/vpc_gcp_peering_withvpcid.go b/api/vpc_gcp_peering_withvpcid.go index 9ecef1fc..15b5b17e 100644 --- a/api/vpc_gcp_peering_withvpcid.go +++ b/api/vpc_gcp_peering_withvpcid.go @@ -8,8 +8,8 @@ import ( ) // RequestVpcGcpPeeringWithVpcId: requests a VPC peering from an instance. -func (api *API) RequestVpcGcpPeeringWithVpcId(vpcID string, params map[string]interface{}, - waitOnStatus bool, sleep, timeout int) (map[string]interface{}, error) { +func (api *API) RequestVpcGcpPeeringWithVpcId(vpcID string, params map[string]any, + waitOnStatus bool, sleep, timeout int) (map[string]any, error) { path := fmt.Sprintf("api/vpcs/%s/vpc-peering", vpcID) attempt, data, err := api.requestVpcGcpPeeringWithRetry(path, params, waitOnStatus, 1, sleep, timeout) @@ -29,7 +29,7 @@ func (api *API) RequestVpcGcpPeeringWithVpcId(vpcID string, params map[string]in } func (api *API) ReadVpcGcpPeeringWithVpcId(vpcID string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { path := fmt.Sprintf("/api/vpcs/%s/vpc-peering", vpcID) _, data, err := api.readVpcGcpPeeringWithRetry(path, 1, sleep, timeout) @@ -38,7 +38,7 @@ func (api *API) ReadVpcGcpPeeringWithVpcId(vpcID string, sleep, timeout int) ( // UpdateVpcGcpPeeringWithVpcId: updates the VPC peering from the API func (api *API) UpdateVpcGcpPeeringWithVpcId(vpcID string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { // NOP just read out the VPC peering return api.ReadVpcGcpPeeringWithVpcId(vpcID, sleep, timeout) @@ -47,7 +47,7 @@ func (api *API) UpdateVpcGcpPeeringWithVpcId(vpcID string, sleep, timeout int) ( // RemoveVpcGcpPeeringWithVpcId: removes the VPC peering from the API func (api *API) RemoveVpcGcpPeeringWithVpcId(vpcID, peerID string) error { var ( - failed map[string]interface{} + failed map[string]any path = fmt.Sprintf("/api/vpcs/%s/vpc-peering/%s", vpcID, peerID) ) @@ -68,7 +68,7 @@ func (api *API) RemoveVpcGcpPeeringWithVpcId(vpcID, peerID string) error { // ReadVpcGcpInfoWithVpcId: reads the VPC info from the API func (api *API) ReadVpcGcpInfoWithVpcId(vpcID string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { path := fmt.Sprintf("/api/vpcs/%s/vpc-peering/info", vpcID) _, data, err := api.readVpcGcpPeeringWithRetry(path, 1, sleep, timeout) diff --git a/api/vpc_peering.go b/api/vpc_peering.go index 275328f9..b12b1313 100644 --- a/api/vpc_peering.go +++ b/api/vpc_peering.go @@ -8,7 +8,7 @@ import ( ) func (api *API) AcceptVpcPeering(instanceID int, peeringID string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { attempt, err := api.waitForPeeringStatus(instanceID, peeringID, 1, sleep, timeout) log.Printf("[DEBUG] api::vpc_peering#accept attempt: %d, sleep: %d, timeout: %d", @@ -20,18 +20,18 @@ func (api *API) AcceptVpcPeering(instanceID int, peeringID string, sleep, timeou return api.retryAcceptVpcPeering(path, attempt, sleep, timeout) } -func (api *API) ReadVpcInfo(instanceID int) (map[string]interface{}, error) { +func (api *API) ReadVpcInfo(instanceID int) (map[string]any, error) { path := fmt.Sprintf("/api/instances/%d/vpc-peering/info", instanceID) // Initiale values, 5 attempts and 20 second sleep return api.readVpcInfoWithRetry(path, 5, 20) } func (api *API) ReadVpcPeeringRequest(instanceID int, peeringID string) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/vpc-peering/request/%s", instanceID, peeringID) ) @@ -57,11 +57,11 @@ func (api *API) RemoveVpcPeering(instanceID int, peeringID string, sleep, timeou } func (api *API) retryAcceptVpcPeering(path string, attempt, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc_peering#retryRemoveVpcPeering path: %s, "+ @@ -94,11 +94,11 @@ func (api *API) retryAcceptVpcPeering(path string, attempt, sleep, timeout int) } func (api *API) readVpcInfoWithRetry(path string, attempts, sleep int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc_peering#readVpcInfoWithRetry path: %s, "+ @@ -131,7 +131,7 @@ func (api *API) readVpcInfoWithRetry(path string, attempts, sleep int) ( func (api *API) retryRemoveVpcPeering(path string, attempt, sleep, timeout int) error { var ( - failed map[string]interface{} + failed map[string]any ) log.Printf("[DEBUG] api::vpc_peering#retryRemoveVpcPeering path: %s, "+ @@ -175,8 +175,8 @@ func (api *API) waitForPeeringStatusWithRetry(path, peeringID string, attempt, s timeout int) (int, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::vpc_peering#waitForPeeringStatusWithRetry path: %s "+ diff --git a/api/vpc_peering_withvpcid.go b/api/vpc_peering_withvpcid.go index 899d15c0..1872ad57 100644 --- a/api/vpc_peering_withvpcid.go +++ b/api/vpc_peering_withvpcid.go @@ -9,7 +9,7 @@ import ( ) func (api *API) AcceptVpcPeeringWithVpcId(vpcID, peeringID string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { attempt, err := api.waitForPeeringStatusWithVpcID(vpcID, peeringID, 1, sleep, timeout) if err != nil { @@ -19,18 +19,18 @@ func (api *API) AcceptVpcPeeringWithVpcId(vpcID, peeringID string, sleep, timeou return api.retryAcceptVpcPeering(path, attempt, sleep, timeout) } -func (api *API) ReadVpcInfoWithVpcId(vpcID string) (map[string]interface{}, error) { +func (api *API) ReadVpcInfoWithVpcId(vpcID string) (map[string]any, error) { path := fmt.Sprintf("/api/vpcs/%s/vpc-peering/info", vpcID) // Initiale values, 5 attempts and 20 second sleep return api.readVpcInfoWithRetry(path, 5, 20) } func (api *API) ReadVpcPeeringRequestWithVpcId(vpcID, peeringID string) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/vpcs/%s/vpc-peering/request/%s", vpcID, peeringID) ) diff --git a/api/webhook.go b/api/webhook.go index 9508a7d4..9700308d 100644 --- a/api/webhook.go +++ b/api/webhook.go @@ -9,19 +9,19 @@ import ( ) // CreateWebhook - create a webhook for a vhost and a specific qeueu -func (api *API) CreateWebhook(instanceID int, params map[string]interface{}, - sleep, timeout int) (map[string]interface{}, error) { +func (api *API) CreateWebhook(instanceID int, params map[string]any, + sleep, timeout int) (map[string]any, error) { return api.createWebhookWithRetry(instanceID, params, 1, sleep, timeout) } // createWebhookWithRetry: create webhook with retry if backend is busy. -func (api *API) createWebhookWithRetry(instanceID int, params map[string]interface{}, - attempt, sleep, timeout int) (map[string]interface{}, error) { +func (api *API) createWebhookWithRetry(instanceID int, params map[string]any, + attempt, sleep, timeout int) (map[string]any, error) { var ( - data = make(map[string]interface{}) - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/webhooks", instanceID) ) @@ -58,7 +58,7 @@ func (api *API) createWebhookWithRetry(instanceID int, params map[string]interfa // ReadWebhook - retrieves a specific webhook for an instance func (api *API) ReadWebhook(instanceID int, webhookID string, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { path := fmt.Sprintf("/api/instances/%d/webhooks/%s", instanceID, webhookID) return api.readWebhookWithRetry(path, 1, sleep, timeout) @@ -66,11 +66,11 @@ func (api *API) ReadWebhook(instanceID int, webhookID string, sleep, timeout int // readWebhookWithRetry: read webhook with retry if backend is busy. func (api *API) readWebhookWithRetry(path string, attempt, sleep, timeout int) ( - map[string]interface{}, error) { + map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any ) log.Printf("[DEBUG] api::webhook#read path: %s", path) @@ -100,10 +100,10 @@ func (api *API) readWebhookWithRetry(path string, attempt, sleep, timeout int) ( } // ListWebhooks - list all webhooks for an instance. -func (api *API) ListWebhooks(instanceID int) (map[string]interface{}, error) { +func (api *API) ListWebhooks(instanceID int) (map[string]any, error) { var ( - data map[string]interface{} - failed map[string]interface{} + data map[string]any + failed map[string]any path = fmt.Sprintf("/api/instances/%d/webhooks", instanceID) ) @@ -123,7 +123,7 @@ func (api *API) ListWebhooks(instanceID int) (map[string]interface{}, error) { } // UpdateWebhook - updates a specific webhook for an instance -func (api *API) UpdateWebhook(instanceID int, webhookID string, params map[string]interface{}, +func (api *API) UpdateWebhook(instanceID int, webhookID string, params map[string]any, sleep, timeout int) error { path := fmt.Sprintf("/api/instances/%d/webhooks/%s", instanceID, webhookID) @@ -131,12 +131,12 @@ func (api *API) UpdateWebhook(instanceID int, webhookID string, params map[strin } // updateWebhookWithRetry: update webhook with retry if backend is busy. -func (api *API) updateWebhookWithRetry(path string, params map[string]interface{}, +func (api *API) updateWebhookWithRetry(path string, params map[string]any, attempt, sleep, timeout int) error { var ( - data = make(map[string]interface{}) - failed map[string]interface{} + data = make(map[string]any) + failed map[string]any ) log.Printf("[DEBUG] api::webhook#update path: %s, params: %v", path, params) @@ -174,7 +174,7 @@ func (api *API) DeleteWebhook(instanceID int, webhookID string, sleep, timeout i // deleteWebhookWithRetry: delete webhook with retry if backend is busy. func (api *API) deleteWebhookWithRetry(path string, attempt, sleep, timeout int) error { var ( - failed map[string]interface{} + failed map[string]any ) log.Printf("[DEBUG] api::webhook#delete path: %s", path)