Skip to content

Commit

Permalink
style: format go code
Browse files Browse the repository at this point in the history
  • Loading branch information
mondragonfx committed Mar 15, 2023
1 parent 40eb1a8 commit b6d7370
Show file tree
Hide file tree
Showing 49 changed files with 650 additions and 651 deletions.
4 changes: 2 additions & 2 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (a *AccountServiceHandler) Get(ctx context.Context) (*Account, *http.Respon

account := new(accountBase)
resp, err := a.client.DoWithContext(ctx, req, account)
if err != nil {
return nil,resp, err
if err != nil {
return nil, resp, err
}

return account.Account, resp, nil
Expand Down
1 change: 0 additions & 1 deletion account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestAccountServiceHandler_Get(t *testing.T) {
t.Errorf("Account.Get returned error: %v", err)
}


expected := &Account{Balance: -5519.11, PendingCharges: 57.03, LastPaymentDate: "2014-07-18 15:31:01", LastPaymentAmount: -1.00, Name: "Test Tester", Email: "[email protected]", ACL: []string{"subscriptions", "billing", "support", "provisioning"}}

if !reflect.DeepEqual(account, expected) {
Expand Down
14 changes: 7 additions & 7 deletions application.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// ApplicationService is the interface to interact with the Application endpoint on the Vultr API.
// Link : https://www.vultr.com/api/#tag/application
type ApplicationService interface {
List(ctx context.Context, options *ListOptions) ([]Application, *Meta,*http.Response, error)
List(ctx context.Context, options *ListOptions) ([]Application, *Meta, *http.Response, error)
}

// ApplicationServiceHandler handles interaction with the application methods for the Vultr API.
Expand All @@ -35,26 +35,26 @@ type applicationBase struct {
}

// List retrieves a list of available applications that can be launched when creating a Vultr instance
func (a *ApplicationServiceHandler) List(ctx context.Context, options *ListOptions) ([]Application, *Meta,*http.Response, error) {
func (a *ApplicationServiceHandler) List(ctx context.Context, options *ListOptions) ([]Application, *Meta, *http.Response, error) {
uri := "/v2/applications"

req, err := a.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil,nil, err
return nil, nil, nil, err
}

newValues, err := query.Values(options)
if err != nil {
return nil, nil,nil, err
return nil, nil, nil, err
}

req.URL.RawQuery = newValues.Encode()
apps := new(applicationBase)

resp,err := a.client.DoWithContext(ctx, req, apps)
resp, err := a.client.DoWithContext(ctx, req, apps)
if err != nil {
return nil, nil,resp, err
return nil, nil, resp, err
}

return apps.Applications, apps.Meta,resp, nil
return apps.Applications, apps.Meta, resp, nil
}
2 changes: 1 addition & 1 deletion application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestApplicationServiceHandler_List(t *testing.T) {
PerPage: 1,
Cursor: "",
}
apps, meta,_, err := client.Application.List(ctx, options)
apps, meta, _, err := client.Application.List(ctx, options)
if err != nil {
t.Errorf("Application.List returned error: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestBackupServiceHandler_GetEmpty(t *testing.T) {
fmt.Fprint(w, response)
})

backup,_, err := client.Backup.Get(ctx, "543d34149403a")
backup, _, err := client.Backup.Get(ctx, "543d34149403a")
if err != nil {
t.Errorf("Backup.Get returned error: %v", err)
}
Expand Down
76 changes: 38 additions & 38 deletions bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ const bmPath = "/v2/bare-metals"
// BareMetalServerService is the interface to interact with the Bare Metal endpoints on the Vultr API
// Link : https://www.vultr.com/api/#tag/baremetal
type BareMetalServerService interface {
Create(ctx context.Context, bmCreate *BareMetalCreate) (*BareMetalServer,*http.Response, error)
Create(ctx context.Context, bmCreate *BareMetalCreate) (*BareMetalServer, *http.Response, error)
Get(ctx context.Context, serverID string) (*BareMetalServer, *http.Response, error)
Update(ctx context.Context, serverID string, bmReq *BareMetalUpdate) (*BareMetalServer, *http.Response, error)
Delete(ctx context.Context, serverID string) error
List(ctx context.Context, options *ListOptions) ([]BareMetalServer, *Meta,*http.Response, error)
List(ctx context.Context, options *ListOptions) ([]BareMetalServer, *Meta, *http.Response, error)

GetBandwidth(ctx context.Context, serverID string) (*Bandwidth,*http.Response, error)
GetUserData(ctx context.Context, serverID string) (*UserData, *http.Response,error)
GetVNCUrl(ctx context.Context, serverID string) (*VNCUrl,*http.Response, error)
GetBandwidth(ctx context.Context, serverID string) (*Bandwidth, *http.Response, error)
GetUserData(ctx context.Context, serverID string) (*UserData, *http.Response, error)
GetVNCUrl(ctx context.Context, serverID string) (*VNCUrl, *http.Response, error)

ListIPv4s(ctx context.Context, serverID string, options *ListOptions) ([]IPv4, *Meta,*http.Response, error)
ListIPv6s(ctx context.Context, serverID string, options *ListOptions) ([]IPv6, *Meta,*http.Response, error)
ListIPv4s(ctx context.Context, serverID string, options *ListOptions) ([]IPv4, *Meta, *http.Response, error)
ListIPv6s(ctx context.Context, serverID string, options *ListOptions) ([]IPv6, *Meta, *http.Response, error)

Halt(ctx context.Context, serverID string) error
Reboot(ctx context.Context, serverID string) error
Expand Down Expand Up @@ -146,18 +146,18 @@ func (b *BareMetalServerServiceHandler) Create(ctx context.Context, bmCreate *Ba
bm := new(bareMetalBase)
resp, err := b.client.DoWithContext(ctx, req, bm)
if err != nil {
return nil,resp, err
return nil, resp, err
}

return bm.BareMetal,resp, nil
return bm.BareMetal, resp, nil
}

// Get information for a Bare Metal instance.
func (b *BareMetalServerServiceHandler) Get(ctx context.Context, serverID string) (*BareMetalServer,*http.Response, error) {
func (b *BareMetalServerServiceHandler) Get(ctx context.Context, serverID string) (*BareMetalServer, *http.Response, error) {
uri := fmt.Sprintf("%s/%s", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil,nil,err
return nil, nil, err
}

bms := new(bareMetalBase)
Expand All @@ -166,15 +166,15 @@ func (b *BareMetalServerServiceHandler) Get(ctx context.Context, serverID string
return nil, resp, err
}

return bms.BareMetal,resp, nil
return bms.BareMetal, resp, nil
}

// Update a Bare Metal server
func (b *BareMetalServerServiceHandler) Update(ctx context.Context, serverID string, bmReq *BareMetalUpdate) (*BareMetalServer,*http.Response,error) {
func (b *BareMetalServerServiceHandler) Update(ctx context.Context, serverID string, bmReq *BareMetalUpdate) (*BareMetalServer, *http.Response, error) {
uri := fmt.Sprintf("%s/%s", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodPatch, uri, bmReq)
if err != nil {
return nil,nil, err
return nil, nil, err
}

bms := new(bareMetalBase)
Expand All @@ -183,7 +183,7 @@ func (b *BareMetalServerServiceHandler) Update(ctx context.Context, serverID str
return nil, resp, err
}

return bms.BareMetal,resp, nil
return bms.BareMetal, resp, nil
}

// Delete a Bare Metal server.
Expand All @@ -193,7 +193,7 @@ func (b *BareMetalServerServiceHandler) Delete(ctx context.Context, serverID str
if err != nil {
return nil
}
_, err = b.client.DoWithContext(ctx, req, nil)
_, err = b.client.DoWithContext(ctx, req, nil)
return err
}

Expand All @@ -214,14 +214,14 @@ func (b *BareMetalServerServiceHandler) List(ctx context.Context, options *ListO
bms := new(bareMetalsBase)
resp, err := b.client.DoWithContext(ctx, req, bms)
if err != nil {
return nil, nil,resp, err
return nil, nil, resp, err
}

return bms.BareMetals, bms.Meta, resp, nil
}

// GetBandwidth used by a Bare Metal server.
func (b *BareMetalServerServiceHandler) GetBandwidth(ctx context.Context, serverID string) (*Bandwidth,*http.Response, error) {
func (b *BareMetalServerServiceHandler) GetBandwidth(ctx context.Context, serverID string) (*Bandwidth, *http.Response, error) {
uri := fmt.Sprintf("%s/%s/bandwidth", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
Expand All @@ -242,11 +242,11 @@ func (b *BareMetalServerServiceHandler) GetUserData(ctx context.Context, serverI
uri := fmt.Sprintf("%s/%s/user-data", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil,nil, err
return nil, nil, err
}

userData := new(userDataBase)
resp,err := b.client.DoWithContext(ctx, req, userData)
resp, err := b.client.DoWithContext(ctx, req, userData)
if err != nil {
return nil, nil, err
}
Expand All @@ -255,17 +255,17 @@ func (b *BareMetalServerServiceHandler) GetUserData(ctx context.Context, serverI
}

// GetVNCUrl gets the vnc url for a given Bare Metal server.
func (b *BareMetalServerServiceHandler) GetVNCUrl(ctx context.Context, serverID string) (*VNCUrl, *http.Response, error) {
func (b *BareMetalServerServiceHandler) GetVNCUrl(ctx context.Context, serverID string) (*VNCUrl, *http.Response, error) {
uri := fmt.Sprintf("%s/%s/vnc", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}

vnc := new(vncBase)
resp,err := b.client.DoWithContext(ctx, req, vnc)
resp, err := b.client.DoWithContext(ctx, req, vnc)
if err != nil {
return nil,resp, err
return nil, resp, err
}

return vnc.VNCUrl, resp, nil
Expand All @@ -277,18 +277,18 @@ func (b *BareMetalServerServiceHandler) ListIPv4s(ctx context.Context, serverID
uri := fmt.Sprintf("%s/%s/ipv4", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil,nil,err
return nil, nil, nil, err
}

newValues, err := query.Values(options)
if err != nil {
return nil, nil,nil, err
return nil, nil, nil, err
}

req.URL.RawQuery = newValues.Encode()

ipv4 := new(ipBase)
resp, err := b.client.DoWithContext(ctx, req, ipv4)
resp, err := b.client.DoWithContext(ctx, req, ipv4)
if err != nil {
return nil, nil, resp, err
}
Expand All @@ -303,20 +303,20 @@ func (b *BareMetalServerServiceHandler) ListIPv6s(ctx context.Context, serverID
uri := fmt.Sprintf("%s/%s/ipv6", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil,nil, err
return nil, nil, nil, err
}

newValues, err := query.Values(options)
if err != nil {
return nil, nil,nil, err
return nil, nil, nil, err
}

req.URL.RawQuery = newValues.Encode()

ipv6 := new(ipBase)
resp, err := b.client.DoWithContext(ctx, req, ipv6)
resp, err := b.client.DoWithContext(ctx, req, ipv6)
if err != nil {
return nil, nil,resp, err
return nil, nil, resp, err
}

return ipv6.IPv6s, ipv6.Meta, resp, nil
Expand All @@ -332,7 +332,7 @@ func (b *BareMetalServerServiceHandler) Halt(ctx context.Context, serverID strin
return err
}

_, err = b.client.DoWithContext(ctx, req, nil)
_, err = b.client.DoWithContext(ctx, req, nil)
return err
}

Expand Down Expand Up @@ -363,7 +363,7 @@ func (b *BareMetalServerServiceHandler) Start(ctx context.Context, serverID stri

// Reinstall the operating system on a Bare Metal server.
// All data will be permanently lost, but the IP address will remain the same.
func (b *BareMetalServerServiceHandler) Reinstall(ctx context.Context, serverID string) (*BareMetalServer, *http.Response,error) {
func (b *BareMetalServerServiceHandler) Reinstall(ctx context.Context, serverID string) (*BareMetalServer, *http.Response, error) {
uri := fmt.Sprintf("%s/%s/reinstall", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodPost, uri, nil)
if err != nil {
Expand All @@ -376,7 +376,7 @@ func (b *BareMetalServerServiceHandler) Reinstall(ctx context.Context, serverID
return nil, resp, err
}

return bms.BareMetal,resp, nil
return bms.BareMetal, resp, nil
}

// MassStart will start a list of Bare Metal servers the machine is already running, it will be restarted.
Expand Down Expand Up @@ -419,18 +419,18 @@ func (b *BareMetalServerServiceHandler) MassReboot(ctx context.Context, serverLi
}

// GetUpgrades that are available for a Bare Metal server.
func (b *BareMetalServerServiceHandler) GetUpgrades(ctx context.Context, serverID string) (*Upgrades, *http.Response,error) {
func (b *BareMetalServerServiceHandler) GetUpgrades(ctx context.Context, serverID string) (*Upgrades, *http.Response, error) {
uri := fmt.Sprintf("%s/%s/upgrades", bmPath, serverID)
req, err := b.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil,nil, err
return nil, nil, err
}

upgrades := new(upgradeBase)
resp,err := b.client.DoWithContext(ctx, req, upgrades)
resp, err := b.client.DoWithContext(ctx, req, upgrades)
if err != nil {
return nil,resp, err
return nil, resp, err
}

return upgrades.Upgrades,resp,nil
return upgrades.Upgrades, resp, nil
}
Loading

0 comments on commit b6d7370

Please sign in to comment.