Skip to content

Commit

Permalink
Add Tags attribute to droplet create
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-chittenden committed Nov 9, 2016
1 parent 2ff8a02 commit 82ae435
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions droplets.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ type DropletCreateRequest struct {
PrivateNetworking bool `json:"private_networking"`
UserData string `json:"user_data,omitempty"`
Volumes []DropletCreateVolume `json:"volumes,omitempty"`
Tags []string `json:"tags"`
}

// DropletMultiCreateRequest is a request to create multiple droplets.
Expand All @@ -219,6 +220,7 @@ type DropletMultiCreateRequest struct {
IPv6 bool `json:"ipv6"`
PrivateNetworking bool `json:"private_networking"`
UserData string `json:"user_data,omitempty"`
Tags []string `json:"tags"`
}

func (d DropletCreateRequest) String() string {
Expand Down
4 changes: 4 additions & 0 deletions droplets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func TestDroplets_Create(t *testing.T) {
{ID: "hello-im-another-volume"},
{Name: "hello-im-still-a-volume", ID: "should be ignored due to Name"},
},
Tags: []string{"one", "two"},
}

mux.HandleFunc("/v2/droplets", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -169,6 +170,7 @@ func TestDroplets_Create(t *testing.T) {
map[string]interface{}{"id": "hello-im-another-volume"},
map[string]interface{}{"name": "hello-im-still-a-volume"},
},
"tags": []interface{}{"one", "two"},
}

var v map[string]interface{}
Expand Down Expand Up @@ -209,6 +211,7 @@ func TestDroplets_CreateMultiple(t *testing.T) {
Image: DropletCreateImage{
ID: 1,
},
Tags: []string{"one", "two"},
}

mux.HandleFunc("/v2/droplets", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -221,6 +224,7 @@ func TestDroplets_CreateMultiple(t *testing.T) {
"backups": false,
"ipv6": false,
"private_networking": false,
"tags": []interface{}{"one", "two"},
}

var v map[string]interface{}
Expand Down
4 changes: 2 additions & 2 deletions godo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestNewRequest(t *testing.T) {
inBody, outBody := &DropletCreateRequest{Name: "l"},
`{"name":"l","region":"","size":"","image":0,`+
`"ssh_keys":null,"backups":false,"ipv6":false,`+
`"private_networking":false}`+"\n"
`"private_networking":false,"tags":null}`+"\n"
req, _ := c.NewRequest("GET", inURL, inBody)

// test relative URL was expanded
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestNewRequest_withUserData(t *testing.T) {
inBody, outBody := &DropletCreateRequest{Name: "l", UserData: "u"},
`{"name":"l","region":"","size":"","image":0,`+
`"ssh_keys":null,"backups":false,"ipv6":false,`+
`"private_networking":false,"user_data":"u"}`+"\n"
`"private_networking":false,"user_data":"u","tags":null}`+"\n"
req, _ := c.NewRequest("GET", inURL, inBody)

// test relative URL was expanded
Expand Down

0 comments on commit 82ae435

Please sign in to comment.