@@ -21,28 +21,40 @@ import (
2121 "github.com/crunchydata/postgres-operator/pgo/api"
2222 log "github.com/sirupsen/logrus"
2323 "os"
24+ "strconv"
2425)
2526
2627func showPVC (args []string , ns string ) {
2728 log .Debugf ("showPVC called %v" , args )
2829
29- if args [0 ] == "all" {
30+ // ShowPVCRequest ...
31+ r := msgs.ShowPVCRequest {}
32+ r .Namespace = ns
33+ r .Allflag = strconv .FormatBool (AllFlag )
34+ r .ClientVersion = msgs .PGO_VERSION
35+ r .NodeLabel = NodeLabel
36+ r .PVCRoot = PVCRoot
37+
38+ if AllFlag {
3039 //special case to just list all the PVCs
31- printPVC (args [0 ], "" , NodeLabel , ns )
40+ r .PVCName = ""
41+ r .PVCRoot = ""
42+ printPVC (& r )
3243 } else {
3344 //args are a list of pvc names...for this case show details
3445 for _ , arg := range args {
46+ r .PVCName = arg
3547 log .Debugf ("show pvc called for %s" , arg )
36- printPVC (arg , PVCRoot , NodeLabel , ns )
48+ printPVC (& r )
3749
3850 }
3951 }
4052
4153}
4254
43- func printPVC (pvcName , pvcRoot , nodeLabel , ns string ) {
55+ func printPVC (r * msgs. ShowPVCRequest ) {
4456
45- response , err := api .ShowPVC (httpclient , pvcName , pvcRoot , & SessionCredentials , nodeLabel , ns )
57+ response , err := api .ShowPVC (httpclient , r , & SessionCredentials )
4658
4759 if err != nil {
4860 fmt .Println ("Error: " + err .Error ())
@@ -60,12 +72,12 @@ func printPVC(pvcName, pvcRoot, nodeLabel, ns string) {
6072 }
6173 log .Debugf ("response = %v" , response )
6274
63- if pvcName == "all" {
75+ if AllFlag {
6476 fmt .Println ("All Operator Labeled PVCs" )
6577 }
6678
6779 for k , v := range response .Results {
68- if pvcName == "all" {
80+ if AllFlag {
6981 if v != "" {
7082 fmt .Printf ("%s%s\n " , TreeTrunk , v )
7183 }
0 commit comments