Skip to content

Commit 5da96a3

Browse files
authored
Merge pull request #268 from alexander-ding/enh/migrate-v2
Rename API to HostAPI
2 parents b36b549 + 0a2b8ff commit 5da96a3

25 files changed

+61
-58
lines changed

integrationtests/disk_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/kubernetes-csi/csi-proxy/pkg/disk"
13-
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/api"
13+
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/hostapi"
1414
"github.com/stretchr/testify/assert"
1515
"github.com/stretchr/testify/require"
1616
)

integrationtests/filesystem_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/stretchr/testify/require"
1616

1717
"github.com/kubernetes-csi/csi-proxy/pkg/filesystem"
18-
filesystemapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/api"
18+
filesystemapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/hostapi"
1919
)
2020

2121
func TestFilesystem(t *testing.T) {

integrationtests/iscsi_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"testing"
88

99
disk "github.com/kubernetes-csi/csi-proxy/pkg/disk"
10-
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/api"
10+
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/hostapi"
1111
iscsi "github.com/kubernetes-csi/csi-proxy/pkg/iscsi"
12-
iscsiapi "github.com/kubernetes-csi/csi-proxy/pkg/iscsi/api"
12+
iscsiapi "github.com/kubernetes-csi/csi-proxy/pkg/iscsi/hostapi"
1313
system "github.com/kubernetes-csi/csi-proxy/pkg/system"
14-
systemapi "github.com/kubernetes-csi/csi-proxy/pkg/system/api"
14+
systemapi "github.com/kubernetes-csi/csi-proxy/pkg/system/hostapi"
1515

1616
"github.com/stretchr/testify/assert"
1717
"github.com/stretchr/testify/require"

integrationtests/smb_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"github.com/stretchr/testify/require"
1616

1717
fs "github.com/kubernetes-csi/csi-proxy/pkg/filesystem"
18-
fsapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/api"
18+
fsapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/hostapi"
1919
"github.com/kubernetes-csi/csi-proxy/pkg/smb"
20-
smbapi "github.com/kubernetes-csi/csi-proxy/pkg/smb/api"
20+
smbapi "github.com/kubernetes-csi/csi-proxy/pkg/smb/hostapi"
2121
)
2222

2323
func TestSMB(t *testing.T) {

integrationtests/system_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"testing"
1010

1111
system "github.com/kubernetes-csi/csi-proxy/pkg/system"
12-
systemapi "github.com/kubernetes-csi/csi-proxy/pkg/system/api"
12+
systemapi "github.com/kubernetes-csi/csi-proxy/pkg/system/hostapi"
1313

1414
"github.com/stretchr/testify/assert"
1515
"github.com/stretchr/testify/require"

integrationtests/volume_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"testing"
1010

1111
disk "github.com/kubernetes-csi/csi-proxy/pkg/disk"
12-
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/api"
12+
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/hostapi"
1313
volume "github.com/kubernetes-csi/csi-proxy/pkg/volume"
14-
volumeapi "github.com/kubernetes-csi/csi-proxy/pkg/volume/api"
14+
volumeapi "github.com/kubernetes-csi/csi-proxy/pkg/volume/hostapi"
1515

1616
"github.com/stretchr/testify/require"
1717
)

pkg/disk/disk.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package disk
33
import (
44
"context"
55

6-
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/api"
6+
diskapi "github.com/kubernetes-csi/csi-proxy/pkg/disk/hostapi"
77
"k8s.io/klog/v2"
88
)
99

1010
type Disk struct {
11-
hostAPI diskapi.API
11+
hostAPI diskapi.HostAPI
1212
}
1313

1414
type Interface interface {
@@ -39,7 +39,7 @@ type Interface interface {
3939
// check that Disk implements Interface
4040
var _ Interface = &Disk{}
4141

42-
func New(hostAPI diskapi.API) (*Disk, error) {
42+
func New(hostAPI diskapi.HostAPI) (*Disk, error) {
4343
return &Disk{
4444
hostAPI: hostAPI,
4545
}, nil

pkg/disk/api/api.go renamed to pkg/disk/hostapi/hostapi.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const (
2323
IOCTL_STORAGE_QUERY_PROPERTY = 0x002d1400
2424
)
2525

26-
// API declares the interface exposed by the internal API
27-
type API interface {
26+
// HostAPI declares the interface exposed by the internal API
27+
type HostAPI interface {
2828
// ListDiskLocations - constructs a map with the disk number as the key and the DiskLocation structure
2929
// as the value. The DiskLocation struct has various fields like the Adapter, Bus, Target and LUNID.
3030
ListDiskLocations() (map[uint32]DiskLocation, error)
@@ -55,7 +55,7 @@ type API interface {
5555
type DiskAPI struct{}
5656

5757
// ensure that DiskAPI implements the exposed API
58-
var _ API = &DiskAPI{}
58+
var _ HostAPI = &DiskAPI{}
5959

6060
func New() DiskAPI {
6161
return DiskAPI{}
File renamed without changes.

pkg/filesystem/filesystem.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package filesystem
33
import (
44
"context"
55

6-
filesystemapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/api"
6+
filesystemapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/hostapi"
77
"k8s.io/klog/v2"
88
)
99

1010
type Filesystem struct {
11-
hostAPI filesystemapi.API
11+
hostAPI filesystemapi.HostAPI
1212
}
1313

1414
type Interface interface {
@@ -41,7 +41,7 @@ type Interface interface {
4141
// check that Filesystem implements Interface
4242
var _ Interface = &Filesystem{}
4343

44-
func New(hostAPI filesystemapi.API) (*Filesystem, error) {
44+
func New(hostAPI filesystemapi.HostAPI) (*Filesystem, error) {
4545
return &Filesystem{
4646
hostAPI: hostAPI,
4747
}, nil

pkg/filesystem/filesystem_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"context"
55
"testing"
66

7-
fsapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/api"
7+
fsapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/hostapi"
88
)
99

1010
type fakeFileSystemAPI struct{}
1111

12-
var _ fsapi.API = &fakeFileSystemAPI{}
12+
var _ fsapi.HostAPI = &fakeFileSystemAPI{}
1313

1414
func (fakeFileSystemAPI) PathExists(path string) (bool, error) {
1515
return true, nil

pkg/filesystem/api/api.go renamed to pkg/filesystem/hostapi/hotsapi.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
// pkg/filesystem/filesystem.go so that logic can be easily unit-tested
1515
// without requiring specific OS environments.
1616

17-
// API is the exposed Filesystem API
18-
type API interface {
17+
// HostAPI is the exposed Filesystem API
18+
type HostAPI interface {
1919
PathExists(path string) (bool, error)
2020
PathValid(path string) (bool, error)
2121
Mkdir(path string) error
@@ -27,10 +27,10 @@ type API interface {
2727

2828
type filesystemAPI struct{}
2929

30-
// check that filesystemAPI implements API
31-
var _ API = &filesystemAPI{}
30+
// check that filesystemAPI implements HostAPI
31+
var _ HostAPI = &filesystemAPI{}
3232

33-
func New() API {
33+
func New() HostAPI {
3434
return filesystemAPI{}
3535
}
3636

pkg/iscsi/api/api.go renamed to pkg/iscsi/hostapi/hostapi.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// pkg/iscsi/iscsi.go so that logic can be easily unit-tested
1313
// without requiring specific OS environments.
1414

15-
type API interface {
15+
type HostAPI interface {
1616
AddTargetPortal(portal *TargetPortal) error
1717
DiscoverTargetPortal(portal *TargetPortal) ([]string, error)
1818
ListTargetPortals() ([]TargetPortal, error)
@@ -26,10 +26,10 @@ type API interface {
2626

2727
type iscsiAPI struct{}
2828

29-
// check that iscsiAPI implements API
30-
var _ API = &iscsiAPI{}
29+
// check that iscsiAPI implements HostAPI
30+
var _ HostAPI = &iscsiAPI{}
3131

32-
func New() API {
32+
func New() HostAPI {
3333
return iscsiAPI{}
3434
}
3535

File renamed without changes.

pkg/iscsi/iscsi.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import (
44
"context"
55
"fmt"
66

7-
iscsiapi "github.com/kubernetes-csi/csi-proxy/pkg/iscsi/api"
7+
iscsiapi "github.com/kubernetes-csi/csi-proxy/pkg/iscsi/hostapi"
88
"k8s.io/klog/v2"
99
)
1010

1111
const defaultISCSIPort = 3260
1212

1313
type ISCSI struct {
14-
hostAPI iscsiapi.API
14+
hostAPI iscsiapi.HostAPI
1515
}
1616

1717
type Interface interface {
@@ -53,7 +53,7 @@ type Interface interface {
5353

5454
var _ Interface = &ISCSI{}
5555

56-
func New(hostAPI iscsiapi.API) (*ISCSI, error) {
56+
func New(hostAPI iscsiapi.HostAPI) (*ISCSI, error) {
5757
return &ISCSI{
5858
hostAPI: hostAPI,
5959
}, nil

pkg/smb/api/api.go renamed to pkg/smb/hostapi/hostapi.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/kubernetes-csi/csi-proxy/pkg/utils"
88
)
99

10-
type API interface {
10+
type HostAPI interface {
1111
IsSMBMapped(remotePath string) (bool, error)
1212
NewSMBLink(remotePath, localPath string) error
1313
NewSMBGlobalMapping(remotePath, username, password string) error
@@ -16,9 +16,9 @@ type API interface {
1616

1717
type smbAPI struct{}
1818

19-
var _ API = &smbAPI{}
19+
var _ HostAPI = &smbAPI{}
2020

21-
func New() API {
21+
func New() HostAPI {
2222
return smbAPI{}
2323
}
2424

pkg/smb/smb.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"strings"
77

88
fs "github.com/kubernetes-csi/csi-proxy/pkg/filesystem"
9-
smbapi "github.com/kubernetes-csi/csi-proxy/pkg/smb/api"
9+
smbapi "github.com/kubernetes-csi/csi-proxy/pkg/smb/hostapi"
1010
"k8s.io/klog/v2"
1111
)
1212

1313
type SMB struct {
14-
hostAPI smbapi.API
14+
hostAPI smbapi.HostAPI
1515
fs fs.Interface
1616
}
1717

@@ -51,7 +51,7 @@ func getRootMappingPath(path string) (string, error) {
5151
return strings.ToLower("\\\\" + parts[0] + "\\" + parts[1]), nil
5252
}
5353

54-
func New(hostAPI smbapi.API, fsClient fs.Interface) (*SMB, error) {
54+
func New(hostAPI smbapi.HostAPI, fsClient fs.Interface) (*SMB, error) {
5555
return &SMB{
5656
hostAPI: hostAPI,
5757
fs: fsClient,

pkg/smb/smb_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"testing"
66

77
fs "github.com/kubernetes-csi/csi-proxy/pkg/filesystem"
8-
fsapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/api"
9-
smbapi "github.com/kubernetes-csi/csi-proxy/pkg/smb/api"
8+
fsapi "github.com/kubernetes-csi/csi-proxy/pkg/filesystem/hostapi"
9+
smbapi "github.com/kubernetes-csi/csi-proxy/pkg/smb/hostapi"
1010
)
1111

1212
type fakeSMBAPI struct{}
1313

14-
var _ smbapi.API = &fakeSMBAPI{}
14+
var _ smbapi.HostAPI = &fakeSMBAPI{}
1515

1616
func (fakeSMBAPI) NewSMBGlobalMapping(remotePath, username, password string) error {
1717
return nil
@@ -31,7 +31,7 @@ func (fakeSMBAPI) NewSMBLink(remotePath, localPath string) error {
3131

3232
type fakeFileSystemAPI struct{}
3333

34-
var _ fsapi.API = &fakeFileSystemAPI{}
34+
var _ fsapi.HostAPI = &fakeFileSystemAPI{}
3535

3636
func (fakeFileSystemAPI) PathExists(path string) (bool, error) {
3737
return true, nil

pkg/system/api/api.go renamed to pkg/system/hostapi/hostapi.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// pkg/system/system.go so that logic can be easily unit-tested
1515
// without requiring specific OS environments.
1616

17-
type API interface {
17+
type HostAPI interface {
1818
GetBIOSSerialNumber() (string, error)
1919
GetService(name string) (*ServiceInfo, error)
2020
StartService(name string) error
@@ -23,7 +23,10 @@ type API interface {
2323

2424
type systemAPI struct{}
2525

26-
func New() API {
26+
// check that systemAPI implements HostAPI
27+
var _ HostAPI = &systemAPI{}
28+
29+
func New() HostAPI {
2730
return systemAPI{}
2831
}
2932

File renamed without changes.

pkg/system/system.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package system
33
import (
44
"context"
55

6-
systemapi "github.com/kubernetes-csi/csi-proxy/pkg/system/api"
6+
systemapi "github.com/kubernetes-csi/csi-proxy/pkg/system/hostapi"
77
"k8s.io/klog/v2"
88
)
99

1010
type System struct {
11-
hostAPI systemapi.API
11+
hostAPI systemapi.HostAPI
1212
}
1313

1414
type Interface interface {
@@ -32,7 +32,7 @@ type Interface interface {
3232
// check that System implements Interface
3333
var _ Interface = &System{}
3434

35-
func New(hostAPI systemapi.API) (*System, error) {
35+
func New(hostAPI systemapi.HostAPI) (*System, error) {
3636
return &System{
3737
hostAPI: hostAPI,
3838
}, nil

pkg/volume/api/api.go renamed to pkg/volume/hostapi/hostapi.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"k8s.io/klog/v2"
1414
)
1515

16-
// API exposes the internal volume operations available in the server
17-
type API interface {
16+
// HostAPI exposes the internal volume operations available in the server
17+
type HostAPI interface {
1818
// ListVolumesOnDisk lists volumes on a disk identified by a `diskNumber` and optionally a partition identified by `partitionNumber`.
1919
ListVolumesOnDisk(diskNumber uint32, partitionNumber uint32) (volumeIDs []string, err error)
2020
// MountVolume mounts the volume at the requested global staging target path.
@@ -42,8 +42,8 @@ type API interface {
4242
// volumeAPI implements the internal Volume APIs
4343
type volumeAPI struct{}
4444

45-
// verifies that the API is implemented
46-
var _ API = &volumeAPI{}
45+
// verifies that HostAPI is implemented
46+
var _ HostAPI = &volumeAPI{}
4747

4848
var (
4949
// VolumeRegexp matches a Windows Volume
@@ -57,7 +57,7 @@ var (
5757
)
5858

5959
// New - Construct a new Volume API Implementation.
60-
func New() API {
60+
func New() HostAPI {
6161
return &volumeAPI{}
6262
}
6363

pkg/volume/volume.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"context"
55
"fmt"
66

7-
volumeapi "github.com/kubernetes-csi/csi-proxy/pkg/volume/api"
7+
volumeapi "github.com/kubernetes-csi/csi-proxy/pkg/volume/hostapi"
88
"k8s.io/klog/v2"
99
)
1010

1111
// Volume wraps the host API and implements the interface
1212
type Volume struct {
13-
hostAPI volumeapi.API
13+
hostAPI volumeapi.HostAPI
1414
}
1515

1616
type Interface interface {
@@ -53,7 +53,7 @@ type Interface interface {
5353

5454
var _ Interface = &Volume{}
5555

56-
func New(hostAPI volumeapi.API) (*Volume, error) {
56+
func New(hostAPI volumeapi.HostAPI) (*Volume, error) {
5757
return &Volume{
5858
hostAPI: hostAPI,
5959
}, nil

0 commit comments

Comments
 (0)