Skip to content

Commit

Permalink
Use any alias instead of interface{}
Browse files Browse the repository at this point in the history
Updates map[string]interface{} and similar to instead use the any alias.
  • Loading branch information
tbroden84 authored and dentarg committed Jun 7, 2024
1 parent 9fc5598 commit 15e3cc0
Show file tree
Hide file tree
Showing 25 changed files with 271 additions and 292 deletions.
16 changes: 8 additions & 8 deletions api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
)

Expand All @@ -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)
)

Expand All @@ -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)
)

Expand Down
30 changes: 14 additions & 16 deletions api/alarms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand All @@ -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)
)

Expand All @@ -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)
)

Expand All @@ -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))
)

Expand All @@ -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)
)

Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 10 additions & 14 deletions api/aws_eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand All @@ -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)
)

Expand All @@ -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)
)

Expand All @@ -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)
)

Expand Down
10 changes: 5 additions & 5 deletions api/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand All @@ -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<username>(.*)):(?P<password>(.*))@`)
match := r.FindStringSubmatch(url)

Expand Down
22 changes: 9 additions & 13 deletions api/custom_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
)
Expand All @@ -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)
)

Expand All @@ -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)

Expand All @@ -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)
)

Expand Down
12 changes: 6 additions & 6 deletions api/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
)

Expand Down
Loading

0 comments on commit 15e3cc0

Please sign in to comment.