Commit Graph

340 Commits

Author SHA1 Message Date
dependabot[bot]
dcffb6c51c chore(deps): bump github.com/mattn/go-isatty from 0.0.23 to 0.0.24
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.23 to 0.0.24.
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.23...v0.0.24)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
  dependency-version: 0.0.24
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-26 01:42:30 +00:00
github-actions[bot]
c747d27b4b Merge pull request #507 from ahmetb/dependabot/go_modules/github.com/mattn/go-isatty-0.0.23
chore(deps): bump github.com/mattn/go-isatty from 0.0.22 to 0.0.23
2026-07-19 01:50:15 +00:00
github-actions[bot]
4017845db9 Merge pull request #505 from ahmetb/dependabot/github_actions/actions/checkout-7
chore(deps): bump actions/checkout from 4 to 7
2026-07-19 01:44:33 +00:00
github-actions[bot]
544fa73edb Merge pull request #506 from ahmetb/dependabot/github_actions/actions/setup-go-7
chore(deps): bump actions/setup-go from 6 to 7
2026-07-19 01:44:06 +00:00
dependabot[bot]
41ded28d6e chore(deps): bump github.com/mattn/go-isatty from 0.0.22 to 0.0.23
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.22 to 0.0.23.
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.22...v0.0.23)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
  dependency-version: 0.0.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-19 01:42:35 +00:00
dependabot[bot]
f5b89b0208 chore(deps): bump actions/setup-go from 6 to 7
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 6 to 7.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-19 01:42:24 +00:00
dependabot[bot]
be21af2c91 chore(deps): bump actions/checkout from 4 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-19 01:42:20 +00:00
Ahmet Alp Balkan
8b2837501d Merge pull request #504 from ahmetb/add-claude-github-actions-1784418692532
Add Claude Code GitHub Workflow
2026-07-18 16:54:04 -07:00
Ahmet Alp Balkan
55b886379e "Claude Code Review workflow" 2026-07-18 16:51:35 -07:00
Ahmet Alp Balkan
2fa442d6c4 "Claude PR Assistant workflow" 2026-07-18 16:51:34 -07:00
Ahmet Alp Balkan
88a4649767 Merge pull request #493 from ahmetb/dependabot/github_actions/actions/github-script-9
auto-merge per updated dependabot workflow
2026-07-17 17:06:24 -07:00
Ahmet Alp Balkan
0328137dc9 Merge pull request #494 from ahmetb/dependabot/github_actions/dependabot/fetch-metadata-3
auto-merge per updated dependabot workflow
2026-07-17 17:06:20 -07:00
Ahmet Alp Balkan
f7c8d9dc56 Merge pull request #502 from ahmetb/dependabot/github_actions/actions/checkout-7
auto-merge per updated dependabot workflow
2026-07-17 17:06:18 -07:00
Ahmet Alp Balkan
9d6bcb685e Merge pull request #503 from ahmetb/dependabot/github_actions/actions/cache-6
auto-merge per updated dependabot workflow
2026-07-17 17:06:15 -07:00
Ahmet Alp Balkan
1e889ce715 ci: auto-merge dependabot major version bumps
Drop the semver-major exclusion from the Dependabot auto-merge gate so
that major version PRs are also auto-approved and merged once CI passes,
matching the workflow already in place for minor and patch updates.
2026-07-17 17:05:44 -07:00
Ahmet Alp Balkan
17df3085a1 fix: pipe context/namespace lists to fzf via stdin
Interactive mode was launching fzf and handing it the parent TTY on fd
0, then relying on fzf to re-exec kubectx via FZF_DEFAULT_COMMAND to
obtain the candidate list. fzf never received the list on its stdin, so
on systems where fzf did not honor FZF_DEFAULT_COMMAND the picker showed
no items and kubectx exited with 'you did not choose any of the
options'.

Build the candidate list in-process and pipe it directly to fzf's
stdin. This removes the self-re-exec, the $SHELL -c dependency, and the
TTY-plumbing hack on fd 0.

Fixes #500
2026-07-17 17:04:49 -07:00
dependabot[bot]
b74cccfe1b chore(deps): bump actions/cache from 5 to 6
Bumps [actions/cache](https://github.com/actions/cache) from 5 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-28 01:42:26 +00:00
dependabot[bot]
60c08ac9cb chore(deps): bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-21 01:42:14 +00:00
github-actions[bot]
c8393ea883 Merge pull request #498 from ahmetb/dependabot/go_modules/github.com/mattn/go-isatty-0.0.22
chore(deps): bump github.com/mattn/go-isatty from 0.0.21 to 0.0.22
2026-05-03 01:51:35 +00:00
dependabot[bot]
91c85fde5b chore(deps): bump github.com/mattn/go-isatty from 0.0.21 to 0.0.22
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.21 to 0.0.22.
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.21...v0.0.22)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
  dependency-version: 0.0.22
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-03 01:42:44 +00:00
github-actions[bot]
dd726040b6 Merge pull request #496 from ahmetb/dependabot/go_modules/kubernetes-b87b1fd336
chore(deps): bump the kubernetes group with 2 updates
2026-04-19 01:51:39 +00:00
dependabot[bot]
3dc647d2f0 chore(deps): bump the kubernetes group with 2 updates
Bumps the kubernetes group with 2 updates: [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go).


Updates `k8s.io/apimachinery` from 0.35.3 to 0.35.4
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.35.3...v0.35.4)

Updates `k8s.io/client-go` from 0.35.3 to 0.35.4
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.35.3...v0.35.4)

---
updated-dependencies:
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.35.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: kubernetes
- dependency-name: k8s.io/client-go
  dependency-version: 0.35.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: kubernetes
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-19 01:42:44 +00:00
github-actions[bot]
0b4d946f47 Merge pull request #495 from ahmetb/dependabot/go_modules/github.com/mattn/go-isatty-0.0.21
chore(deps): bump github.com/mattn/go-isatty from 0.0.20 to 0.0.21
2026-04-12 01:51:33 +00:00
dependabot[bot]
c6f78f22ec chore(deps): bump github.com/mattn/go-isatty from 0.0.20 to 0.0.21
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.20 to 0.0.21.
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.20...v0.0.21)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
  dependency-version: 0.0.21
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-12 01:42:37 +00:00
dependabot[bot]
63d626fc8d chore(deps): bump dependabot/fetch-metadata from 2 to 3
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2 to 3.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v2...v3)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-12 01:42:28 +00:00
dependabot[bot]
bc73df2f6d chore(deps): bump actions/github-script from 8 to 9
Bumps [actions/github-script](https://github.com/actions/github-script) from 8 to 9.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v8...v9)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: '9'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-12 01:42:25 +00:00
Ahmet Alp Balkan
c3c8d5e56e Move krew distribution to Go binaries 2026-04-05 15:36:58 -07:00
Ahmet Alp Balkan
9130a99d5b fix gofmt 2026-03-26 23:12:42 -04:00
Ahmet Alp Balkan
7605ca50c4 Release v0.11.0 (gofmt) v0.11.0 2026-03-26 23:10:42 -04:00
Ahmet Alp Balkan
951f90103f Release v0.11.0 2026-03-26 23:08:32 -04:00
Ahmet Alp Balkan
19d813d567 Use case-insensitive comparison for Connection upgrade header
The isUpgrade() check used exact string match (== "Upgrade") for the
Connection header value. A client sending "Connection: upgrade"
(lowercase) would bypass this check. While not exploitable in practice
(the Upgrade header check catches real upgrades), this hardens the
proxy with defense-in-depth.

Also adds a comprehensive security test suite covering jailbreak
attempts: method override smuggling, path traversal, dryRun parameter
injection, upgrade header smuggling, review endpoint spoofing, unusual
HTTP methods, concurrent request filtering, and credential leakage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 23:06:39 -04:00
Ahmet Alp Balkan
20217f1945 Allow non-mutating POST endpoints and dry-run through readonly proxy
The readonly proxy now permits:
- K8s "review" POST endpoints (SubjectAccessReview, TokenReview, etc.)
  that query auth state without persisting resources
- Requests with ?dryRun=All for server-side validation

Review endpoints are matched with anchored regexps pinned to
authorization.k8s.io and authentication.k8s.io API groups, preventing
spoofing via custom resources with the same name.

Refactors the handler into small, independently tested filter functions
(isUpgrade, isReadOnly, isNonMutatingPost, isDryRun) composed by a
checkRequest commander.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:05:32 -04:00
Ahmet Alp Balkan
6f8704f966 Extract common shell logic into shellSession
Deduplicates code between ShellOp and ReadonlyShellOp by extracting
shared logic (context validation, kubeconfig extraction, temp file
management, shell spawning) into a shellSession struct.

Callers configure behavior via:
- printEntry/printExit callbacks for banner messages
- extraEnv for additional environment variables
- transformKubeconfig hook for kubeconfig transformation (e.g. proxy)

Also extracts fzfPickContext for shared interactive mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 11:45:50 -04:00
Ahmet Alp Balkan
d75d282b17 Update README with readonly flag docs and reorganize examples
- Document -r/--readonly flag with usage example
- Reorganize Examples into Usage section with kubectx/kubens subsections
- Each command example in its own code block
- Remove outdated 'written in bash' badge

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:27:43 -04:00
Ahmet Alp Balkan
c20f59254a Update help text for kubectx and kubens
- Add description strings from bash scripts to Go help output
- Add -r/--readonly usage lines to kubectx help
- Reorder help to show -s/-r flags more prominently
- Normalize flag separators to comma-space consistently

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:27:38 -04:00
Ahmet Alp Balkan
2b2a3bacce Add -r/--readonly flag for read-only shell mode
Introduces ReadonlyShellOp and InteractiveReadonlyShellOp that spawn
an isolated sub-shell routing kubectl traffic through the readonly
reverse proxy. The proxy blocks write operations while allowing reads.

- Extracts minimal kubeconfig, starts proxy, rewrites kubeconfig to
  point at proxy, spawns shell with KUBECTX_READONLY_SHELL=1
- Proxy and temp files cleaned up on shell exit
- Flag parsing mirrors -s/--shell pattern with optional context arg
- Interactive fzf mode supported when no context specified

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:27:32 -04:00
Ahmet Alp Balkan
e868cdb984 Add readonly reverse proxy for kubectx
Introduces a new internal/proxy package that provides a localhost HTTP
reverse proxy enforcing read-only access to the Kubernetes API server.

- Allows GET, HEAD, OPTIONS requests (kubectl get/describe/logs/top/watch)
- Blocks POST, PUT, DELETE, PATCH with metav1.Status 405 responses
- Blocks Connection: Upgrade requests (kubectl exec/cp/port-forward)
- Uses client-go transport for TLS/auth to the real API server
- Rewrites kubeconfig: server URL to proxy, strips auth, sets insecure-skip-tls-verify
- Appends [RO] suffix to context name in rewritten kubeconfig
- DEBUG=1 enables request/response logging
- Comprehensive test coverage for all proxy behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:27:24 -04:00
Ahmet Alp Balkan
2cb7500e34 Support interactive fzf selection for kubectx -s with no arguments
When `kubectx -s` (or `--shell`) is invoked without a context name and
fzf is available in an interactive terminal, launch fzf to let the user
pick a context, then start an isolated shell scoped to that selection.

This mirrors the existing behavior where `kubectx` with no arguments
launches fzf for context switching, and `kubectx -d` with no arguments
launches fzf for context deletion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.10.2
2026-03-23 16:28:25 -07:00
Ahmet Alp Balkan
ccddf675d5 fix: use full git history in release workflow for changelog generation
Replace shallow checkout + `git fetch --tags` with `fetch-depth: 0` so
GoReleaser has the full commit history between tags to generate release
notes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 15:53:12 -07:00
Ahmet Alp Balkan
e4727d38f8 Fix relative path resolution in exec credential plugins (#490)
When kubens needs to query the Kubernetes API (e.g. to check if a
namespace exists), it builds a REST client from the in-memory
kubeconfig bytes using clientcmd.RESTConfigFromKubeConfig(). This
function has no knowledge of the kubeconfig file's location on disk,
so it cannot resolve relative paths in exec credential plugin commands
(e.g. `command: ../scripts/get-token.sh`). This causes a "no such file
or directory" error for users whose kubeconfig uses relative paths in
exec-based authentication.

The fix threads the kubeconfig file path through a new PathHinter
optional interface on ReadWriteResetCloser. When a file path is
available, newKubernetesClientSet now uses
clientcmd.NewNonInteractiveDeferredLoadingClientConfig with
ExplicitPath, which resolves relative paths relative to the kubeconfig
file's directory — matching kubectl's own behavior. The old
bytes-based fallback is preserved for in-memory configs (e.g. tests).

Fixes #488

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 10:18:48 -07:00
dependabot[bot]
6780ceed84 chore(deps): bump actions/checkout from 4 to 6 (#483)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-23 09:30:25 -07:00
dependabot[bot]
a3d295a9d7 chore(deps): bump actions/github-script from 7 to 8 (#482)
Bumps [actions/github-script](https://github.com/actions/github-script) from 7 to 8.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-23 09:30:20 -07:00
Ahmet Alp Balkan
eb621b4406 Support multiple kubeconfig files (KUBECONFIG=file1:file2:file3) (#489)
Previously, kubectx would error with "multiple files in KUBECONFIG are
currently not supported" when KUBECONFIG contained colon-separated paths.
This is a common setup where users maintain separate kubeconfig files for
different clusters/environments.

This change evolves the internal Kubeconfig struct from holding a single
file to a slice of file entries, matching kubectl's merge semantics:

- Reading current-context: first file with a non-empty value wins
- Writing current-context: always written to the first file
- Listing contexts: merged from all files, first occurrence wins for
  duplicate names
- Modifying a context (delete/rename/set-namespace): written to the
  file that owns that context
- Missing files in the KUBECONFIG list are silently skipped (matching
  kubectl behavior), but permission errors are propagated

The Loader interface already returned []ReadWriteResetCloser, so all
public method signatures remain unchanged — zero modifications needed
in cmd/kubectx/ or cmd/kubens/ callers.

Fixes #485
Fixes #211

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 09:28:37 -07:00
Ahmet Alp Balkan
8214f23123 fix: replace deprecated set-output with GITHUB_OUTPUT env file
Fixes #484: The ::set-output:: workflow command is deprecated. Updated
CI workflow to use the $GITHUB_OUTPUT environment file syntax instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 08:46:57 -07:00
github-actions[bot]
ec2d429dae Merge pull request #486 from ahmetb/dependabot/go_modules/kubernetes-a60a1cc88f
chore(deps): bump the kubernetes group with 2 updates
2026-03-22 01:53:12 +00:00
github-actions[bot]
1528960b87 Merge pull request #487 from ahmetb/dependabot/go_modules/github.com/fatih/color-1.19.0
chore(deps): bump github.com/fatih/color from 1.18.0 to 1.19.0
2026-03-22 01:52:42 +00:00
dependabot[bot]
b2fe82051b chore(deps): bump github.com/fatih/color from 1.18.0 to 1.19.0
Bumps [github.com/fatih/color](https://github.com/fatih/color) from 1.18.0 to 1.19.0.
- [Release notes](https://github.com/fatih/color/releases)
- [Commits](https://github.com/fatih/color/compare/v1.18.0...v1.19.0)

---
updated-dependencies:
- dependency-name: github.com/fatih/color
  dependency-version: 1.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-22 01:42:47 +00:00
dependabot[bot]
5aa1d4acf0 chore(deps): bump the kubernetes group with 2 updates
Bumps the kubernetes group with 2 updates: [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go).


Updates `k8s.io/apimachinery` from 0.35.2 to 0.35.3
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.35.2...v0.35.3)

Updates `k8s.io/client-go` from 0.35.2 to 0.35.3
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.35.2...v0.35.3)

---
updated-dependencies:
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.35.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: kubernetes
- dependency-name: k8s.io/client-go
  dependency-version: 0.35.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: kubernetes
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-22 01:42:43 +00:00
Ahmet Alp Balkan
524c9b8f0d Release v0.10.0 v0.10.0 2026-03-20 13:20:38 -07:00
Ahmet Alp Balkan
f500964e24 fix: skip fzf launch in kubens when no contexts exist in kubeconfig (#481)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:30:21 +00:00