Skip to content

Commit cf06152

Browse files
authored
Merge pull request #266 from alexander-ding/enh/migrate-v2
Document structs used in API group interfaces
2 parents 6e21a4a + 3f6d00f commit cf06152

File tree

6 files changed

+92
-17
lines changed

6 files changed

+92
-17
lines changed

pkg/disk/types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type DiskLocation struct {
88
}
99

1010
type ListDiskLocationsRequest struct {
11+
// Intentionally empty
1112
}
1213

1314
type ListDiskLocationsResponse struct {
@@ -21,20 +22,26 @@ type PartitionDiskRequest struct {
2122
}
2223

2324
type PartitionDiskResponse struct {
25+
// Intentionally empty
2426
}
2527

2628
type RescanRequest struct {
29+
// Intentionally empty
2730
}
2831

2932
type RescanResponse struct {
33+
// Intentionally empty
3034
}
3135

3236
type ListDiskIDsRequest struct {
37+
// Intentionally empty
3338
}
3439

3540
type DiskIDs struct {
3641
// Map of Disk ID types and Disk ID values
37-
Page83 string
42+
Page83 string
43+
44+
// The disk serial number
3845
SerialNumber string
3946
}
4047

@@ -44,6 +51,7 @@ type ListDiskIDsResponse struct {
4451
}
4552

4653
type GetDiskStatsRequest struct {
54+
// Disk device number of the disk to get the stats from
4755
DiskNumber uint32
4856
}
4957

pkg/filesystem/types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
package filesystem
22

3-
// PathExistsRequest is the internal representation of requests to the PathExists endpoint.
43
type PathExistsRequest struct {
54
// The path whose existence we want to check in the host's filesystem
65
Path string
76
}
87

9-
// PathExistsResponse is the internal representation of responses from the PathExists endpoint.
108
type PathExistsResponse struct {
119
// Indicates whether the path in PathExistsRequest exists in the host's filesystem
1210
Exists bool
1311
}
1412

15-
// PathValidRequest is the internal representation of requests to the PathValid endpoint.
1613
type PathValidRequest struct {
1714
// The path whose validity we want to check in the host's filesystem
1815
Path string
1916
}
2017

21-
// PathValidResponse is the internal representation of responses from the PathValid endpoint.
2218
type PathValidResponse struct {
2319
// Indicates whether the path in PathValidRequest is a valid path
2420
Valid bool
@@ -47,6 +43,7 @@ type MkdirRequest struct {
4743
}
4844

4945
type MkdirResponse struct {
46+
// Intentionally empty
5047
}
5148

5249
type RmdirRequest struct {
@@ -66,11 +63,13 @@ type RmdirRequest struct {
6663
// Path cannot be a file of type symlink.
6764
// Maximum path length will be capped to 260 characters.
6865
Path string
66+
6967
// Force remove all contents under path (if any).
7068
Force bool
7169
}
7270

7371
type RmdirResponse struct {
72+
// Intentionally empty
7473
}
7574

7675
type RmdirContentsRequest struct {
@@ -93,6 +92,7 @@ type RmdirContentsRequest struct {
9392
}
9493

9594
type RmdirContentsResponse struct {
95+
// Intentionally empty
9696
}
9797

9898
type CreateSymlinkRequest struct {
@@ -111,6 +111,7 @@ type CreateSymlinkRequest struct {
111111
// source_path cannot already exist in the host filesystem.
112112
// Maximum path length will be capped to 260 characters.
113113
SourcePath string
114+
114115
// Target path is the location of the new directory entry to be created in the host's filesystem.
115116
// All special characters allowed by Windows in path names will be allowed
116117
// except for restrictions noted below. For details, please check:
@@ -130,12 +131,15 @@ type CreateSymlinkRequest struct {
130131
}
131132

132133
type CreateSymlinkResponse struct {
134+
// Intentionally empty
133135
}
134136

135137
type IsSymlinkRequest struct {
138+
// The path whose existence as a symlink we want to check in the host's filesystem
136139
Path string
137140
}
138141

139142
type IsSymlinkResponse struct {
143+
// Indicates whether the path in IsSymlinkRequest is a symlink
140144
IsSymlink bool
141145
}

pkg/iscsi/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type DiscoverTargetPortalResponse struct {
7575
type GetTargetDisksRequest struct {
7676
// Target portal whose disks will be queried
7777
TargetPortal *TargetPortal
78+
7879
// IQN of the iSCSI Target
7980
Iqn string
8081
}
@@ -86,6 +87,7 @@ type GetTargetDisksResponse struct {
8687
}
8788

8889
type ListTargetPortalsRequest struct {
90+
// Intentionally empty
8991
}
9092

9193
type ListTargetPortalsResponse struct {
@@ -105,6 +107,7 @@ type RemoveTargetPortalResponse struct {
105107
type TargetPortal struct {
106108
// iSCSI Target (server) address
107109
TargetAddress string
110+
108111
// iSCSI Target port (default iSCSI port is 3260)
109112
TargetPort uint32
110113
}

pkg/smb/types.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
11
package smb
22

33
type NewSMBGlobalMappingRequest struct {
4+
// A remote SMB share to mount
5+
// All unicode characters allowed in SMB server name specifications are
6+
// permitted except for restrictions below
7+
//
8+
// Restrictions:
9+
// SMB remote path specified in the format: \\server-name\sharename, \\server.fqdn\sharename or \\a.b.c.d\sharename
10+
// If not an IP address, share name has to be a valid DNS name.
11+
// UNC specifications to local paths or prefix: \\?\ is not allowed.
12+
// Characters: + [ ] " / : ; | < > , ? * = $ are not allowed
413
RemotePath string
5-
LocalPath string
6-
Username string
7-
Password string
14+
15+
// Optional local path to mount the SMB on
16+
LocalPath string
17+
18+
// Username credential associated with the share
19+
Username string
20+
21+
// Password credential associated with the share
22+
Password string
823
}
924

1025
type NewSMBGlobalMappingResponse struct {
11-
// Intentionally empty.
26+
// Intentionally empty
1227
}
1328

1429
type RemoveSMBGlobalMappingRequest struct {
30+
// A remote SMB share mapping to remove
31+
// All unicode characters allowed in SMB server name specifications are
32+
// permitted except for restrictions below
33+
//
34+
// Restrictions:
35+
// SMB share specified in the format: \\server-name\sharename, \\server.fqdn\sharename or \\a.b.c.d\sharename
36+
// If not an IP address, share name has to be a valid DNS name.
37+
// UNC specifications to local paths or prefix: \\?\ is not allowed.
38+
// Characters: + [ ] " / : ; | < > , ? * = $ are not allowed
1539
RemotePath string
1640
}
1741

1842
type RemoveSMBGlobalMappingResponse struct {
19-
// Intentionally empty.
43+
// Intentionally empty
2044
}

pkg/system/types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package system
22

33
type GetBIOSSerialNumberRequest struct {
4+
// Intentionally empty
45
}
56

67
type GetBIOSSerialNumberResponse struct {
8+
// Serial number
79
SerialNumber string
810
}
911

@@ -30,6 +32,7 @@ type StopServiceResponse struct {
3032

3133
type ServiceStatus uint32
3234

35+
// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status#members
3336
const (
3437
SERVICE_STATUS_UNKNOWN ServiceStatus = iota
3538
SERVICE_STATUS_STOPPED
@@ -43,6 +46,7 @@ const (
4346

4447
type Startype uint32
4548

49+
// https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-changeserviceconfiga
4650
const (
4751
START_TYPE_BOOT Startype = iota
4852
START_TYPE_SYSTEM
@@ -60,9 +64,9 @@ type GetServiceResponse struct {
6064
// Service display name
6165
DisplayName string
6266

63-
// Service start type.
67+
// Service start type
6468
// Used to control whether a service will start on boot, and if so on which
65-
// boot phase.
69+
// boot phase
6670
StartType Startype
6771

6872
// Service status, e.g. stopped, running, paused

pkg/volume/types.go

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,121 @@
11
package volume
22

33
type ListVolumesOnDiskRequest struct {
4-
DiskNumber uint32
4+
// Disk device number of the disk to query for volumes
5+
DiskNumber uint32
6+
7+
// The partition number (optional), by default it uses the first partition of the disk
58
PartitionNumber uint32
69
}
710

811
type ListVolumesOnDiskResponse struct {
12+
// Volume device IDs of volumes on the specified disk
913
VolumeIds []string
1014
}
1115

1216
type MountVolumeRequest struct {
13-
VolumeId string
17+
// Volume device ID of the volume to mount
18+
VolumeId string
19+
20+
// Path in the host's file system where the volume needs to be mounted
1421
TargetPath string
1522
}
1623

1724
type MountVolumeResponse struct {
25+
// Intentionally empty
1826
}
1927

2028
type IsVolumeFormattedRequest struct {
29+
// Volume device ID of the volume to check
2130
VolumeId string
2231
}
2332

2433
type IsVolumeFormattedResponse struct {
34+
// Whether the volume is formatted with NTFS
2535
Formatted bool
2636
}
2737

2838
type FormatVolumeRequest struct {
39+
// Volume device ID of the volume to format
2940
VolumeId string
3041
}
3142

3243
type FormatVolumeResponse struct {
44+
// Intentionally empty
3345
}
3446

3547
type WriteVolumeCacheRequest struct {
48+
// Volume device ID of the volume to flush the cache
3649
VolumeId string
3750
}
3851

3952
type WriteVolumeCacheResponse struct {
53+
// Intentionally empty
4054
}
4155

4256
type UnmountVolumeRequest struct {
43-
VolumeId string
57+
// Volume device ID of the volume to dismount
58+
VolumeId string
59+
60+
// Path where the volume has been mounted
4461
TargetPath string
4562
}
4663

4764
type UnmountVolumeResponse struct {
65+
// Intentionally empty
4866
}
4967

5068
type ResizeVolumeRequest struct {
51-
VolumeId string
69+
// Volume device ID of the volume to resize
70+
VolumeId string
71+
72+
// New size in bytes of the volume
5273
SizeBytes int64
5374
}
5475

5576
type ResizeVolumeResponse struct {
77+
// Intentionally empty
5678
}
5779

5880
type GetVolumeStatsRequest struct {
81+
// Volume device Id of the volume to get the stats for
5982
VolumeId string
6083
}
6184

6285
type GetVolumeStatsResponse struct {
86+
// Total bytes
6387
TotalBytes int64
64-
UsedBytes int64
88+
89+
// Used bytes
90+
UsedBytes int64
6591
}
6692

6793
type GetDiskNumberFromVolumeIDRequest struct {
94+
// Volume device ID of the volume to get the disk number for
6895
VolumeId string
6996
}
7097

7198
type GetDiskNumberFromVolumeIDResponse struct {
99+
// Corresponding disk number
72100
DiskNumber uint32
73101
}
74102

75103
type GetVolumeIDFromTargetPathRequest struct {
104+
// The target path
76105
TargetPath string
77106
}
78107

79108
type GetVolumeIDFromTargetPathResponse struct {
109+
// The volume device ID
80110
VolumeId string
81111
}
82112

83113
type GetClosestVolumeIDFromTargetPathRequest struct {
114+
// The target path
84115
TargetPath string
85116
}
86117

87118
type GetClosestVolumeIDFromTargetPathResponse struct {
119+
// The volume device ID
88120
VolumeId string
89121
}

0 commit comments

Comments
 (0)