Merge remote-tracking branch 'upstream/master' into release-cmd/config-v0.1

This commit is contained in:
Phillip Wittrock
2020-04-02 11:31:14 -07:00
40 changed files with 997 additions and 218 deletions

View File

@@ -18,6 +18,6 @@ List setters for Resources.
Show setters:
$ config set DIR/
$ config list-setters DIR/
NAME DESCRIPTION VALUE TYPE COUNT SETBY
name-prefix '' PREFIX string 2

View File

@@ -28,8 +28,8 @@ the configuration as comments.
Optional. The value to set on the field.
To print the possible setters for the Resources in a directory, run `set` on
a directory -- e.g. `kustomize config set DIR/`.
To print the possible setters for the Resources in a directory, run
`list-setters` on a directory -- e.g. `kustomize config list-setters DIR/`.
#### Tips
@@ -58,7 +58,7 @@ To create a custom setter for a field see: `kustomize help config create-setter`
List setters: Show the possible setters
$ config set DIR/
$ config list-setters DIR/
NAME DESCRIPTION VALUE TYPE COUNT SETBY
name-prefix '' PREFIX string 2
@@ -69,7 +69,7 @@ To create a custom setter for a field see: `kustomize help config create-setter`
List setters: Show the new values
$ config set DIR/
$ config list-setters DIR/
NAME DESCRIPTION VALUE TYPE COUNT SETBY
name-prefix 'test environment' test string 2 dev

View File

@@ -29,6 +29,8 @@ func NewListSettersRunner(parent string) *ListSettersRunner {
PreRunE: r.preRunE,
RunE: r.runE,
}
c.Flags().BoolVar(&r.Markdown, "markdown", false,
"output as github markdown")
fixDocs(parent, c)
r.Command = c
return r
@@ -39,9 +41,10 @@ func ListSettersCommand(parent string) *cobra.Command {
}
type ListSettersRunner struct {
Command *cobra.Command
Lookup setters.LookupSetters
List setters2.List
Command *cobra.Command
Lookup setters.LookupSetters
List setters2.List
Markdown bool
}
func (r *ListSettersRunner) preRunE(c *cobra.Command, args []string) error {
@@ -64,7 +67,7 @@ func (r *ListSettersRunner) runE(c *cobra.Command, args []string) error {
if err := r.List.List(path, args[0]); err != nil {
return err
}
table := newTable(c.OutOrStdout())
table := newTable(c.OutOrStdout(), r.Markdown)
table.SetHeader([]string{"NAME", "VALUE", "SET BY", "DESCRIPTION", "COUNT"})
for i := range r.List.Setters {
s := r.List.Setters[i]
@@ -92,13 +95,19 @@ func (r *ListSettersRunner) runE(c *cobra.Command, args []string) error {
return handleError(c, lookup(r.Lookup, c, args))
}
func newTable(o io.Writer) *tablewriter.Table {
func newTable(o io.Writer, m bool) *tablewriter.Table {
table := tablewriter.NewWriter(o)
table.SetRowLine(false)
table.SetBorder(false)
table.SetHeaderLine(false)
table.SetColumnSeparator(" ")
table.SetCenterSeparator(" ")
if m {
// markdown format
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
} else {
table.SetBorder(false)
table.SetHeaderLine(false)
table.SetColumnSeparator(" ")
table.SetCenterSeparator(" ")
}
table.SetAlignment(tablewriter.ALIGN_LEFT)
return table
}

View File

@@ -171,7 +171,7 @@ List setters for Resources.
var ListSettersExamples = `
Show setters:
$ config set DIR/
$ config list-setters DIR/
NAME DESCRIPTION VALUE TYPE COUNT SETBY
name-prefix '' PREFIX string 2`
@@ -289,8 +289,8 @@ the configuration as comments.
Optional. The value to set on the field.
To print the possible setters for the Resources in a directory, run ` + "`" + `set` + "`" + ` on
a directory -- e.g. ` + "`" + `kustomize config set DIR/` + "`" + `.
To print the possible setters for the Resources in a directory, run
` + "`" + `list-setters` + "`" + ` on a directory -- e.g. ` + "`" + `kustomize config list-setters DIR/` + "`" + `.
#### Tips
@@ -318,7 +318,7 @@ var SetExamples = `
List setters: Show the possible setters
$ config set DIR/
$ config list-setters DIR/
NAME DESCRIPTION VALUE TYPE COUNT SETBY
name-prefix '' PREFIX string 2
@@ -329,7 +329,7 @@ var SetExamples = `
List setters: Show the new values
$ config set DIR/
$ config list-setters DIR/
NAME DESCRIPTION VALUE TYPE COUNT SETBY
name-prefix 'test environment' test string 2 dev