Move "Is Set" column to after "Required"

This commit is contained in:
Eyob Tefera
2020-10-14 19:38:47 +00:00
parent 0490ca163f
commit 8714ca5a58
4 changed files with 39 additions and 49 deletions

View File

@@ -8,7 +8,6 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"strconv"
"strings" "strings"
"github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter"
@@ -109,7 +108,7 @@ func (r *ListSettersRunner) ListSetters(w io.Writer, openAPIPath, resourcePath s
return err return err
} }
table := newTable(w, r.Markdown) table := newTable(w, r.Markdown)
table.SetHeader([]string{"NAME", "VALUE", "IS SET", "SET BY", "DESCRIPTION", "COUNT", "REQUIRED"}) table.SetHeader([]string{"NAME", "VALUE", "SET BY", "DESCRIPTION", "COUNT", "REQUIRED", "IS SET"})
for i := range r.List.Setters { for i := range r.List.Setters {
s := r.List.Setters[i] s := r.List.Setters[i]
v := s.Value v := s.Value
@@ -119,23 +118,17 @@ func (r *ListSettersRunner) ListSetters(w io.Writer, openAPIPath, resourcePath s
v = strings.Join(s.ListValues, ",") v = strings.Join(s.ListValues, ",")
v = fmt.Sprintf("[%s]", v) v = fmt.Sprintf("[%s]", v)
} }
var required string required := "No"
if s.Required { if s.Required {
required = "Yes" required = "Yes"
} else {
required = "No"
} }
isSet := "No"
var isSet = "No" if s.IsSet {
if s.IsSet != "" { isSet = "Yes"
var b, _ = strconv.ParseBool(s.IsSet)
if b {
isSet = "Yes"
}
} }
table.Append([]string{ table.Append([]string{
s.Name, v, isSet, s.SetBy, s.Description, fmt.Sprintf("%d", s.Count), required}) s.Name, v, s.SetBy, s.Description, fmt.Sprintf("%d", s.Count), required, isSet})
} }
table.Render() table.Render()

View File

@@ -46,8 +46,8 @@ metadata:
spec: spec:
replicas: 3 # {"$ref": "#/definitions/io.k8s.cli.setters.replicas"} replicas: 3 # {"$ref": "#/definitions/io.k8s.cli.setters.replicas"}
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
replicas 3 No me hello world 1 Yes replicas 3 me hello world 1 Yes No
`, `,
}, },
@@ -72,8 +72,8 @@ metadata:
spec: spec:
replicas: 3 # {"$ref": "#/definitions/io.k8s.cli.setters.replicas"} replicas: 3 # {"$ref": "#/definitions/io.k8s.cli.setters.replicas"}
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
replicas 4 No me hello world 1 No replicas 4 me hello world 1 No No
`, `,
}, },
{ {
@@ -131,10 +131,10 @@ spec:
- name: nginx2 - name: nginx2
image: nginx # {"$ref": "#/definitions/io.k8s.cli.setters.image"} image: nginx # {"$ref": "#/definitions/io.k8s.cli.setters.image"}
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
image nginx No me2 hello world 2 2 No image nginx me2 hello world 2 2 No No
replicas 3 No me1 hello world 1 1 No replicas 3 me1 hello world 1 1 No No
tag 1.7.9 No me3 hello world 3 1 Yes tag 1.7.9 me3 hello world 3 1 Yes No
--------------- ----------- -------------- --------------- ----------- --------------
SUBSTITUTION PATTERN REFERENCES SUBSTITUTION PATTERN REFERENCES
image IMAGE:TAG [image,tag] image IMAGE:TAG [image,tag]
@@ -207,10 +207,10 @@ spec:
- name: nginx2 - name: nginx2
image: nginx image: nginx
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
image nginx No me2 hello world 2 3 No image nginx me2 hello world 2 3 No No
replicas 3 No me1 hello world 1 2 No replicas 3 me1 hello world 1 2 No No
tag 1.7.9 No me3 hello world 3 2 No tag 1.7.9 me3 hello world 3 2 No No
--------------- ----------- -------------- --------------- ----------- --------------
SUBSTITUTION PATTERN REFERENCES SUBSTITUTION PATTERN REFERENCES
image IMAGE:TAG [image,tag] image IMAGE:TAG [image,tag]
@@ -284,8 +284,8 @@ spec:
- name: nginx2 - name: nginx2
image: nginx image: nginx
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
image nginx No me2 hello world 2 3 Yes image nginx me2 hello world 2 3 Yes No
`, `,
}, },
@@ -324,8 +324,8 @@ spec:
- "b" - "b"
- "c" - "c"
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
list [a,b,c] No me hello world 1 Yes list [a,b,c] me hello world 1 Yes No
`, `,
}, },
@@ -390,10 +390,10 @@ openAPI:
name: my-other-setter name: my-other-setter
value: nginxotherthing value: nginxotherthing
`, `,
expected: ` NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED expected: ` NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
my-image-setter nginx No 2 No my-image-setter nginx 2 No No
my-other-setter nginxotherthing No 1 No my-other-setter nginxotherthing 1 No No
my-tag-setter 1.7.9 Yes 2 Yes my-tag-setter 1.7.9 2 Yes Yes
------------------ ------------------------------------------------ ----------------------------------- ------------------ ------------------------------------------------ -----------------------------------
SUBSTITUTION PATTERN REFERENCES SUBSTITUTION PATTERN REFERENCES
my-image-subst ${my-image-setter}::${my-tag-setter} [my-image-setter,my-tag-setter] my-image-subst ${my-image-setter}::${my-tag-setter} [my-image-setter,my-tag-setter]
@@ -476,20 +476,20 @@ func TestListSettersSubPackages(t *testing.T) {
expected: ` expected: `
test/testdata/dataset-with-setters/mysql/ test/testdata/dataset-with-setters/mysql/
NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
image mysql No 1 No image mysql 1 No No
namespace myspace No 1 No namespace myspace 1 No No
tag 1.7.9 No 1 No tag 1.7.9 1 No No
--------------- ----------------- -------------- --------------- ----------------- --------------
SUBSTITUTION PATTERN REFERENCES SUBSTITUTION PATTERN REFERENCES
image-tag ${image}:${tag} [image,tag] image-tag ${image}:${tag} [image,tag]
test/testdata/dataset-with-setters/mysql/nosetters/ test/testdata/dataset-with-setters/mysql/nosetters/
NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
test/testdata/dataset-with-setters/mysql/storage/ test/testdata/dataset-with-setters/mysql/storage/
NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
namespace myspace No 1 No namespace myspace 1 No No
`, `,
}, },
{ {
@@ -499,10 +499,10 @@ test/testdata/dataset-with-setters/mysql/storage/
expected: ` expected: `
test/testdata/dataset-with-setters/mysql/ test/testdata/dataset-with-setters/mysql/
NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
image mysql No 1 No image mysql 1 No No
namespace myspace No 1 No namespace myspace 1 No No
tag 1.7.9 No 1 No tag 1.7.9 1 No No
`, `,
}, },
} }

View File

@@ -35,8 +35,8 @@ openAPI:
}, },
expectedStdOut: ` expectedStdOut: `
./ ./
NAME VALUE IS SET SET BY DESCRIPTION COUNT REQUIRED NAME VALUE SET BY DESCRIPTION COUNT REQUIRED IS SET
replicas 3 No 1 No replicas 3 1 No No
`, `,
}, },
} }

View File

@@ -145,9 +145,6 @@ type SetterDefinition struct {
// ListValues are the value of a list setter. // ListValues are the value of a list setter.
ListValues []string `yaml:"listValues,omitempty"` ListValues []string `yaml:"listValues,omitempty"`
// IsSet indicates the specified field has been explicitly assigned.
IsSet string `yaml:"isSet,omitempty"`
// SetBy is the person or role that last set the value. // SetBy is the person or role that last set the value.
SetBy string `yaml:"setBy,omitempty"` SetBy string `yaml:"setBy,omitempty"`