From 8c3604318a6781ada06947f803b770c7738dee1c Mon Sep 17 00:00:00 2001
From: astraw99 <wangchengiscool@gmail.com>
Date: Fri, 6 Oct 2023 19:53:05 +0800
Subject: [PATCH] Update readme doc

---
 README.md              |  6 +++++-
 pkg/hostpath/README.md | 38 ++++++++++++++++++++++++++++----------
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 63cd504e0..24967379c 100644
--- a/README.md
+++ b/README.md
@@ -28,13 +28,17 @@ The following examples assume that the CSI hostpath driver has been deployed and
 - [Volume snapshots](docs/example-snapshots-1.17-and-later.md)
 - [Inline ephemeral volumes](docs/example-ephemeral.md)
 
-## Building the binaries
+## Build and Test locally
+### Building the binaries
 If you want to build the driver yourself, you can do so with the following command from the root directory:
 
 ```shell
 make
 ```
 
+### Test hostpath driver
+See [doc](./pkg/hostpath/README.md)
+
 ## Development
 
 ### Updating sidecar images
diff --git a/pkg/hostpath/README.md b/pkg/hostpath/README.md
index 612bd5cf3..1ba6943d2 100644
--- a/pkg/hostpath/README.md
+++ b/pkg/hostpath/README.md
@@ -7,9 +7,15 @@
 $ make
 ```
 
+### Set endpoint
+```
+$ endpoint=unix:///tmp/csi.sock # unix (default)
+$ #endpoint=tcp://127.0.0.1:10000 # tcp
+```
+
 ### Start Hostpath driver
 ```
-$ sudo ./bin/hostpathplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode -v=5
+$ sudo ./bin/hostpathplugin --endpoint $endpoint --nodeid CSINode -v=5
 ```
 
 ### Test using csc
@@ -17,42 +23,54 @@ Get ```csc``` tool from https://github.com/rexray/gocsi/tree/master/csc
 
 #### Get plugin info
 ```
-$ csc identity plugin-info --endpoint tcp://127.0.0.1:10000
-"csi-hostpath"  "0.1.0"
+$ sudo csc identity plugin-info --endpoint $endpoint
+"hostpath.csi.k8s.io"  "v1.x.x-xx-xxx"
 ```
 
 #### Create a volume
 ```
-$ csc controller new --endpoint tcp://127.0.0.1:10000 --cap 1,block CSIVolumeName
+$ sudo csc controller new --endpoint $endpoint --cap 1,block --req-bytes 10240000 CSIVolumeName
 CSIVolumeID
 ```
 
 #### Delete a volume
 ```
-$ csc controller del --endpoint tcp://127.0.0.1:10000 CSIVolumeID
+$ sudo csc controller del --endpoint $endpoint CSIVolumeID
 CSIVolumeID
 ```
 
 #### Validate volume capabilities
 ```
-$ csc controller validate-volume-capabilities --endpoint tcp://127.0.0.1:10000 --cap 1,block CSIVolumeID
-CSIVolumeID  true
+$ sudo csc controller validate-volume-capabilities --endpoint $endpoint --cap 1,block CSIVolumeID
+CSIVolumeID  volume_capabilities:<block:<> access_mode:<mode:SINGLE_NODE_WRITER > >
+```
+
+#### NodeStage a volume
+```
+$ sudo csc node stage --endpoint $endpoint --cap 1,block --staging-target-path /mnt/hostpath CSIVolumeID
+CSIVolumeID
+```
+
+#### NodeUnstage a volume
+```
+$ sudo csc node unstage --endpoint $endpoint --cap 1,block --staging-target-path /mnt/hostpath CSIVolumeID
+CSIVolumeID
 ```
 
 #### NodePublish a volume
 ```
-$ csc node publish --endpoint tcp://127.0.0.1:10000 --cap 1,block --target-path /mnt/hostpath CSIVolumeID
+$ sudo csc node publish --endpoint $endpoint --cap 1,block --staging-target-path /mnt/hostpath --target-path /mnt/hostpath CSIVolumeID
 CSIVolumeID
 ```
 
 #### NodeUnpublish a volume
 ```
-$ csc node unpublish --endpoint tcp://127.0.0.1:10000 --target-path /mnt/hostpath CSIVolumeID
+$ sudo csc node unpublish --endpoint $endpoint --target-path /mnt/hostpath CSIVolumeID
 CSIVolumeID
 ```
 
 #### Get NodeInfo
 ```
-$ csc node get-info --endpoint tcp://127.0.0.1:10000
+$ sudo csc node get-info --endpoint $endpoint
 CSINode
 ```