Skip to content

Commit c090d28

Browse files
authored
Merge pull request kubernetes#2756 from spiffxp/kepctl-query-flags
kepctl: add query flags and test coverage, add create flags
2 parents 3ad8912 + d013c3b commit c090d28

File tree

27 files changed

+726
-1462
lines changed

27 files changed

+726
-1462
lines changed

pkg/kepctl/commands/create.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ func addCreate(topLevel *cobra.Command) {
2828
co := proposal.CreateOpts{}
2929

3030
cmd := &cobra.Command{
31-
Use: "create [KEP]",
31+
Use: "create",
3232
Short: "Create a new KEP",
3333
Long: "Create a new KEP using the current KEP template for the given type",
34-
Example: ` kepctl create sig-architecture/000-mykep`,
34+
Example: ` kepctl create --name a-path --title "My KEP" --number 123 --owning-sig sig-foo`,
3535
SilenceUsage: true,
3636
SilenceErrors: true,
3737
PreRunE: func(cmd *cobra.Command, args []string) error {
@@ -50,6 +50,20 @@ func addCreate(topLevel *cobra.Command) {
5050
"KEP Title",
5151
)
5252

53+
cmd.PersistentFlags().StringVar(
54+
&co.Number,
55+
"number",
56+
"",
57+
"Number",
58+
)
59+
60+
cmd.PersistentFlags().StringVar(
61+
&co.Name,
62+
"name",
63+
"",
64+
"Name",
65+
)
66+
5367
cmd.PersistentFlags().StringArrayVar(
5468
&co.Authors,
5569
"authors",
@@ -79,9 +93,16 @@ func addCreate(topLevel *cobra.Command) {
7993
"KEP State",
8094
)
8195

96+
cmd.PersistentFlags().StringVar(
97+
&co.SIG,
98+
"owning-sig",
99+
"",
100+
"Owning SIG",
101+
)
102+
82103
cmd.PersistentFlags().StringArrayVar(
83-
&co.SIGS,
84-
"sigs",
104+
&co.ParticipatingSIGs,
105+
"participating-sigs",
85106
[]string{},
86107
"Participating SIGs",
87108
)

pkg/kepctl/commands/query.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ package commands
1818

1919
import (
2020
"fmt"
21+
"os"
2122

2223
"github.com/pkg/errors"
2324
"github.com/spf13/cobra"
2425

26+
"k8s.io/enhancements/pkg/output"
2527
"k8s.io/enhancements/pkg/repo"
2628
)
2729

@@ -86,6 +88,13 @@ func addQuery(topLevel *cobra.Command) {
8688
"Author",
8789
)
8890

91+
cmd.PersistentFlags().StringSliceVar(
92+
&qo.Participant,
93+
"participating-sig",
94+
nil,
95+
"Participating SIG",
96+
)
97+
8998
cmd.PersistentFlags().BoolVar(
9099
&qo.IncludePRs,
91100
"include-prs",
@@ -96,10 +105,8 @@ func addQuery(topLevel *cobra.Command) {
96105
cmd.PersistentFlags().StringVar(
97106
&qo.Output,
98107
"output",
99-
repo.DefaultOutputOpt,
100-
fmt.Sprintf(
101-
"Output format. Can be %v", repo.SupportedOutputOpts,
102-
),
108+
output.DefaultFormat,
109+
fmt.Sprintf("Output format. Can be %v", output.ValidFormats()),
103110
)
104111

105112
topLevel.AddCommand(cmd)
@@ -112,5 +119,14 @@ func runQuery(opts *repo.QueryOpts) error {
112119
}
113120
rc.TokenPath = rootOpts.TokenPath
114121

115-
return rc.Query(opts)
122+
results, err := rc.Query(opts)
123+
if err != nil {
124+
return err
125+
}
126+
o, err := output.NewOutput(opts.Output, os.Stdout, os.Stderr)
127+
if err != nil {
128+
return err
129+
}
130+
o.PrintProposals(results)
131+
return nil
116132
}

pkg/kepctl/kepctl.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ type Options struct {
2323
TokenPath string
2424

2525
// KEP options
26-
KEP string // KEP name sig-xxx/xxx-name
27-
Name string
28-
Number string
29-
SIG string
26+
KEP string // KEP name sig-xxx/xxx-name
27+
Name string
28+
Number string
29+
SIG string
30+
ParticipatingSIG string
3031
}

pkg/legacy/keps/proposals.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

pkg/legacy/keps/proposals_test.go

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)