Skip to content

Commit

Permalink
Update csc commands with new v1.2.0 flags
Browse files Browse the repository at this point in the history
* Add optional secrets field to ListSnapshotsRequest
* Add optional staging_path to NodeGetVolumeStatsRequest and
  NodeExpandVolumeRequest
* Add optional volume_capability to ControllerExpandVolumeRequest
  and NodeExpandVolumeRequest
  • Loading branch information
codenrhoden committed Jan 26, 2020
1 parent 8b92503 commit 3cd9121
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
6 changes: 5 additions & 1 deletion csc/cmd/controller_expand_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
var expandVolume struct {
reqBytes int64
limBytes int64
volCap *volumeCapabilitySliceArg
}

var expandVolumeCmd = &cobra.Command{
Expand All @@ -28,7 +29,8 @@ USAGE
RunE: func(cmd *cobra.Command, args []string) error {

req := csi.ControllerExpandVolumeRequest{
Secrets: root.secrets,
Secrets: root.secrets,
VolumeCapability: expandVolume.volCap.data[0],
}

if expandVolume.reqBytes > 0 || expandVolume.limBytes > 0 {
Expand Down Expand Up @@ -68,6 +70,8 @@ func init() {

flagLimitBytes(expandVolumeCmd.Flags(), &expandVolume.limBytes)

flagVolumeCapability(nodeExpandVolumeCmd.Flags(), expandVolume.volCap)

flagWithRequiresCreds(
expandVolumeCmd.Flags(),
&root.withRequiresCreds,
Expand Down
1 change: 1 addition & 0 deletions csc/cmd/controller_list_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var listSnapshotsCmd = &cobra.Command{
StartingToken: listSnapshots.startingToken,
SnapshotId: listSnapshots.SnapshotId,
SourceVolumeId: listSnapshots.sourceVolumeId,
Secrets: root.secrets,
}

// If auto-paging is not enabled then send a normal request.
Expand Down
16 changes: 11 additions & 5 deletions csc/cmd/node_expand_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
)

var nodeExpandVolume struct {
reqBytes int64
limBytes int64
volPath string
reqBytes int64
limBytes int64
stagingPath string
volCap *volumeCapabilitySliceArg
}

var nodeExpandVolumeCmd = &cobra.Command{
Expand All @@ -30,8 +31,10 @@ USAGE

// Set the volume name and path for the current request.
req := csi.NodeExpandVolumeRequest{
VolumeId: args[0],
VolumePath: args[1],
VolumeId: args[0],
VolumePath: args[1],
StagingTargetPath: nodeExpandVolume.stagingPath,
VolumeCapability: nodeExpandVolume.volCap.data[0],
}

if nodeExpandVolume.reqBytes > 0 || nodeExpandVolume.limBytes > 0 {
Expand Down Expand Up @@ -66,4 +69,7 @@ func init() {

flagLimitBytes(nodeExpandVolumeCmd.Flags(), &nodeExpandVolume.limBytes)

flagStagingTargetPath(nodeExpandVolumeCmd.Flags(), &nodeExpandVolume.stagingPath)

flagVolumeCapability(nodeExpandVolumeCmd.Flags(), nodeExpandVolume.volCap)
}
13 changes: 4 additions & 9 deletions csc/cmd/node_get_volume_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
)

var nodeGetVolumeStats struct {
nodeID string
stagingTargetPath string
pubInfo mapOfStringArg
attribs mapOfStringArg
caps volumeCapabilitySliceArg
}

var nodeGetVolumeStatsCmd = &cobra.Command{
Use: "stats",
Short: `invokes the rpc "NodeGetVolumeStats"`,
Example: `
USAGE
csc node stats VOLUME_ID:VOLUME_PATH [VOLUME_ID:VOLUME_PATh...]
csc node stats VOLUME_ID:VOLUME_PATH:STAGING_PATH [VOLUME_ID:VOLUME_PATH:STAGING_PATH...]
`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -39,6 +31,9 @@ USAGE
// Set the volume ID and volume path for the current request.
split := strings.Split(args[i], ":")
req.VolumeId, req.VolumePath = split[0], split[1]
if len(split) > 2 {
req.StagingTargetPath = split[2]
}

log.WithField("request", req).Debug("staging volume")
rep, err := node.client.NodeGetVolumeStats(ctx, &req)
Expand Down

0 comments on commit 3cd9121

Please sign in to comment.