Skip to content

Commit

Permalink
added new fields to VolumeSnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealSibasishBehera committed Dec 23, 2024
1 parent 2ffdc71 commit 714d8f8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
18 changes: 9 additions & 9 deletions volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ type VolumeResult struct {

// VolumeConfig are the settings required to create a new Volume
type VolumeConfig struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
ClusterID string `json:"cluster_id"`
NetworkID string `json:"network_id"`
Region string `json:"region"`
SizeGigabytes int `json:"size_gb"`
Bootable bool `json:"bootable"`
VolumeType string `json:"volume_type"`
SnapshotID *string `json:"snapshot_id,omitempty"`
Name string `json:"name"`
Namespace string `json:"namespace"`
ClusterID string `json:"cluster_id"`
NetworkID string `json:"network_id"`
Region string `json:"region"`
SizeGigabytes int `json:"size_gb"`
Bootable bool `json:"bootable"`
VolumeType string `json:"volume_type"`
SnapshotID string `json:"snapshot_id,omitempty"`
}

// VolumeAttachConfig is the configuration used to attach volume
Expand Down
4 changes: 3 additions & 1 deletion volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ type VolumeSnapshot struct {
SnapshotID string `json:"snapshot_id"`
SnapshotDescription string `json:"snapshot_description"`
VolumeID string `json:"volume_id"`
InstanceID string `json:"instance_id,omitempty"`
SourceVolumeName string `json:"source_volume_name"`
RestoreSize int `json:"restore_size"`
State string `json:"state"`
CreationTime string `json:"creation_time"`
CreationTime string `json:"creation_time,omitempty"`
}

// VolumeSnapshotConfig is the configuration for creating a new VolumeSnapshot
Expand Down
8 changes: 8 additions & 0 deletions volume_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func TestListVolumeSnapshots(t *testing.T) {
"snapshot_id": "12345",
"snapshot_description": "snapshot for test",
"volume_id": "12345",
"source_volume_name": "test-volume",
"instance_id": "ins1234",
"restore_size": 20,
"state": "available",
"creation_time": "2020-01-01T00:00:00Z"
Expand All @@ -32,6 +34,8 @@ func TestListVolumeSnapshots(t *testing.T) {
SnapshotID: "12345",
SnapshotDescription: "snapshot for test",
VolumeID: "12345",
SourceVolumeName: "test-volume",
InstanceID: "ins1234",
RestoreSize: 20,
State: "available",
CreationTime: "2020-01-01T00:00:00Z",
Expand All @@ -50,6 +54,8 @@ func TestGetVolumeSnapshot(t *testing.T) {
"snapshot_id": "snapshot-uuid",
"snapshot_description": "snapshot for testing",
"volume_id": "12345",
"source_volume_name": "test-volume",
"instance_id": "ins1234",
"restore_size": 20,
"state": "available",
"creation_time": "2020-01-01T00:00:00Z"
Expand All @@ -68,6 +74,8 @@ func TestGetVolumeSnapshot(t *testing.T) {
SnapshotID: "snapshot-uuid",
SnapshotDescription: "snapshot for testing",
VolumeID: "12345",
SourceVolumeName: "test-volume",
InstanceID: "ins1234",
RestoreSize: 20,
State: "available",
CreationTime: "2020-01-01T00:00:00Z",
Expand Down
12 changes: 12 additions & 0 deletions volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ func TestCreateVolumeSnapshot(t *testing.T) {
"name": "test-snapshot",
"snapshot_description": "snapshot for testing",
"volume_id": "12346",
"instance_id": "instance-123",
"source_volume_name": "source-volume",
"state": "available",
"creation_time": "2020-01-01T00:00:00Z"
}`,
Expand All @@ -285,6 +287,8 @@ func TestCreateVolumeSnapshot(t *testing.T) {
Name: "test-snapshot",
SnapshotDescription: "snapshot for testing",
VolumeID: "12346",
InstanceID: "instance-123",
SourceVolumeName: "source-volume",
State: "available",
CreationTime: "2020-01-01T00:00:00Z",
}
Expand All @@ -300,6 +304,8 @@ func TestGetVolumeSnapshotByVolumeID(t *testing.T) {
"name": "test-snapshot",
"snapshot_description": "snapshot for testing",
"volume_id": "12346",
"instance_id": "instance-123",
"source_volume_name": "source-volume",
"state": "available",
"creation_time": "2020-01-01T00:00:00Z"
}`,
Expand All @@ -317,6 +323,8 @@ func TestGetVolumeSnapshotByVolumeID(t *testing.T) {
Name: "test-snapshot",
SnapshotDescription: "snapshot for testing",
VolumeID: "12346",
InstanceID: "instance-123",
SourceVolumeName: "source-volume",
State: "available",
CreationTime: "2020-01-01T00:00:00Z",
}
Expand All @@ -333,6 +341,8 @@ func TestListVolumeSnapshotsByVolumeID(t *testing.T) {
"name": "test-snapshot",
"snapshot_description": "snapshot for testing",
"volume_id": "12346",
"instance_id": "instance-123",
"source_volume_name": "source-volume",
"state": "available",
"creation_time": "2020-01-01T00:00:00Z"
}]`,
Expand All @@ -351,6 +361,8 @@ func TestListVolumeSnapshotsByVolumeID(t *testing.T) {
Name: "test-snapshot",
SnapshotDescription: "snapshot for testing",
VolumeID: "12346",
InstanceID: "instance-123",
SourceVolumeName: "source-volume",
State: "available",
CreationTime: "2020-01-01T00:00:00Z",
},
Expand Down

0 comments on commit 714d8f8

Please sign in to comment.