Skip to content

Commit

Permalink
Merge pull request #270 from alexander-ding/enh/rename-api-groups
Browse files Browse the repository at this point in the history
Rename Id to ID
  • Loading branch information
k8s-ci-robot authored Oct 21, 2022
2 parents a2485c0 + aff0587 commit a089fe0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 54 deletions.
10 changes: 5 additions & 5 deletions integrationtests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ func volumeInit(volumeClient volume.Interface, t *testing.T) (*VirtualHardDisk,
t.Fatalf("List response: %v", err)
}

volumeIDsLen := len(listResponse.VolumeIds)
volumeIDsLen := len(listResponse.VolumeIDs)
if volumeIDsLen != 1 {
t.Fatalf("Number of volumes not equal to 1: %d", volumeIDsLen)
}
volumeID := listResponse.VolumeIds[0]
t.Logf("VolumeId %v", volumeID)
volumeID := listResponse.VolumeIDs[0]
t.Logf("VolumeID %v", volumeID)

isVolumeFormattedRequest := &volume.IsVolumeFormattedRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}
isVolumeFormattedResponse, err := volumeClient.IsVolumeFormatted(context.TODO(), isVolumeFormattedRequest)
if err != nil {
Expand All @@ -213,7 +213,7 @@ func volumeInit(volumeClient volume.Interface, t *testing.T) (*VirtualHardDisk,
}

formatVolumeRequest := &volume.FormatVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}
_, err = volumeClient.FormatVolume(context.TODO(), formatVolumeRequest)
if err != nil {
Expand Down
36 changes: 18 additions & 18 deletions integrationtests/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func runNegativeListVolumeRequest(t *testing.T, client volume.Interface, diskNum

func runNegativeIsVolumeFormattedRequest(t *testing.T, client volume.Interface, volumeID string) {
isVolumeFormattedRequest := &volume.IsVolumeFormattedRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}
_, err := client.IsVolumeFormatted(context.TODO(), isVolumeFormattedRequest)
if err == nil {
Expand All @@ -64,7 +64,7 @@ func runNegativeIsVolumeFormattedRequest(t *testing.T, client volume.Interface,

func runNegativeFormatVolumeRequest(t *testing.T, client volume.Interface, volumeID string) {
formatVolumeRequest := &volume.FormatVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}
_, err := client.FormatVolume(context.TODO(), formatVolumeRequest)
if err == nil {
Expand All @@ -74,7 +74,7 @@ func runNegativeFormatVolumeRequest(t *testing.T, client volume.Interface, volum

func runNegativeResizeVolumeRequest(t *testing.T, client volume.Interface, volumeID string, size int64) {
resizeVolumeRequest := &volume.ResizeVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
SizeBytes: size,
}
_, err := client.ResizeVolume(context.TODO(), resizeVolumeRequest)
Expand All @@ -86,7 +86,7 @@ func runNegativeResizeVolumeRequest(t *testing.T, client volume.Interface, volum
func runNegativeMountVolumeRequest(t *testing.T, client volume.Interface, volumeID, targetPath string) {
// Mount the volume
mountVolumeRequest := &volume.MountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: targetPath,
}

Expand All @@ -99,7 +99,7 @@ func runNegativeMountVolumeRequest(t *testing.T, client volume.Interface, volume
func runNegativeUnmountVolumeRequest(t *testing.T, client volume.Interface, volumeID, targetPath string) {
// Unmount the volume
unmountVolumeRequest := &volume.UnmountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: targetPath,
}
_, err := client.UnmountVolume(context.TODO(), unmountVolumeRequest)
Expand All @@ -111,7 +111,7 @@ func runNegativeUnmountVolumeRequest(t *testing.T, client volume.Interface, volu
func runNegativeVolumeStatsRequest(t *testing.T, client volume.Interface, volumeID string) {
// Get VolumeStats
volumeStatsRequest := &volume.GetVolumeStatsRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}
_, err := client.GetVolumeStats(context.TODO(), volumeStatsRequest)
if err == nil {
Expand Down Expand Up @@ -169,7 +169,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient
}
cDriveVolume := strings.TrimSpace(string(targetb))

if response.VolumeId != cDriveVolume {
if response.VolumeID != cDriveVolume {
t.Fatalf("The volume from GetClosestVolumeIDFromTargetPath doesn't match the C: drive volume")
}
})
Expand All @@ -180,7 +180,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient

// Mount the volume
mountVolumeRequest := &volume.MountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: vhd.Mount,
}
_, err = volumeClient.MountVolume(context.TODO(), mountVolumeRequest)
Expand All @@ -191,7 +191,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient
// Unmount the volume
defer func() {
unmountVolumeRequest := &volume.UnmountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: vhd.Mount,
}
_, err = volumeClient.UnmountVolume(context.TODO(), unmountVolumeRequest)
Expand All @@ -215,7 +215,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient
t.Fatalf("GetClosestVolumeIDFromTargetPath request error, err=%v", err)
}

if response.VolumeId != volumeID {
if response.VolumeID != volumeID {
t.Fatalf("The volume from GetClosestVolumeIDFromTargetPath doesn't match the VHD volume=%s", volumeID)
}
})
Expand All @@ -227,7 +227,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient

// Mount the volume
mountVolumeRequest := &volume.MountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: vhd.Mount,
}
_, err = volumeClient.MountVolume(context.TODO(), mountVolumeRequest)
Expand All @@ -238,7 +238,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient
// Unmount the volume
defer func() {
unmountVolumeRequest := &volume.UnmountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: vhd.Mount,
}
_, err = volumeClient.UnmountVolume(context.TODO(), unmountVolumeRequest)
Expand Down Expand Up @@ -270,7 +270,7 @@ func getClosestVolumeFromTargetPathTests(diskClient disk.Interface, volumeClient
t.Fatalf("GetClosestVolumeIDFromTargetPath request error, err=%v", err)
}

if response.VolumeId != volumeID {
if response.VolumeID != volumeID {
t.Fatalf("The volume from GetClosestVolumeIDFromTargetPath doesn't match the VHD volume=%s", volumeID)
}
})
Expand All @@ -281,7 +281,7 @@ func mountVolumeTests(diskClient disk.Interface, volumeClient volume.Interface,
defer vhdCleanup()

volumeStatsRequest := &volume.GetVolumeStatsRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}

volumeStatsResponse, err := volumeClient.GetVolumeStats(context.TODO(), volumeStatsRequest)
Expand Down Expand Up @@ -313,7 +313,7 @@ func mountVolumeTests(diskClient disk.Interface, volumeClient volume.Interface,
// "SizeMax": 2130689536
// }
resizeVolumeRequest := &volume.ResizeVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
// resize the partition to 1.5x times instead
SizeBytes: newVolumeSize,
}
Expand All @@ -335,7 +335,7 @@ func mountVolumeTests(diskClient disk.Interface, volumeClient volume.Interface,
}

volumeDiskNumberRequest := &volume.GetDiskNumberFromVolumeIDRequest{
VolumeId: volumeID,
VolumeID: volumeID,
}

volumeDiskNumberResponse, err := volumeClient.GetDiskNumberFromVolumeID(context.TODO(), volumeDiskNumberRequest)
Expand All @@ -358,7 +358,7 @@ func mountVolumeTests(diskClient disk.Interface, volumeClient volume.Interface,

// Mount the volume
mountVolumeRequest := &volume.MountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: vhd.Mount,
}
_, err = volumeClient.MountVolume(context.TODO(), mountVolumeRequest)
Expand All @@ -368,7 +368,7 @@ func mountVolumeTests(diskClient disk.Interface, volumeClient volume.Interface,

// Unmount the volume
unmountVolumeRequest := &volume.UnmountVolumeRequest{
VolumeId: volumeID,
VolumeID: volumeID,
TargetPath: vhd.Mount,
}
_, err = volumeClient.UnmountVolume(context.TODO(), unmountVolumeRequest)
Expand Down
22 changes: 11 additions & 11 deletions pkg/volume/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ type ListVolumesOnDiskRequest struct {

type ListVolumesOnDiskResponse struct {
// Volume device IDs of volumes on the specified disk
VolumeIds []string
VolumeIDs []string
}

type MountVolumeRequest struct {
// Volume device ID of the volume to mount
VolumeId string
VolumeID string

// Path in the host's file system where the volume needs to be mounted
TargetPath string
Expand All @@ -27,7 +27,7 @@ type MountVolumeResponse struct {

type IsVolumeFormattedRequest struct {
// Volume device ID of the volume to check
VolumeId string
VolumeID string
}

type IsVolumeFormattedResponse struct {
Expand All @@ -37,7 +37,7 @@ type IsVolumeFormattedResponse struct {

type FormatVolumeRequest struct {
// Volume device ID of the volume to format
VolumeId string
VolumeID string
}

type FormatVolumeResponse struct {
Expand All @@ -46,7 +46,7 @@ type FormatVolumeResponse struct {

type WriteVolumeCacheRequest struct {
// Volume device ID of the volume to flush the cache
VolumeId string
VolumeID string
}

type WriteVolumeCacheResponse struct {
Expand All @@ -55,7 +55,7 @@ type WriteVolumeCacheResponse struct {

type UnmountVolumeRequest struct {
// Volume device ID of the volume to dismount
VolumeId string
VolumeID string

// Path where the volume has been mounted
TargetPath string
Expand All @@ -67,7 +67,7 @@ type UnmountVolumeResponse struct {

type ResizeVolumeRequest struct {
// Volume device ID of the volume to resize
VolumeId string
VolumeID string

// New size in bytes of the volume
SizeBytes int64
Expand All @@ -79,7 +79,7 @@ type ResizeVolumeResponse struct {

type GetVolumeStatsRequest struct {
// Volume device Id of the volume to get the stats for
VolumeId string
VolumeID string
}

type GetVolumeStatsResponse struct {
Expand All @@ -92,7 +92,7 @@ type GetVolumeStatsResponse struct {

type GetDiskNumberFromVolumeIDRequest struct {
// Volume device ID of the volume to get the disk number for
VolumeId string
VolumeID string
}

type GetDiskNumberFromVolumeIDResponse struct {
Expand All @@ -107,7 +107,7 @@ type GetVolumeIDFromTargetPathRequest struct {

type GetVolumeIDFromTargetPathResponse struct {
// The volume device ID
VolumeId string
VolumeID string
}

type GetClosestVolumeIDFromTargetPathRequest struct {
Expand All @@ -117,5 +117,5 @@ type GetClosestVolumeIDFromTargetPathRequest struct {

type GetClosestVolumeIDFromTargetPathResponse struct {
// The volume device ID
VolumeId string
VolumeID string
}
28 changes: 14 additions & 14 deletions pkg/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ func (v *Volume) ListVolumesOnDisk(context context.Context, request *ListVolumes
return response, err
}

response.VolumeIds = volumeIDs
response.VolumeIDs = volumeIDs
return response, nil
}

func (v *Volume) MountVolume(context context.Context, request *MountVolumeRequest) (*MountVolumeResponse, error) {
klog.V(2).Infof("MountVolume: Request: %+v", request)
response := &MountVolumeResponse{}

volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
klog.Errorf("volume id empty")
return response, fmt.Errorf("MountVolumeRequest.VolumeId is empty")
return response, fmt.Errorf("MountVolumeRequest.VolumeID is empty")
}
targetPath := request.TargetPath
if targetPath == "" {
Expand All @@ -100,7 +100,7 @@ func (v *Volume) UnmountVolume(context context.Context, request *UnmountVolumeRe
klog.V(2).Infof("UnmountVolume: Request: %+v", request)
response := &UnmountVolumeResponse{}

volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
klog.Errorf("volume id empty")
return response, fmt.Errorf("volume id empty")
Expand All @@ -122,7 +122,7 @@ func (v *Volume) IsVolumeFormatted(context context.Context, request *IsVolumeFor
klog.V(2).Infof("IsVolumeFormatted: Request: %+v", request)
response := &IsVolumeFormattedResponse{}

volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
klog.Errorf("volume id empty")
return response, fmt.Errorf("volume id empty")
Expand All @@ -141,7 +141,7 @@ func (v *Volume) FormatVolume(context context.Context, request *FormatVolumeRequ
klog.V(2).Infof("FormatVolume: Request: %+v", request)
response := &FormatVolumeResponse{}

volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
klog.Errorf("volume id empty")
return response, fmt.Errorf("volume id empty")
Expand All @@ -159,7 +159,7 @@ func (v *Volume) WriteVolumeCache(context context.Context, request *WriteVolumeC
klog.V(2).Infof("WriteVolumeCache: Request: %+v", request)
response := &WriteVolumeCacheResponse{}

volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
klog.Errorf("volume id empty")
return response, fmt.Errorf("volume id empty")
Expand All @@ -177,7 +177,7 @@ func (v *Volume) ResizeVolume(context context.Context, request *ResizeVolumeRequ
klog.V(2).Infof("ResizeVolume: Request: %+v", request)
response := &ResizeVolumeResponse{}

volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
klog.Errorf("volume id empty")
return response, fmt.Errorf("volume id empty")
Expand All @@ -195,7 +195,7 @@ func (v *Volume) ResizeVolume(context context.Context, request *ResizeVolumeRequ

func (v *Volume) GetVolumeStats(context context.Context, request *GetVolumeStatsRequest) (*GetVolumeStatsResponse, error) {
klog.V(2).Infof("GetVolumeStats: Request: %+v", request)
volumeID := request.VolumeId
volumeID := request.VolumeID
if volumeID == "" {
return nil, fmt.Errorf("volume id empty")
}
Expand All @@ -219,12 +219,12 @@ func (v *Volume) GetVolumeStats(context context.Context, request *GetVolumeStats
func (v *Volume) GetDiskNumberFromVolumeID(context context.Context, request *GetDiskNumberFromVolumeIDRequest) (*GetDiskNumberFromVolumeIDResponse, error) {
klog.V(2).Infof("GetDiskNumberFromVolumeID: Request: %+v", request)

volumeId := request.VolumeId
if volumeId == "" {
volumeID := request.VolumeID
if volumeID == "" {
return nil, fmt.Errorf("volume id empty")
}

diskNumber, err := v.hostAPI.GetDiskNumberFromVolumeID(volumeId)
diskNumber, err := v.hostAPI.GetDiskNumberFromVolumeID(volumeID)
if err != nil {
klog.Errorf("failed GetDiskNumberFromVolumeID %v", err)
return nil, err
Expand Down Expand Up @@ -252,7 +252,7 @@ func (v *Volume) GetVolumeIDFromTargetPath(context context.Context, request *Get
}

response := &GetVolumeIDFromTargetPathResponse{
VolumeId: volume,
VolumeID: volume,
}

return response, nil
Expand All @@ -273,7 +273,7 @@ func (v *Volume) GetClosestVolumeIDFromTargetPath(context context.Context, reque
}

response := &GetClosestVolumeIDFromTargetPathResponse{
VolumeId: volume,
VolumeID: volume,
}

return response, nil
Expand Down
Loading

0 comments on commit a089fe0

Please sign in to comment.