Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups cmd - list groups and associated checks #59

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/clusterlint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func main() {
},
Action: runChecks,
},
{
Name: "groups",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should make this a subcommand of clusterlint list - i.e., have clusterlint list checks and clusterlint list groups.

Usage: "list all groups and associated checks in the registry",
Action: listGroups,
},
}
err := app.Run(os.Args)
if err != nil {
Expand Down Expand Up @@ -132,6 +137,21 @@ func listChecks(c *cli.Context) error {
return nil
}

// listGroups lists all the groups in the registry or a specific group if found
// shows checks that belong to the group.
func listGroups(c *cli.Context) error {
groups := checks.ListGroups()
for _, group := range groups {
var checkNames []string
checks := checks.GetGroup(group)
for _, check := range checks {
checkNames = append(checkNames, check.Name())
}
fmt.Printf("%s: %s\n", group, strings.Join(checkNames, ", "))
}
return nil
}

// runChecks runs all the checks based on the flags passed.
func runChecks(c *cli.Context) error {
var kubeconfigFilePaths []string
Expand Down