diff --git a/pkg/cmd/cli/cmd/process.go b/pkg/cmd/cli/cmd/process.go index 42cdb819002d..24c15aca4b4f 100644 --- a/pkg/cmd/cli/cmd/process.go +++ b/pkg/cmd/cli/cmd/process.go @@ -10,6 +10,7 @@ import ( "github.com/golang/glog" "github.com/spf13/cobra" + "github.com/openshift/origin/pkg/cmd/cli/describe" "github.com/openshift/origin/pkg/cmd/util/clientcmd" "github.com/openshift/origin/pkg/template" "github.com/openshift/origin/pkg/template/api" @@ -89,7 +90,7 @@ Examples: // If 'parameters' flag is set it does not do processing but only print // the template parameters to console for inspection. if cmdutil.GetFlagBool(cmd, "parameters") == true { - err = printer.PrintObj(templateObj, out) + err = describe.PrintTemplateParameters(templateObj.Parameters, out) checkErr(err) return } diff --git a/pkg/cmd/cli/describe/printer.go b/pkg/cmd/cli/describe/printer.go index 8a108db33501..86cc47881857 100644 --- a/pkg/cmd/cli/describe/printer.go +++ b/pkg/cmd/cli/describe/printer.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "strings" + "text/tabwriter" kctl "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -30,7 +31,6 @@ var ( deploymentColumns = []string{"NAME", "STATUS", "CAUSE"} deploymentConfigColumns = []string{"NAME", "TRIGGERS", "LATEST VERSION"} templateColumns = []string{"NAME", "DESCRIPTION", "PARAMETERS", "OBJECTS"} - parameterColumns = []string{"NAME", "DESCRIPTION", "GENERATOR", "VALUE"} policyColumns = []string{"NAME", "ROLES", "LAST MODIFIED"} policyBindingColumns = []string{"NAME", "ROLE BINDINGS", "LAST MODIFIED"} @@ -84,6 +84,25 @@ func NewHumanReadablePrinter(noHeaders bool) *kctl.HumanReadablePrinter { const templateDescriptionLen = 80 +// PrintTemplateParameters the Template parameters with their default values +func PrintTemplateParameters(params []templateapi.Parameter, output io.Writer) error { + w := tabwriter.NewWriter(output, 20, 5, 3, ' ', 0) + defer w.Flush() + parameterColumns := []string{"NAME", "DESCRIPTION", "GENERATOR", "VALUE"} + fmt.Fprintf(w, "%s\n", strings.Join(parameterColumns, "\t")) + for _, p := range params { + value := p.Value + if len(p.Generate) != 0 { + value = p.From + } + _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", p.Name, p.Description, p.Generate, value) + if err != nil { + return err + } + } + return nil +} + func printTemplate(t *templateapi.Template, w io.Writer) error { description := "" if t.Annotations != nil { @@ -116,20 +135,6 @@ func printTemplate(t *templateapi.Template, w io.Writer) error { return err } -func printTemplateParameters(t *templateapi.Template, w io.Writer) error { - for _, p := range t.Parameters { - value := p.Value - if len(p.Generate) != 0 { - value = p.From - } - _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", p.Name, p.Description, p.Generate, value) - if err != nil { - return err - } - } - return nil -} - func printTemplateList(list *templateapi.TemplateList, w io.Writer) error { for _, t := range list.Items { if err := printTemplate(&t, w); err != nil {