Skip to content

Commit 435a1c5

Browse files
authored
Merge pull request kubernetes#1911 from johnbelamaric/kepctlquery
Add the query subcommand to kepctl
2 parents b13460a + e406d35 commit 435a1c5

File tree

15 files changed

+2231
-20
lines changed

15 files changed

+2231
-20
lines changed

cmd/kepctl/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ func addRepoPathFlag(
2727
opts *kepctl.CommonArgs,
2828
) {
2929
f.StringVar(&opts.RepoPath, "repo-path", "", "Path to kubernetes/enhancements")
30+
f.StringVar(&opts.TokenPath, "gh-token-path", "", "Path to a file with a GitHub API token")
3031
}

cmd/kepctl/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ func buildMainCommand() (*cobra.Command, error) {
4949

5050
rootCmd.AddCommand(buildCreateCommand(k))
5151
rootCmd.AddCommand(buildPromoteCommand(k))
52+
rootCmd.AddCommand(buildQueryCommand(k))
5253
return rootCmd, nil
5354
}

cmd/kepctl/query.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"github.com/spf13/cobra"
21+
22+
"k8s.io/enhancements/pkg/kepctl"
23+
)
24+
25+
func buildQueryCommand(k *kepctl.Client) *cobra.Command {
26+
opts := kepctl.QueryOpts{}
27+
cmd := &cobra.Command{
28+
Use: "query",
29+
Short: "Query KEPs",
30+
Long: "Query the local filesystem, and optionally GitHub PRs for KEPs",
31+
Example: ` kepctl query --sig architecture --status provisional --include-prs`,
32+
PreRunE: func(cmd *cobra.Command, args []string) error {
33+
return opts.Validate(args)
34+
},
35+
RunE: func(cmd *cobra.Command, args []string) error {
36+
return k.Query(opts)
37+
},
38+
}
39+
40+
f := cmd.Flags()
41+
f.StringSliceVar(&opts.SIG, "sig", nil, "SIG")
42+
f.StringSliceVar(&opts.Status, "status", nil, "Status")
43+
f.StringSliceVar(&opts.Stage, "stage", nil, "Stage")
44+
f.BoolVar(&opts.IncludePRs, "include-prs", false, "Include PRs in the results")
45+
46+
addRepoPathFlag(f, &opts.CommonArgs)
47+
48+
return cmd
49+
}

go.mod

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ module k8s.io/enhancements
33
go 1.12
44

55
require (
6-
github.com/pkg/errors v0.8.0
6+
github.com/google/go-github/v32 v32.1.0
7+
github.com/olekukonko/tablewriter v0.0.4
8+
github.com/pkg/errors v0.9.1
79
github.com/spf13/cobra v1.0.0
8-
github.com/spf13/pflag v1.0.3
9-
github.com/stretchr/testify v1.2.2
10-
gopkg.in/yaml.v2 v2.2.8
10+
github.com/spf13/pflag v1.0.5
11+
github.com/stretchr/testify v1.5.1
12+
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
13+
gopkg.in/yaml.v2 v2.3.0
14+
k8s.io/test-infra v0.0.0-20200813194141-e9678d500461
1115
sigs.k8s.io/yaml v1.2.0
1216
)

go.sum

Lines changed: 1699 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)