Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/cmd/cli/cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
35 changes: 20 additions & 15 deletions pkg/cmd/cli/describe/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"strings"
"text/tabwriter"

kctl "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
Expand All @@ -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"}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down