Skip to content

Commit a14bc78

Browse files
authored
Nfs struct exposes Host and MountPath (#933)
1 parent a37e724 commit a14bc78

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

nfs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ type Nfs struct {
7474
CreatedAt string `json:"created_at"`
7575
// VpcIDs is a list of VPC IDs that have access to the NFS share
7676
VpcIDs []string `json:"vpc_ids"`
77+
// Host is the IP address of the NFS server accessible from the associated VPC
78+
Host string `json:"host"`
79+
// MountPath is the path at which the share will be available
80+
MountPath string `json:"mount_path"`
7781
}
7882

7983
type NfsSnapshot struct {

nfs_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestNfsCreate(t *testing.T) {
2222
mux.HandleFunc("/v2/nfs", func(w http.ResponseWriter, r *http.Request) {
2323
assert.Equal(t, http.MethodPost, r.Method)
2424
w.WriteHeader(http.StatusCreated)
25-
fmt.Fprint(w, `{"share": {"id": "test-nfs-id", "name": "test-nfs-share", "size_gib": 50, "region": "atl1", "status": "CREATING", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": []}}`)
25+
fmt.Fprint(w, `{"share": {"id": "test-nfs-id", "name": "test-nfs-share", "size_gib": 50, "region": "atl1", "status": "CREATING", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": [], "host": "10.128.32.2", "mount_path": "/123456/test-nfs-id"}}`)
2626
})
2727

2828
share, resp, err := client.Nfs.Create(context.Background(), createRequest)
@@ -32,6 +32,8 @@ func TestNfsCreate(t *testing.T) {
3232
assert.Equal(t, "atl1", share.Region)
3333
assert.Equal(t, 50, share.SizeGib)
3434
assert.Equal(t, NfsShareCreating, share.Status)
35+
assert.Equal(t, "10.128.32.2", share.Host)
36+
assert.Equal(t, "/123456/test-nfs-id", share.MountPath)
3537

3638
invalidCreateRequest := &NfsCreateRequest{
3739
Name: "test-nfs-share-invalid-size",
@@ -67,7 +69,7 @@ func TestNfsGet(t *testing.T) {
6769
mux.HandleFunc("/v2/nfs/test-nfs-id", func(w http.ResponseWriter, r *http.Request) {
6870
assert.Equal(t, http.MethodGet, r.Method)
6971
w.WriteHeader(http.StatusOK)
70-
fmt.Fprint(w, `{"share": {"id": "test-nfs-id", "name": "test-nfs-share", "size_gib": 50, "region": "atl1", "status": "ACTIVE", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": []}}`)
72+
fmt.Fprint(w, `{"share": {"id": "test-nfs-id", "name": "test-nfs-share", "size_gib": 50, "region": "atl1", "status": "ACTIVE", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": [], "host": "10.128.32.2", "mount_path": "/123456/test-nfs-id"}}`)
7173
})
7274

7375
share, resp, err := client.Nfs.Get(context.Background(), "test-nfs-id", "atl1")
@@ -77,6 +79,8 @@ func TestNfsGet(t *testing.T) {
7779
assert.Equal(t, "atl1", share.Region)
7880
assert.Equal(t, 50, share.SizeGib)
7981
assert.Equal(t, NfsShareActive, share.Status)
82+
assert.Equal(t, "10.128.32.2", share.Host)
83+
assert.Equal(t, "/123456/test-nfs-id", share.MountPath)
8084
}
8185

8286
func TestNfsList(t *testing.T) {
@@ -88,10 +92,10 @@ func TestNfsList(t *testing.T) {
8892
page := r.URL.Query().Get("page")
8993
if page == "2" {
9094
w.WriteHeader(http.StatusOK)
91-
fmt.Fprint(w, `{"shares": [{"id": "test-nfs-id-2", "name": "test-nfs-share-2", "size_gib": 50, "region": "atl1", "status": "ACTIVE", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": []}]}`)
95+
fmt.Fprint(w, `{"shares": [{"id": "test-nfs-id-2", "name": "test-nfs-share-2", "size_gib": 50, "region": "atl1", "status": "ACTIVE", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": [], "host": "10.128.32.3", "mount_path": "/123456/test-nfs-id-2"}]}`)
9296
} else {
9397
w.WriteHeader(http.StatusOK)
94-
fmt.Fprint(w, `{"shares": [{"id": "test-nfs-id-1", "name": "test-nfs-share-1", "size_gib": 50, "region": "atl1", "status": "CREATING", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": []}]}`)
98+
fmt.Fprint(w, `{"shares": [{"id": "test-nfs-id-1", "name": "test-nfs-share-1", "size_gib": 50, "region": "atl1", "status": "CREATING", "created_at":"2023-10-01T00:00:00Z", "vpc_ids": [], "host": "10.128.32.2", "mount_path": "/123456/test-nfs-id-1"}]}`)
9599
}
96100
})
97101

@@ -104,6 +108,8 @@ func TestNfsList(t *testing.T) {
104108
assert.Equal(t, "atl1", shares[0].Region)
105109
assert.Equal(t, 50, shares[0].SizeGib)
106110
assert.Equal(t, NfsShareCreating, shares[0].Status)
111+
assert.Equal(t, "10.128.32.2", shares[0].Host)
112+
assert.Equal(t, "/123456/test-nfs-id-1", shares[0].MountPath)
107113

108114
// Test second page
109115
shares, resp, err = client.Nfs.List(context.Background(), &ListOptions{Page: 2}, "atl1")
@@ -114,6 +120,8 @@ func TestNfsList(t *testing.T) {
114120
assert.Equal(t, "atl1", shares[0].Region)
115121
assert.Equal(t, 50, shares[0].SizeGib)
116122
assert.Equal(t, NfsShareActive, shares[0].Status)
123+
assert.Equal(t, "10.128.32.3", shares[0].Host)
124+
assert.Equal(t, "/123456/test-nfs-id-2", shares[0].MountPath)
117125
}
118126

119127
func TestNfsSnapshotGet(t *testing.T) {

0 commit comments

Comments
 (0)