@@ -2,8 +2,10 @@ package cmd
2
2
3
3
import (
4
4
"errors"
5
+ "fmt"
5
6
"io"
6
7
"strings"
8
+ "text/tabwriter"
7
9
8
10
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
9
11
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@@ -15,6 +17,25 @@ import (
15
17
"github.com/openshift/origin/pkg/template/api"
16
18
)
17
19
20
+ // printTemplateParameters prints all parameters defined by the template
21
+ func printTemplateParameters (t * api.Template , output io.Writer ) error {
22
+ w := tabwriter .NewWriter (output , 20 , 5 , 3 , ' ' , 0 )
23
+ defer w .Flush ()
24
+ parameterColumns := []string {"NAME" , "DESCRIPTION" , "GENERATOR" , "VALUE" }
25
+ fmt .Fprintf (w , "%s\n " , strings .Join (parameterColumns , "\t " ))
26
+ for _ , p := range t .Parameters {
27
+ value := p .Value
28
+ if len (p .Generate ) != 0 {
29
+ value = p .From
30
+ }
31
+ _ , err := fmt .Fprintf (w , "%s\t %s\t %s\t %s\n " , p .Name , p .Description , p .Generate , value )
32
+ if err != nil {
33
+ return err
34
+ }
35
+ }
36
+ return nil
37
+ }
38
+
18
39
// injectUserVars injects user specified variables into the Template
19
40
func injectUserVars (cmd * cobra.Command , t * api.Template ) {
20
41
values := util.StringList {}
@@ -89,7 +110,7 @@ Examples:
89
110
// If 'parameters' flag is set it does not do processing but only print
90
111
// the template parameters to console for inspection.
91
112
if cmdutil .GetFlagBool (cmd , "parameters" ) == true {
92
- err = printer . PrintObj (templateObj , out )
113
+ err = printTemplateParameters (templateObj , out )
93
114
checkErr (err )
94
115
return
95
116
}
0 commit comments