add support for tagging snapshots
This commit is contained in:
parent
69f334e64b
commit
cc58c69571
|
@ -37,6 +37,7 @@ type Snapshot struct {
|
|||
MinDiskSize int `json:"min_disk_size,omitempty"`
|
||||
SizeGigaBytes float64 `json:"size_gigabytes,omitempty"`
|
||||
Created string `json:"created_at,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
type snapshotRoot struct {
|
||||
|
|
|
@ -176,10 +176,11 @@ func TestSnapshot_String(t *testing.T) {
|
|||
MinDiskSize: 20,
|
||||
SizeGigaBytes: 4.84,
|
||||
Created: "2013-11-27T09:24:55Z",
|
||||
Tags: []string{"one", "two"},
|
||||
}
|
||||
|
||||
stringified := snapshot.String()
|
||||
expected := `godo.Snapshot{ID:"1", Name:"Snapsh176ot", ResourceID:"0", ResourceType:"droplet", Regions:["one"], MinDiskSize:20, SizeGigaBytes:4.84, Created:"2013-11-27T09:24:55Z"}`
|
||||
expected := `godo.Snapshot{ID:"1", Name:"Snapsh176ot", ResourceID:"0", ResourceType:"droplet", Regions:["one"], MinDiskSize:20, SizeGigaBytes:4.84, Created:"2013-11-27T09:24:55Z", Tags:["one" "two"]}`
|
||||
if expected != stringified {
|
||||
t.Errorf("Snapshot.String returned %+v, expected %+v", stringified, expected)
|
||||
}
|
||||
|
|
|
@ -178,6 +178,7 @@ type SnapshotCreateRequest struct {
|
|||
VolumeID string `json:"volume_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
// ListSnapshots lists all snapshots related to a storage volume.
|
||||
|
|
|
@ -631,6 +631,7 @@ func TestStorageSnapshots_Create(t *testing.T) {
|
|||
VolumeID: "98d414c6-295e-4e3a-ac58-eb9456c1e1d1",
|
||||
Name: "my snapshot",
|
||||
Description: "my description",
|
||||
Tags: []string{"one", "two"},
|
||||
}
|
||||
|
||||
want := &Snapshot{
|
||||
|
@ -639,6 +640,7 @@ func TestStorageSnapshots_Create(t *testing.T) {
|
|||
Name: "my snapshot",
|
||||
SizeGigaBytes: 100,
|
||||
Created: "2002-10-02T15:00:00.05Z",
|
||||
Tags: []string{"one", "two"},
|
||||
}
|
||||
jBlob := `{
|
||||
"snapshot":{
|
||||
|
@ -647,7 +649,8 @@ func TestStorageSnapshots_Create(t *testing.T) {
|
|||
"name": "my snapshot",
|
||||
"description": "my description",
|
||||
"size_gigabytes": 100,
|
||||
"created_at": "2002-10-02T15:00:00.05Z"
|
||||
"created_at": "2002-10-02T15:00:00.05Z",
|
||||
"tags": ["one", "two"]
|
||||
},
|
||||
"links": {
|
||||
"pages": {
|
||||
|
|
2
tags.go
2
tags.go
|
@ -41,6 +41,8 @@ const (
|
|||
VolumeResourceType ResourceType = "volume"
|
||||
// LoadBalancerResourceType holds the string representing our ResourceType of LoadBalancer.
|
||||
LoadBalancerResourceType ResourceType = "load_balancer"
|
||||
// VolumeSnapshotResourceType holds the string representing our ResourceType for storage Snapshots.
|
||||
VolumeSnapshotResourceType ResourceType = "volumesnapshot"
|
||||
)
|
||||
|
||||
// Resource represent a single resource for associating/disassociating with tags
|
||||
|
|
Loading…
Reference in New Issue