Skip to content

Commit 4b7b71d

Browse files
committed
kepctl create: add enough flags to work
I do not recommend using `kepctl create` right now; validation and argument parsing needs work. I wanted to make sure I hadn't broken it with recent changes and realized it already didn't work. So I added just enough flags until validation stopped yelling at me, and I was able to run the following command to get a file created in keps/sig-testing/first-try/kep.yaml kepctl create \ --name first-try \ --number not-a-number \ --title testing-kepctl-create \ --owning-sig sig-testing
1 parent bee883e commit 4b7b71d

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
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/proposal/create.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ type CreateOpts struct {
4141
SIG string
4242

4343
// Create options
44-
Title string
45-
Approvers []string
46-
Authors []string
47-
Reviewers []string
48-
Type string
49-
State string
50-
SIGS []string
51-
PRRApprovers []string
44+
Title string
45+
Approvers []string
46+
Authors []string
47+
Reviewers []string
48+
Type string
49+
State string
50+
ParticipatingSIGs []string
51+
PRRApprovers []string
5252
}
5353

5454
// Validate checks the args provided to the create command and parses the sig,
@@ -121,6 +121,8 @@ func createKEP(kep *api.Proposal, opts *CreateOpts) error {
121121
}
122122

123123
func populateProposal(p *api.Proposal, opts *CreateOpts) {
124+
p.Name = opts.Name
125+
124126
if opts.State != "" {
125127
p.Status = opts.State
126128
}
@@ -157,7 +159,7 @@ func populateProposal(p *api.Proposal, opts *CreateOpts) {
157159

158160
// TODO(lint): appendAssign: append result not assigned to the same slice (gocritic)
159161
//nolint:gocritic
160-
p.ParticipatingSIGs = append(opts.SIGS, opts.SIG)
162+
p.ParticipatingSIGs = append(opts.ParticipatingSIGs, opts.SIG)
161163
p.Filename = opts.Name
162164
p.LastUpdated = "v1.19"
163165

0 commit comments

Comments
 (0)