Skip to content

Commit 714d8f8

Browse files
added new fields to VolumeSnapshot
1 parent 2ffdc71 commit 714d8f8

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

volume.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ type VolumeResult struct {
3333

3434
// VolumeConfig are the settings required to create a new Volume
3535
type VolumeConfig struct {
36-
Name string `json:"name"`
37-
Namespace string `json:"namespace"`
38-
ClusterID string `json:"cluster_id"`
39-
NetworkID string `json:"network_id"`
40-
Region string `json:"region"`
41-
SizeGigabytes int `json:"size_gb"`
42-
Bootable bool `json:"bootable"`
43-
VolumeType string `json:"volume_type"`
44-
SnapshotID *string `json:"snapshot_id,omitempty"`
36+
Name string `json:"name"`
37+
Namespace string `json:"namespace"`
38+
ClusterID string `json:"cluster_id"`
39+
NetworkID string `json:"network_id"`
40+
Region string `json:"region"`
41+
SizeGigabytes int `json:"size_gb"`
42+
Bootable bool `json:"bootable"`
43+
VolumeType string `json:"volume_type"`
44+
SnapshotID string `json:"snapshot_id,omitempty"`
4545
}
4646

4747
// VolumeAttachConfig is the configuration used to attach volume

volume_snapshot.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ type VolumeSnapshot struct {
1212
SnapshotID string `json:"snapshot_id"`
1313
SnapshotDescription string `json:"snapshot_description"`
1414
VolumeID string `json:"volume_id"`
15+
InstanceID string `json:"instance_id,omitempty"`
16+
SourceVolumeName string `json:"source_volume_name"`
1517
RestoreSize int `json:"restore_size"`
1618
State string `json:"state"`
17-
CreationTime string `json:"creation_time"`
19+
CreationTime string `json:"creation_time,omitempty"`
1820
}
1921

2022
// VolumeSnapshotConfig is the configuration for creating a new VolumeSnapshot

volume_snapshot_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ func TestListVolumeSnapshots(t *testing.T) {
1212
"snapshot_id": "12345",
1313
"snapshot_description": "snapshot for test",
1414
"volume_id": "12345",
15+
"source_volume_name": "test-volume",
16+
"instance_id": "ins1234",
1517
"restore_size": 20,
1618
"state": "available",
1719
"creation_time": "2020-01-01T00:00:00Z"
@@ -32,6 +34,8 @@ func TestListVolumeSnapshots(t *testing.T) {
3234
SnapshotID: "12345",
3335
SnapshotDescription: "snapshot for test",
3436
VolumeID: "12345",
37+
SourceVolumeName: "test-volume",
38+
InstanceID: "ins1234",
3539
RestoreSize: 20,
3640
State: "available",
3741
CreationTime: "2020-01-01T00:00:00Z",
@@ -50,6 +54,8 @@ func TestGetVolumeSnapshot(t *testing.T) {
5054
"snapshot_id": "snapshot-uuid",
5155
"snapshot_description": "snapshot for testing",
5256
"volume_id": "12345",
57+
"source_volume_name": "test-volume",
58+
"instance_id": "ins1234",
5359
"restore_size": 20,
5460
"state": "available",
5561
"creation_time": "2020-01-01T00:00:00Z"
@@ -68,6 +74,8 @@ func TestGetVolumeSnapshot(t *testing.T) {
6874
SnapshotID: "snapshot-uuid",
6975
SnapshotDescription: "snapshot for testing",
7076
VolumeID: "12345",
77+
SourceVolumeName: "test-volume",
78+
InstanceID: "ins1234",
7179
RestoreSize: 20,
7280
State: "available",
7381
CreationTime: "2020-01-01T00:00:00Z",

volume_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ func TestCreateVolumeSnapshot(t *testing.T) {
268268
"name": "test-snapshot",
269269
"snapshot_description": "snapshot for testing",
270270
"volume_id": "12346",
271+
"instance_id": "instance-123",
272+
"source_volume_name": "source-volume",
271273
"state": "available",
272274
"creation_time": "2020-01-01T00:00:00Z"
273275
}`,
@@ -285,6 +287,8 @@ func TestCreateVolumeSnapshot(t *testing.T) {
285287
Name: "test-snapshot",
286288
SnapshotDescription: "snapshot for testing",
287289
VolumeID: "12346",
290+
InstanceID: "instance-123",
291+
SourceVolumeName: "source-volume",
288292
State: "available",
289293
CreationTime: "2020-01-01T00:00:00Z",
290294
}
@@ -300,6 +304,8 @@ func TestGetVolumeSnapshotByVolumeID(t *testing.T) {
300304
"name": "test-snapshot",
301305
"snapshot_description": "snapshot for testing",
302306
"volume_id": "12346",
307+
"instance_id": "instance-123",
308+
"source_volume_name": "source-volume",
303309
"state": "available",
304310
"creation_time": "2020-01-01T00:00:00Z"
305311
}`,
@@ -317,6 +323,8 @@ func TestGetVolumeSnapshotByVolumeID(t *testing.T) {
317323
Name: "test-snapshot",
318324
SnapshotDescription: "snapshot for testing",
319325
VolumeID: "12346",
326+
InstanceID: "instance-123",
327+
SourceVolumeName: "source-volume",
320328
State: "available",
321329
CreationTime: "2020-01-01T00:00:00Z",
322330
}
@@ -333,6 +341,8 @@ func TestListVolumeSnapshotsByVolumeID(t *testing.T) {
333341
"name": "test-snapshot",
334342
"snapshot_description": "snapshot for testing",
335343
"volume_id": "12346",
344+
"instance_id": "instance-123",
345+
"source_volume_name": "source-volume",
336346
"state": "available",
337347
"creation_time": "2020-01-01T00:00:00Z"
338348
}]`,
@@ -351,6 +361,8 @@ func TestListVolumeSnapshotsByVolumeID(t *testing.T) {
351361
Name: "test-snapshot",
352362
SnapshotDescription: "snapshot for testing",
353363
VolumeID: "12346",
364+
InstanceID: "instance-123",
365+
SourceVolumeName: "source-volume",
354366
State: "available",
355367
CreationTime: "2020-01-01T00:00:00Z",
356368
},

0 commit comments

Comments
 (0)