Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A kubectl plugin that runs commands against every context in your kubeconfig fil
- Run kubectl commands against all contexts simultaneously
- Parallel execution with configurable batching (default: 25 contexts at a time)
- Include/exclude contexts by name pattern
- Support for `version`, `get`, `logs`, `wait`, `top`, `events`, `api-resources`, and `api-versions` subcommands
- Support for `version`, `get`, `logs`, `wait`, `top`, `events`, `api-resources`, `api-versions`, and `auth` subcommands
- Streaming log output with `-f` flag across all contexts
- Watch mode with `-w`/`--watch` flag on `get` and `events` subcommands
- Flexible output formatting:
Expand Down Expand Up @@ -238,6 +238,20 @@ Run `kubectl api-versions` against all contexts:
kubectl x api-versions
```

### Auth Command

Run `kubectl auth` subcommands against all contexts:

```bash
# Show the current authenticated user across all contexts
kubectl x auth whoami

# Check if the current user can perform an action across all contexts
kubectl x auth can-i get pods
kubectl x auth can-i create deployments -n default
kubectl x auth can-i '*' '*'
```

## Output Formats

### Default Output
Expand Down
15 changes: 15 additions & 0 deletions cmd/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cmd

import (
"github.com/spf13/cobra"
)

var authCmd = &cobra.Command{
Use: "auth",
Short: "Run kubectl auth subcommands against all contexts",
Long: `Run kubectl auth subcommands (e.g. whoami, can-i) against all contexts in parallel.`,
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runCommand("auth", args)
},
}
14 changes: 14 additions & 0 deletions cmd/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cmd

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestAuthCmd(t *testing.T) {
require.NotNil(t, authCmd)
assert.Equal(t, "auth", authCmd.Use)
assert.True(t, authCmd.DisableFlagParsing)
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ func init() {
rootCmd.AddCommand(eventsCmd)
rootCmd.AddCommand(apiResourcesCmd)
rootCmd.AddCommand(apiVersionsCmd)
rootCmd.AddCommand(authCmd)
}
2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestRootCmd(t *testing.T) {
}

func TestRootCmdHasSubcommands(t *testing.T) {
expected := []string{"version", "get", "logs", "top", "wait", "events", "api-resources", "api-versions"}
expected := []string{"version", "get", "logs", "top", "wait", "events", "api-resources", "api-versions", "auth"}
registered := make(map[string]bool)
for _, cmd := range rootCmd.Commands() {
registered[cmd.Use] = true
Expand Down
Loading