Skip to content

Commit

Permalink
Merge pull request digitalocean#119 from term1nal/refactor/make-linte…
Browse files Browse the repository at this point in the history
…rs-happy

make linters happy
  • Loading branch information
mauricio authored Dec 22, 2016
2 parents 7c9bf15 + 728210a commit 3ab73e7
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 112 deletions.
44 changes: 22 additions & 22 deletions droplet_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// ActionRequest reprents DigitalOcean Action Request
type ActionRequest map[string]interface{}

// DropletActionsService is an interface for interfacing with the droplet actions
// DropletActionsService is an interface for interfacing with the Droplet actions
// endpoints of the DigitalOcean API
// See: https://developers.digitalocean.com/documentation/v2#droplet-actions
type DropletActionsService interface {
Expand Down Expand Up @@ -43,7 +43,7 @@ type DropletActionsService interface {
GetByURI(string) (*Action, *Response, error)
}

// DropletActionsServiceOp handles communication with the droplet action related
// DropletActionsServiceOp handles communication with the Droplet action related
// methods of the DigitalOcean API.
type DropletActionsServiceOp struct {
client *Client
Expand All @@ -57,7 +57,7 @@ func (s *DropletActionsServiceOp) Shutdown(id int) (*Action, *Response, error) {
return s.doAction(id, request)
}

// Shutdown Droplets by Tag
// ShutdownByTag shuts down Droplets matched by a Tag.
func (s *DropletActionsServiceOp) ShutdownByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "shutdown"}
return s.doActionByTag(tag, request)
Expand All @@ -69,7 +69,7 @@ func (s *DropletActionsServiceOp) PowerOff(id int) (*Action, *Response, error) {
return s.doAction(id, request)
}

// PowerOff a Droplet by Tag
// PowerOffByTag powers off Droplets matched by a Tag.
func (s *DropletActionsServiceOp) PowerOffByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "power_off"}
return s.doActionByTag(tag, request)
Expand All @@ -81,7 +81,7 @@ func (s *DropletActionsServiceOp) PowerOn(id int) (*Action, *Response, error) {
return s.doAction(id, request)
}

// PowerOn a Droplet by Tag
// PowerOnByTag powers on Droplets matched by a Tag.
func (s *DropletActionsServiceOp) PowerOnByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "power_on"}
return s.doActionByTag(tag, request)
Expand All @@ -93,7 +93,7 @@ func (s *DropletActionsServiceOp) PowerCycle(id int) (*Action, *Response, error)
return s.doAction(id, request)
}

// PowerCycle a Droplet by Tag
// PowerCycleByTag power cycles Droplets matched by a Tag.
func (s *DropletActionsServiceOp) PowerCycleByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "power_cycle"}
return s.doActionByTag(tag, request)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (s *DropletActionsServiceOp) Snapshot(id int, name string) (*Action, *Respo
return s.doAction(id, request)
}

// Snapshot a Droplet by Tag
// SnapshotByTag snapshots Droplets matched by a Tag.
func (s *DropletActionsServiceOp) SnapshotByTag(tag string, name string) (*Action, *Response, error) {
requestType := "snapshot"
request := &ActionRequest{
Expand All @@ -156,79 +156,79 @@ func (s *DropletActionsServiceOp) SnapshotByTag(tag string, name string) (*Actio
return s.doActionByTag(tag, request)
}

// EnableBackups enables backups for a droplet.
// EnableBackups enables backups for a Droplet.
func (s *DropletActionsServiceOp) EnableBackups(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "enable_backups"}
return s.doAction(id, request)
}

// EnableBackups enables backups for a droplet by Tag
// EnableBackupsByTag enables backups for Droplets matched by a Tag.
func (s *DropletActionsServiceOp) EnableBackupsByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "enable_backups"}
return s.doActionByTag(tag, request)
}

// DisableBackups disables backups for a droplet.
// DisableBackups disables backups for a Droplet.
func (s *DropletActionsServiceOp) DisableBackups(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "disable_backups"}
return s.doAction(id, request)
}

// DisableBackups disables backups for a droplet by tag
// DisableBackupsByTag disables backups for Droplet matched by a Tag.
func (s *DropletActionsServiceOp) DisableBackupsByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "disable_backups"}
return s.doActionByTag(tag, request)
}

// PasswordReset resets the password for a droplet.
// PasswordReset resets the password for a Droplet.
func (s *DropletActionsServiceOp) PasswordReset(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "password_reset"}
return s.doAction(id, request)
}

// RebuildByImageID rebuilds a droplet droplet from an image with a given id.
// RebuildByImageID rebuilds a Droplet from an image with a given id.
func (s *DropletActionsServiceOp) RebuildByImageID(id, imageID int) (*Action, *Response, error) {
request := &ActionRequest{"type": "rebuild", "image": imageID}
return s.doAction(id, request)
}

// RebuildByImageSlug rebuilds a droplet from an image with a given slug.
// RebuildByImageSlug rebuilds a Droplet from an Image matched by a given Slug.
func (s *DropletActionsServiceOp) RebuildByImageSlug(id int, slug string) (*Action, *Response, error) {
request := &ActionRequest{"type": "rebuild", "image": slug}
return s.doAction(id, request)
}

// ChangeKernel changes the kernel for a droplet.
// ChangeKernel changes the kernel for a Droplet.
func (s *DropletActionsServiceOp) ChangeKernel(id, kernelID int) (*Action, *Response, error) {
request := &ActionRequest{"type": "change_kernel", "kernel": kernelID}
return s.doAction(id, request)
}

// EnableIPv6 enables IPv6 for a droplet.
// EnableIPv6 enables IPv6 for a Droplet.
func (s *DropletActionsServiceOp) EnableIPv6(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "enable_ipv6"}
return s.doAction(id, request)
}

// EnableIPv6 enables IPv6 for a droplet by Tag
// EnableIPv6ByTag enables IPv6 for Droplets matched by a Tag.
func (s *DropletActionsServiceOp) EnableIPv6ByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "enable_ipv6"}
return s.doActionByTag(tag, request)
}

// EnablePrivateNetworking enables private networking for a droplet.
// EnablePrivateNetworking enables private networking for a Droplet.
func (s *DropletActionsServiceOp) EnablePrivateNetworking(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "enable_private_networking"}
return s.doAction(id, request)
}

// EnablePrivateNetworking enables private networking for a droplet by Tag
// EnablePrivateNetworkingByTag enables private networking for Droplets matched by a Tag.
func (s *DropletActionsServiceOp) EnablePrivateNetworkingByTag(tag string) (*Action, *Response, error) {
request := &ActionRequest{"type": "enable_private_networking"}
return s.doActionByTag(tag, request)
}

// Upgrade a droplet.
// Upgrade a Droplet.
func (s *DropletActionsServiceOp) Upgrade(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "upgrade"}
return s.doAction(id, request)
Expand Down Expand Up @@ -284,7 +284,7 @@ func (s *DropletActionsServiceOp) doActionByTag(tag string, request *ActionReque
return root.Event, resp, err
}

// Get an action for a particular droplet by id.
// Get an action for a particular Droplet by id.
func (s *DropletActionsServiceOp) Get(dropletID, actionID int) (*Action, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand All @@ -298,7 +298,7 @@ func (s *DropletActionsServiceOp) Get(dropletID, actionID int) (*Action, *Respon
return s.get(path)
}

// GetByURI gets an action for a particular droplet by id.
// GetByURI gets an action for a particular Droplet by id.
func (s *DropletActionsServiceOp) GetByURI(rawurl string) (*Action, *Response, error) {
u, err := url.Parse(rawurl)
if err != nil {
Expand Down
38 changes: 19 additions & 19 deletions droplets.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const dropletBasePath = "v2/droplets"

var errNoNetworks = errors.New("no networks have been defined")

// DropletsService is an interface for interfacing with the droplet
// DropletsService is an interface for interfacing with the Droplet
// endpoints of the DigitalOcean API
// See: https://developers.digitalocean.com/documentation/v2#droplets
type DropletsService interface {
Expand All @@ -28,7 +28,7 @@ type DropletsService interface {
Neighbors(int) ([]Droplet, *Response, error)
}

// DropletsServiceOp handles communication with the droplet related methods of the
// DropletsServiceOp handles communication with the Droplet related methods of the
// DigitalOcean API.
type DropletsServiceOp struct {
client *Client
Expand Down Expand Up @@ -194,7 +194,7 @@ func (d DropletCreateSSHKey) MarshalJSON() ([]byte, error) {
return json.Marshal(d.ID)
}

// DropletCreateRequest represents a request to create a droplet.
// DropletCreateRequest represents a request to create a Droplet.
type DropletCreateRequest struct {
Name string `json:"name"`
Region string `json:"region"`
Expand All @@ -210,7 +210,7 @@ type DropletCreateRequest struct {
Tags []string `json:"tags"`
}

// DropletMultiCreateRequest is a request to create multiple droplets.
// DropletMultiCreateRequest is a request to create multiple Droplets.
type DropletMultiCreateRequest struct {
Names []string `json:"names"`
Region string `json:"region"`
Expand All @@ -233,13 +233,13 @@ func (d DropletMultiCreateRequest) String() string {
return Stringify(d)
}

// Networks represents the droplet's networks
// Networks represents the Droplet's Networks.
type Networks struct {
V4 []NetworkV4 `json:"v4,omitempty"`
V6 []NetworkV6 `json:"v6,omitempty"`
}

// NetworkV4 represents a DigitalOcean IPv4 Network
// NetworkV4 represents a DigitalOcean IPv4 Network.
type NetworkV4 struct {
IPAddress string `json:"ip_address,omitempty"`
Netmask string `json:"netmask,omitempty"`
Expand All @@ -263,7 +263,7 @@ func (n NetworkV6) String() string {
return Stringify(n)
}

// Performs a list request given a path
// Performs a list request given a path.
func (s *DropletsServiceOp) list(path string) ([]Droplet, *Response, error) {
req, err := s.client.NewRequest("GET", path, nil)
if err != nil {
Expand All @@ -282,7 +282,7 @@ func (s *DropletsServiceOp) list(path string) ([]Droplet, *Response, error) {
return root.Droplets, resp, err
}

// List all droplets
// List all Droplets.
func (s *DropletsServiceOp) List(opt *ListOptions) ([]Droplet, *Response, error) {
path := dropletBasePath
path, err := addOptions(path, opt)
Expand All @@ -293,7 +293,7 @@ func (s *DropletsServiceOp) List(opt *ListOptions) ([]Droplet, *Response, error)
return s.list(path)
}

// List all droplets by tag
// ListByTag lists all Droplets matched by a Tag.
func (s *DropletsServiceOp) ListByTag(tag string, opt *ListOptions) ([]Droplet, *Response, error) {
path := fmt.Sprintf("%s?tag_name=%s", dropletBasePath, tag)
path, err := addOptions(path, opt)
Expand All @@ -304,7 +304,7 @@ func (s *DropletsServiceOp) ListByTag(tag string, opt *ListOptions) ([]Droplet,
return s.list(path)
}

// Get individual droplet
// Get individual Droplet.
func (s *DropletsServiceOp) Get(dropletID int) (*Droplet, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand All @@ -326,7 +326,7 @@ func (s *DropletsServiceOp) Get(dropletID int) (*Droplet, *Response, error) {
return root.Droplet, resp, err
}

// Create droplet
// Create Droplet
func (s *DropletsServiceOp) Create(createRequest *DropletCreateRequest) (*Droplet, *Response, error) {
if createRequest == nil {
return nil, nil, NewArgError("createRequest", "cannot be nil")
Expand All @@ -351,7 +351,7 @@ func (s *DropletsServiceOp) Create(createRequest *DropletCreateRequest) (*Drople
return root.Droplet, resp, err
}

// CreateMultiple creates multiple droplets.
// CreateMultiple creates multiple Droplets.
func (s *DropletsServiceOp) CreateMultiple(createRequest *DropletMultiCreateRequest) ([]Droplet, *Response, error) {
if createRequest == nil {
return nil, nil, NewArgError("createRequest", "cannot be nil")
Expand Down Expand Up @@ -388,7 +388,7 @@ func (s *DropletsServiceOp) delete(path string) (*Response, error) {
return resp, err
}

// Delete droplet
// Delete Droplet.
func (s *DropletsServiceOp) Delete(dropletID int) (*Response, error) {
if dropletID < 1 {
return nil, NewArgError("dropletID", "cannot be less than 1")
Expand All @@ -399,7 +399,7 @@ func (s *DropletsServiceOp) Delete(dropletID int) (*Response, error) {
return s.delete(path)
}

// Delete droplets by tag
// DeleteByTag deletes Droplets matched by a Tag.
func (s *DropletsServiceOp) DeleteByTag(tag string) (*Response, error) {
if tag == "" {
return nil, NewArgError("tag", "cannot be empty")
Expand All @@ -410,7 +410,7 @@ func (s *DropletsServiceOp) DeleteByTag(tag string) (*Response, error) {
return s.delete(path)
}

// Kernels lists kernels available for a droplet.
// Kernels lists kernels available for a Droplet.
func (s *DropletsServiceOp) Kernels(dropletID int, opt *ListOptions) ([]Kernel, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand All @@ -436,7 +436,7 @@ func (s *DropletsServiceOp) Kernels(dropletID int, opt *ListOptions) ([]Kernel,
return root.Kernels, resp, err
}

// Actions lists the actions for a droplet.
// Actions lists the actions for a Droplet.
func (s *DropletsServiceOp) Actions(dropletID int, opt *ListOptions) ([]Action, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand Down Expand Up @@ -465,7 +465,7 @@ func (s *DropletsServiceOp) Actions(dropletID int, opt *ListOptions) ([]Action,
return root.Actions, resp, err
}

// Backups lists the backups for a droplet.
// Backups lists the backups for a Droplet.
func (s *DropletsServiceOp) Backups(dropletID int, opt *ListOptions) ([]Image, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand Down Expand Up @@ -494,7 +494,7 @@ func (s *DropletsServiceOp) Backups(dropletID int, opt *ListOptions) ([]Image, *
return root.Backups, resp, err
}

// Snapshots lists the snapshots available for a droplet.
// Snapshots lists the snapshots available for a Droplet.
func (s *DropletsServiceOp) Snapshots(dropletID int, opt *ListOptions) ([]Image, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand Down Expand Up @@ -523,7 +523,7 @@ func (s *DropletsServiceOp) Snapshots(dropletID int, opt *ListOptions) ([]Image,
return root.Snapshots, resp, err
}

// Neighbors lists the neighbors for a droplet.
// Neighbors lists the neighbors for a Droplet.
func (s *DropletsServiceOp) Neighbors(dropletID int) ([]Droplet, *Response, error) {
if dropletID < 1 {
return nil, nil, NewArgError("dropletID", "cannot be less than 1")
Expand Down
6 changes: 3 additions & 3 deletions godo.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ

buf := new(bytes.Buffer)
if body != nil {
err := json.NewEncoder(buf).Encode(body)
err = json.NewEncoder(buf).Encode(body)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -312,12 +312,12 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {

if v != nil {
if w, ok := v.(io.Writer); ok {
_, err := io.Copy(w, resp.Body)
_, err = io.Copy(w, resp.Body)
if err != nil {
return nil, err
}
} else {
err := json.NewDecoder(resp.Body).Decode(v)
err = json.NewDecoder(resp.Body).Decode(v)
if err != nil {
return nil, err
}
Expand Down
6 changes: 1 addition & 5 deletions links.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ func (l *Links) IsLastPage() bool {
}

func (p *Pages) isLast() bool {
if p.Last == "" {
return true
}

return false
return p.Last == ""
}

func pageForURL(urlText string) (int, error) {
Expand Down
4 changes: 0 additions & 4 deletions regions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ type regionsRoot struct {
Links *Links `json:"links"`
}

type regionRoot struct {
Region *Region
}

func (r Region) String() string {
return Stringify(r)
}
Expand Down
2 changes: 1 addition & 1 deletion snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *SnapshotsServiceOp) ListVolume(opt *ListOptions) ([]Snapshot, *Response
return s.list(opt, &listOpt)
}

// GetByID retrieves an snapshot by id.
// Get retrieves an snapshot by id.
func (s *SnapshotsServiceOp) Get(snapshotID string) (*Snapshot, *Response, error) {
return s.get(interface{}(snapshotID))
}
Expand Down
Loading

0 comments on commit 3ab73e7

Please sign in to comment.