Skip to content

Commit 5248df3

Browse files
committed
Fix broken --parameters switch for process
1 parent b071d7f commit 5248df3

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

pkg/cmd/cli/cmd/process.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package cmd
22

33
import (
44
"errors"
5+
"fmt"
56
"io"
67
"strings"
8+
"text/tabwriter"
79

810
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
911
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@@ -15,6 +17,25 @@ import (
1517
"github.com/openshift/origin/pkg/template/api"
1618
)
1719

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+
1839
// injectUserVars injects user specified variables into the Template
1940
func injectUserVars(cmd *cobra.Command, t *api.Template) {
2041
values := util.StringList{}
@@ -89,7 +110,7 @@ Examples:
89110
// If 'parameters' flag is set it does not do processing but only print
90111
// the template parameters to console for inspection.
91112
if cmdutil.GetFlagBool(cmd, "parameters") == true {
92-
err = printer.PrintObj(templateObj, out)
113+
err = printTemplateParameters(templateObj, out)
93114
checkErr(err)
94115
return
95116
}

pkg/cmd/cli/describe/printer.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ var (
3030
deploymentColumns = []string{"NAME", "STATUS", "CAUSE"}
3131
deploymentConfigColumns = []string{"NAME", "TRIGGERS", "LATEST VERSION"}
3232
templateColumns = []string{"NAME", "DESCRIPTION", "PARAMETERS", "OBJECTS"}
33-
parameterColumns = []string{"NAME", "DESCRIPTION", "GENERATOR", "VALUE"}
3433
policyColumns = []string{"NAME", "ROLES", "LAST MODIFIED"}
3534
policyBindingColumns = []string{"NAME", "ROLE BINDINGS", "LAST MODIFIED"}
3635

@@ -116,20 +115,6 @@ func printTemplate(t *templateapi.Template, w io.Writer) error {
116115
return err
117116
}
118117

119-
func printTemplateParameters(t *templateapi.Template, w io.Writer) error {
120-
for _, p := range t.Parameters {
121-
value := p.Value
122-
if len(p.Generate) != 0 {
123-
value = p.From
124-
}
125-
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", p.Name, p.Description, p.Generate, value)
126-
if err != nil {
127-
return err
128-
}
129-
}
130-
return nil
131-
}
132-
133118
func printTemplateList(list *templateapi.TemplateList, w io.Writer) error {
134119
for _, t := range list.Items {
135120
if err := printTemplate(&t, w); err != nil {

0 commit comments

Comments
 (0)