| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"github.com/golang/glog" |
| 11 | 11 |
"github.com/spf13/cobra" |
| 12 | 12 |
|
| 13 |
+ "github.com/openshift/origin/pkg/cmd/cli/describe" |
|
| 13 | 14 |
"github.com/openshift/origin/pkg/cmd/util/clientcmd" |
| 14 | 15 |
"github.com/openshift/origin/pkg/template" |
| 15 | 16 |
"github.com/openshift/origin/pkg/template/api" |
| ... | ... |
@@ -89,7 +90,7 @@ Examples: |
| 89 | 89 |
// If 'parameters' flag is set it does not do processing but only print |
| 90 | 90 |
// the template parameters to console for inspection. |
| 91 | 91 |
if cmdutil.GetFlagBool(cmd, "parameters") == true {
|
| 92 |
- err = printer.PrintObj(templateObj, out) |
|
| 92 |
+ err = describe.PrintTemplateParameters(templateObj.Parameters, out) |
|
| 93 | 93 |
checkErr(err) |
| 94 | 94 |
return |
| 95 | 95 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"io" |
| 6 | 6 |
"strings" |
| 7 |
+ "text/tabwriter" |
|
| 7 | 8 |
|
| 8 | 9 |
kctl "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl" |
| 9 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| ... | ... |
@@ -30,7 +31,6 @@ var ( |
| 30 | 30 |
deploymentColumns = []string{"NAME", "STATUS", "CAUSE"}
|
| 31 | 31 |
deploymentConfigColumns = []string{"NAME", "TRIGGERS", "LATEST VERSION"}
|
| 32 | 32 |
templateColumns = []string{"NAME", "DESCRIPTION", "PARAMETERS", "OBJECTS"}
|
| 33 |
- parameterColumns = []string{"NAME", "DESCRIPTION", "GENERATOR", "VALUE"}
|
|
| 34 | 33 |
policyColumns = []string{"NAME", "ROLES", "LAST MODIFIED"}
|
| 35 | 34 |
policyBindingColumns = []string{"NAME", "ROLE BINDINGS", "LAST MODIFIED"}
|
| 36 | 35 |
|
| ... | ... |
@@ -84,6 +84,25 @@ func NewHumanReadablePrinter(noHeaders bool) *kctl.HumanReadablePrinter {
|
| 84 | 84 |
|
| 85 | 85 |
const templateDescriptionLen = 80 |
| 86 | 86 |
|
| 87 |
+// PrintTemplateParameters the Template parameters with their default values |
|
| 88 |
+func PrintTemplateParameters(params []templateapi.Parameter, output io.Writer) error {
|
|
| 89 |
+ w := tabwriter.NewWriter(output, 20, 5, 3, ' ', 0) |
|
| 90 |
+ defer w.Flush() |
|
| 91 |
+ parameterColumns := []string{"NAME", "DESCRIPTION", "GENERATOR", "VALUE"}
|
|
| 92 |
+ fmt.Fprintf(w, "%s\n", strings.Join(parameterColumns, "\t")) |
|
| 93 |
+ for _, p := range params {
|
|
| 94 |
+ value := p.Value |
|
| 95 |
+ if len(p.Generate) != 0 {
|
|
| 96 |
+ value = p.From |
|
| 97 |
+ } |
|
| 98 |
+ _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", p.Name, p.Description, p.Generate, value) |
|
| 99 |
+ if err != nil {
|
|
| 100 |
+ return err |
|
| 101 |
+ } |
|
| 102 |
+ } |
|
| 103 |
+ return nil |
|
| 104 |
+} |
|
| 105 |
+ |
|
| 87 | 106 |
func printTemplate(t *templateapi.Template, w io.Writer) error {
|
| 88 | 107 |
description := "" |
| 89 | 108 |
if t.Annotations != nil {
|
| ... | ... |
@@ -116,20 +135,6 @@ func printTemplate(t *templateapi.Template, w io.Writer) error {
|
| 116 | 116 |
return err |
| 117 | 117 |
} |
| 118 | 118 |
|
| 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 |
- |
|
| 133 | 119 |
func printTemplateList(list *templateapi.TemplateList, w io.Writer) error {
|
| 134 | 120 |
for _, t := range list.Items {
|
| 135 | 121 |
if err := printTemplate(&t, w); err != nil {
|