File kubectl-switch-2.2.13.obscpio of Package kubectl-switch
07070100000000000081A400000000000000000000000168B36737000000DF000000000000000000000000000000000000002900000000kubectl-switch-2.2.13/.commitlintrc.json{
"rules": {
"subject-case": [
2,
"never",
[
"start-case",
"pascal-case",
"upper-case"
]
],
"header-max-length": [
2,
"always",
150
]
}
}07070100000001000081A400000000000000000000000168B367370000018B000000000000000000000000000000000000002500000000kubectl-switch-2.2.13/.golangci.yaml---
version: "2"
linters:
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
07070100000002000081A400000000000000000000000168B3673700000F60000000000000000000000000000000000000002700000000kubectl-switch-2.2.13/.goreleaser.yaml---
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2
project_name: kubectl-switch
before:
hooks:
- go mod tidy
- go mod download
builds:
- env:
- CGO_ENABLED=0
binary: "{{.ProjectName}}"
goos:
- linux
- darwin
ldflags:
- -s -w -X github.com/mirceanton/{{.ProjectName}}/cmd.version={{.Version}}
archives:
- format: tar.gz
name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
checksum:
disable: false
name_template: "checksums.txt"
changelog:
disable: false
use: github
sort: asc
groups:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: "Patches"
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: "CI"
regexp: ".*ci.*"
order: 998
- title: Others
order: 999
nfpms:
- homepage: https://github.com/mirceanton/{{.ProjectName}}
maintainer: Mircea-Pavel Anton <contact@mirceanton.com>
description: A simple tool to switch between Kubernetes contexts.
file_name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
license: MIT
formats: [deb, apk, rpm]
brews:
- name: kubectl-switch
description: A simple tool to switch between Kubernetes contexts.
license: MIT
homepage: https://github.com/mirceanton/{{.ProjectName}}
directory: Formula
repository:
owner: mirceanton
name: homebrew-taps
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
test: system "#{bin}/kubectl-switch", "--help"
commit_author:
name: mr-borboto[bot]
email: 170036086+mr-borboto[bot]@users.noreply.github.com
dockers:
- image_templates:
- "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-amd64"
use: buildx
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.url=https://github.com/mirceanton/{{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/mirceanton/{{.ProjectName}}"
- "--label=org.opencontainers.image.licenses=MIT"
- "--label=org.opencontainers.image.authors=Mircea-Pavel Anton <contact@mirceanton.com>"
- "--label=org.opencontainers.image.description=A simple tool to switch between Kubernetes contexts."
- image_templates:
- "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-arm64v8"
use: buildx
goarch: arm64
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.url=https://github.com/mirceanton/{{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/mirceanton/{{.ProjectName}}"
- "--label=org.opencontainers.image.licenses=MIT"
- "--label=org.opencontainers.image.authors=Mircea-Pavel Anton <contact@mirceanton.com>"
- "--label=org.opencontainers.image.description=A simple tool to switch between Kubernetes contexts."
docker_manifests:
- name_template: "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}"
image_templates:
- "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-amd64"
- "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-arm64v8"
- name_template: "ghcr.io/mirceanton/{{.ProjectName}}:latest"
image_templates:
- "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-amd64"
- "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-arm64v8"
07070100000003000081A400000000000000000000000168B36737000003BE000000000000000000000000000000000000002100000000kubectl-switch-2.2.13/.mise.toml[tools]
# =================================================================================================
# Project Tools -> pinned versions
# =================================================================================================
go = "1.25.0"
"aqua:golangci/golangci-lint" = "2.4.0"
"aqua:goreleaser/goreleaser" = "2.11.2"
"aqua:kubernetes/kubectl" = "1.33.1"
# =================================================================================================
# Misc Tools
# =================================================================================================
"aqua:kubernetes/minikube" = "latest"
"aqua:helm/helm" = "latest"
"aqua:derailed/k9s" = "latest"
# =================================================================================================
# CI Tools
# =================================================================================================
"npm:@commitlint/cli" = "19"
"aqua:rhysd/actionlint" = "1"
07070100000004000081A400000000000000000000000168B367370000008D000000000000000000000000000000000000002700000000kubectl-switch-2.2.13/.renovaterc.json{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "github>mirceanton/renovate-config//default.json5" ]
}07070100000005000081A400000000000000000000000168B3673700000072000000000000000000000000000000000000002100000000kubectl-switch-2.2.13/DockerfileFROM gcr.io/distroless/static-debian12:nonroot
USER 8675:8675
COPY kubectl-switch /
ENTRYPOINT ["/kubectl-switch"]07070100000006000081A400000000000000000000000168B3673700000433000000000000000000000000000000000000001E00000000kubectl-switch-2.2.13/LICENSEMIT License
Copyright (c) 2023 Mircea-Pavel Anton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
07070100000007000081A400000000000000000000000168B36737000019C0000000000000000000000000000000000000002000000000kubectl-switch-2.2.13/README.md# kubectl-switch
`kubectl-switch` is a command-line tool for managing and switching between multiple Kubernetes configuration files located in the same directory. It simplifies the process of selecting a Kubernetes context from multiple kubeconfig files and updating the active configuration or namespace.
Just dump all your `kubeconfigs` into a single dir and let `kubectl-switch` manage them for you!
## Features
- **Multiple kubeconfig files**: Manage multiple kubeconfig files with one or more contexts each, all present in a single directory. You don't have to generate a global kubeconfig to hold all of your contexts
- **Context Switching**: Easily switch between different Kubernetes contexts from multiple config files.
- **Namespace Switching**: Quickly change the current namespace in the active context.
- **Previous Config**: Switch back to the previous configuration with `kubectl switch -`.
- **Non-Interactive Mode**: Specify the desired context or namespace directly as an argument.
- **Interactive Mode**: Run the program with no arguments to get an interactive list of available namespaces or contexts to choose from.
- **Persistent Configuration**: Changes persist across different shell sessions.
- **Shell Completions**: Provides tab completion for available contexts and namespaces.
- **Non-destructive**: `kubectl-switch` will never edit those. It will only work with copies of them.
## Why `kubectl-switch`?
`kubectl-switch` is an alternative to tools like `kubectx`, `kubens` and `kubie`. It has been created because I feel all of those fall short in certain regards:
- `kubectx` and `kubens` assume all your contexts are defined in a single config file. Yes, there is some hackery you can do to your `KUBECONFIG` environment variable to make it work with multiple files, but it is (in my opinion) a sub-par workflow and I never really liked it
- `kubie` spawns a new shell when you use it to change contexts, making it practically impossible to integrate into scripts or taskfile automation. Also I consider it to be too complicated of a solution for what is fundamentally a really simple problem
What I wanted was something very simple conceptually: I just want to dump all my `kubeconfig` files in a single directory and then have my tool parse them and "physically" move over the config file to `.kube/config` (or whatever is configured in my `KUBECONFIG` env var) such that it is also persistent between different shells. Here is where `kubectl-switch` comes in!
## Installation
### Install via go install
Install the latest stable version directly using Go:
```bash
# Install the latest version
go install github.com/mirceanton/kubectl-switch/v2@latest
# Or install a specific version
go install github.com/mirceanton/kubectl-switch/v2@v2.2.6
```
> **Note**: Versions prior to v2.2.6 cannot be installed via `go install` due to module path issues. If you need an older version, please use one of the alternative installation methods below.
### Download Precompiled Binaries
Precompiled binaries are available for various platforms. You can download the latest release from the [GitHub Releases page](https://github.com/mirceanton/kubectl-switch/releases/latest).
1. Download the appropriate binary for your system and extract the archive.
2. Make the extracted binary executable:
```bash
chmod +x kubectl-switch
```
3. Move the binary to a directory in your PATH:
```bash
mv kubectl-switch /usr/local/bin/kubectl-switch
```
### Install via Homebrew
1. Add the tap
```bash
brew tap mirceanton/taps
```
2. Install `kubectl-switch`
```bash
brew install kubectl-switch
```
### Running via Docker
`kubectl-switch` is also available as a Docker container:
```bash
docker pull ghcr.io/mirceanton/kubectl-switch
```
To use it with your local kubeconfig files:
```bash
docker run -v ~/.kube:/root/.kube -v /path/to/kubeconfigs:/kubeconfigs \
-e KUBECONFIG_DIR=/kubeconfigs \
ghcr.io/mirceanton/kubectl-switch context
```
### Build from Source
1. Clone the repository:
```bash
git clone https://github.com/mirceanton/kubectl-switch
cd kubectl-switch
```
2. Build the tool:
```bash
go build -o kubectl-switch
```
3. Move the binary to your PATH:
```bash
mv kubectl-switch /usr/local/bin/kubectl-switch
```
## Usage
### Context Command
The `context` (or `ctx`) subcommand is used to switch between Kubernetes contexts (think of `kubectx`):
```bash
# Interactive mode - select context from a list
kubectl-switch context
# Switch to a specific context
kubectl-switch ctx my-context
```
### Namespace Command
The `namespace` (or `ns`) subcommand is used to switch the current namespace (think of `kubens`):
```bash
# Interactive mode - select namespace from a list
kubectl-switch namespace
# Switch to a specific namespace
kubectl-switch ns kube-system
```
### Quickly Switch to Previous Configuration
Switch back to the previous configuration:
```bash
kubectl-switch -
```
### Usage with kubectl plugin
When installed as a kubectl plugin, you can use it directly with the `kubectl` command:
```sh
# These commands are equivalent
kubectl-switch ctx
kubectl switch ctx
```
## Configuration
You can configure `kubectl-switch` using environment variables or CLI flags:
| Environment Variable | CLI Flag | Description | Default Value |
| :--------------------: | :---------------: | :----------------------------------------------: | :--------------------------: |
| `KUBECONFIG_DIR` | `--kubeconfig-dir` | Directory containing your kubeconfig files. | None |
| `KUBECONFIG` | N/A | Path where the active kubeconfig will be stored. | `~/.kube/config` |
## Shell Completion
The `completion` subcommand generates shell completion scripts:
```bash
# Generate completions for bash
kubectl-switch completion bash > /etc/bash_completion.d/kubectl-switch
# Generate completions for zsh
kubectl-switch completion zsh > ~/.zsh/completion/_kubectl-switch
# Generate completions for fish
kubectl-switch completion fish > ~/.config/fish/completions/kubectl-switch.fish
# Generate completions for powershell
kubectl-switch completion powershell > ~/kubectl-switch.ps1
```
## Contributing
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
## License
This project is licensed under the MIT License. See the [`LICENSE`](./LICENSE) file for details.
07070100000008000041ED00000000000000000000000268B3673700000000000000000000000000000000000000000000001A00000000kubectl-switch-2.2.13/cmd07070100000009000081A400000000000000000000000168B367370000095C000000000000000000000000000000000000002500000000kubectl-switch-2.2.13/cmd/context.gopackage cmd
import (
"github.com/AlecAivazis/survey/v2"
"github.com/mirceanton/kubectl-switch/v2/pkg/kubeconfig"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var contextManager = kubeconfig.NewContextManager(manager)
var contextCmd = &cobra.Command{
Use: "context",
Aliases: []string{"ctx"},
Short: "Switch the active Kubernetes context",
ValidArgsFunction: getContextCompletions,
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
// Validate and get the config directory
validConfigDir, err := contextManager.ValidateConfigDir(configDir)
if err != nil {
log.Fatal(err)
}
// Get all contexts from kubeconfig files
contextMap, contextNames, err := contextManager.GetContextsFromDir(validConfigDir)
if err != nil {
log.Fatalf("Failed to read kubeconfig files: %v", err)
}
if len(contextMap) == 0 {
log.Fatal("No kubernetes contexts found in the provided directory: ", validConfigDir)
}
// Determine the target context
var selectedContext string
if len(args) == 1 {
selectedContext = args[0]
if _, exists := contextMap[selectedContext]; !exists {
log.Fatalf("Context '%s' not found", selectedContext)
}
} else {
prompt := &survey.Select{
Message: "Choose a context:",
Options: contextNames,
}
err = survey.AskOne(prompt, &selectedContext)
if err != nil {
log.Fatalf("Failed to get user input: %v", err)
}
}
// Switch to the selected context
if err := contextManager.SwitchContext(contextMap[selectedContext], selectedContext); err != nil {
log.Fatalf("Failed to switch context: %v", err)
}
log.Infof("Switched to context '%s'", selectedContext)
},
}
func init() {
rootCmd.AddCommand(contextCmd)
}
// getContextCompletions provides bash completion for available contexts
func getContextCompletions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
configDirFlag, _ := cmd.Flags().GetString("kubeconfig-dir")
validConfigDir, err := contextManager.ValidateConfigDir(configDirFlag)
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
_, contextNames, err := contextManager.GetContextsFromDir(validConfigDir)
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
return contextNames, cobra.ShellCompDirectiveNoFileComp
}
0707010000000A000081A400000000000000000000000168B36737000006E8000000000000000000000000000000000000002700000000kubectl-switch-2.2.13/cmd/namespace.gopackage cmd
import (
"github.com/AlecAivazis/survey/v2"
"github.com/mirceanton/kubectl-switch/v2/pkg/kubeconfig"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var namespaceManager = kubeconfig.NewNamespaceManager(manager)
var namespaceCmd = &cobra.Command{
Use: "namespace",
Aliases: []string{"ns"},
Short: "Switch the active Kubernetes namespace",
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: getNamespaceCompletions,
Run: func(cmd *cobra.Command, args []string) {
// Get all namespaces from the current context
namespaceNames, err := namespaceManager.GetNamespaces()
if err != nil {
log.Fatalf("Error listing namespaces: %v", err)
}
// Determine the target namespace
var selectedNamespace string
if len(args) == 1 {
selectedNamespace = args[0]
} else {
prompt := &survey.Select{
Message: "Choose a namespace:",
Options: namespaceNames,
}
err = survey.AskOne(prompt, &selectedNamespace)
if err != nil {
log.Fatalf("Failed to get user input: %v", err)
}
}
// Switch to the selected namespace
if err := namespaceManager.SwitchNamespace(selectedNamespace); err != nil {
log.Fatalf("Failed to switch namespace: %v", err)
}
log.Infof("Switched to namespace '%s'", selectedNamespace)
},
}
func init() {
rootCmd.AddCommand(namespaceCmd)
}
// getNamespaceCompletions provides bash completion for available namespaces
func getNamespaceCompletions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
namespaceNames, err := namespaceManager.GetNamespaces()
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
return namespaceNames, cobra.ShellCompDirectiveNoFileComp
}
0707010000000B000081A400000000000000000000000168B367370000051D000000000000000000000000000000000000002200000000kubectl-switch-2.2.13/cmd/root.gopackage cmd
import (
"os"
"github.com/mirceanton/kubectl-switch/v2/pkg/kubeconfig"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var (
configDir string // Global flag for the kubeconfig directory
version string // The version of the tool, set at build time
manager = kubeconfig.NewManager()
)
var rootCmd = &cobra.Command{
Use: "kubectl-switch",
Annotations: map[string]string{
cobra.CommandDisplayNameAnnotation: "kubectl switch",
},
Short: "A tool to switch Kubernetes contexts",
Long: `kubectl-switch is a CLI tool to switch Kubernetes contexts from multiple kubeconfig files.`,
Version: version,
RunE: func(cmd *cobra.Command, args []string) error {
// Check if the "-" argument is provided to switch to the previous config
if len(args) == 1 && args[0] == "-" {
if err := manager.SwitchToPrevious(); err != nil {
if err == kubeconfig.ErrNoPreviousConfig {
log.Fatal("No previous configuration found")
} else {
log.Fatalf("Failed to switch to previous config: %v", err)
}
}
return nil
}
return cmd.Help()
},
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().StringVarP(&configDir, "kubeconfig-dir", "", "", "Directory containing kubeconfig files")
}
0707010000000C000081A400000000000000000000000168B3673700000A52000000000000000000000000000000000000001D00000000kubectl-switch-2.2.13/go.modmodule github.com/mirceanton/kubectl-switch/v2
go 1.24.0
// v2 versions without /v2 in module path
retract [v2.0.0, v2.2.5]
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1
k8s.io/apimachinery v0.34.0
k8s.io/client-go v0.34.0
)
require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.34.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
0707010000000D000081A400000000000000000000000168B367370000586A000000000000000000000000000000000000001D00000000kubectl-switch-2.2.13/go.sumgithub.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw=
github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw=
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8=
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.33.1 h1:tA6Cf3bHnLIrUK4IqEgb2v++/GYUtqiu9sRVk3iBXyw=
k8s.io/api v0.33.1/go.mod h1:87esjTn9DRSRTD4fWMXamiXxJhpOIREjWOSjsW1kEHw=
k8s.io/api v0.33.2 h1:YgwIS5jKfA+BZg//OQhkJNIfie/kmRsO0BmNaVSimvY=
k8s.io/api v0.33.2/go.mod h1:fhrbphQJSM2cXzCWgqU29xLDuks4mu7ti9vveEnpSXs=
k8s.io/api v0.33.3 h1:SRd5t//hhkI1buzxb288fy2xvjubstenEKL9K51KBI8=
k8s.io/api v0.33.3/go.mod h1:01Y/iLUjNBM3TAvypct7DIj0M0NIZc+PzAHCIo0CYGE=
k8s.io/api v0.33.4 h1:oTzrFVNPXBjMu0IlpA2eDDIU49jsuEorGHB4cvKupkk=
k8s.io/api v0.33.4/go.mod h1:VHQZ4cuxQ9sCUMESJV5+Fe8bGnqAARZ08tSTdHWfeAc=
k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE=
k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug=
k8s.io/apimachinery v0.33.1 h1:mzqXWV8tW9Rw4VeW9rEkqvnxj59k1ezDUl20tFK/oM4=
k8s.io/apimachinery v0.33.1/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
k8s.io/apimachinery v0.33.2 h1:IHFVhqg59mb8PJWTLi8m1mAoepkUNYmptHsV+Z1m5jY=
k8s.io/apimachinery v0.33.2/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
k8s.io/apimachinery v0.33.3 h1:4ZSrmNa0c/ZpZJhAgRdcsFcZOw1PQU1bALVQ0B3I5LA=
k8s.io/apimachinery v0.33.3/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
k8s.io/apimachinery v0.33.4 h1:SOf/JW33TP0eppJMkIgQ+L6atlDiP/090oaX0y9pd9s=
k8s.io/apimachinery v0.33.4/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0=
k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/client-go v0.33.1 h1:ZZV/Ks2g92cyxWkRRnfUDsnhNn28eFpt26aGc8KbXF4=
k8s.io/client-go v0.33.1/go.mod h1:JAsUrl1ArO7uRVFWfcj6kOomSlCv+JpvIsp6usAGefA=
k8s.io/client-go v0.33.2 h1:z8CIcc0P581x/J1ZYf4CNzRKxRvQAwoAolYPbtQes+E=
k8s.io/client-go v0.33.2/go.mod h1:9mCgT4wROvL948w6f6ArJNb7yQd7QsvqavDeZHvNmHo=
k8s.io/client-go v0.33.3 h1:M5AfDnKfYmVJif92ngN532gFqakcGi6RvaOF16efrpA=
k8s.io/client-go v0.33.3/go.mod h1:luqKBQggEf3shbxHY4uVENAxrDISLOarxpTKMiUuujg=
k8s.io/client-go v0.33.4 h1:TNH+CSu8EmXfitntjUPwaKVPN0AYMbc9F1bBS8/ABpw=
k8s.io/client-go v0.33.4/go.mod h1:LsA0+hBG2DPwovjd931L/AoaezMPX9CmBgyVyBZmbCY=
k8s.io/client-go v0.34.0 h1:YoWv5r7bsBfb0Hs2jh8SOvFbKzzxyNo0nSb0zC19KZo=
k8s.io/client-go v0.34.0/go.mod h1:ozgMnEKXkRjeMvBZdV1AijMHLTh3pbACPvK7zFR+QQY=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4=
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8=
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA=
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts=
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro=
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y=
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc=
sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco=
sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=
0707010000000E000081A400000000000000000000000168B3673700000068000000000000000000000000000000000000001E00000000kubectl-switch-2.2.13/main.gopackage main
import (
"github.com/mirceanton/kubectl-switch/v2/cmd"
)
func main() {
cmd.Execute()
}
0707010000000F000041ED00000000000000000000000268B3673700000000000000000000000000000000000000000000001A00000000kubectl-switch-2.2.13/pkg07070100000010000041ED00000000000000000000000268B3673700000000000000000000000000000000000000000000002500000000kubectl-switch-2.2.13/pkg/kubeconfig07070100000011000081A400000000000000000000000168B3673700000751000000000000000000000000000000000000003000000000kubectl-switch-2.2.13/pkg/kubeconfig/context.gopackage kubeconfig
import (
"os"
"path/filepath"
"strings"
)
// ContextManager handles operations related to Kubernetes contexts
type ContextManager struct {
kubeconfigManager *Manager
}
// NewContextManager creates a new context manager
func NewContextManager(km *Manager) *ContextManager {
return &ContextManager{
kubeconfigManager: km,
}
}
// GetContextsFromDir gets all contexts from kubeconfig files in a directory
func (cm *ContextManager) GetContextsFromDir(configDir string) (map[string]string, []string, error) {
// Handle ~/ in path
if strings.HasPrefix(configDir, "~/") {
homeDir, err := os.UserHomeDir()
if err != nil {
return nil, nil, err
}
configDir = filepath.Join(homeDir, configDir[2:])
}
return cm.kubeconfigManager.GetContextsFromDir(configDir)
}
// SwitchContext switches to the specified context
func (cm *ContextManager) SwitchContext(contextFilePath string, contextName string) error {
// Ensure the destination directory exists
if err := cm.kubeconfigManager.EnsureDir(); err != nil {
return err
}
// Switch to the selected context
if err := cm.kubeconfigManager.SwitchContext(contextFilePath, contextName); err != nil {
return err
}
return nil
}
// ValidateConfigDir ensures the kubeconfig directory is valid and available
func (cm *ContextManager) ValidateConfigDir(configDir string) (string, error) {
if configDir == "" {
configDir = os.Getenv("KUBECONFIG_DIR")
if configDir == "" {
return "", ErrNoConfigDir
}
}
// Handle ~/ in path
if strings.HasPrefix(configDir, "~/") {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", err
}
configDir = filepath.Join(homeDir, configDir[2:])
}
// Check if the directory exists
info, err := os.Stat(configDir)
if err != nil {
return "", err
}
if !info.IsDir() {
return "", ErrNotADirectory
}
return configDir, nil
}
07070100000012000081A400000000000000000000000168B36737000001AE000000000000000000000000000000000000002F00000000kubectl-switch-2.2.13/pkg/kubeconfig/errors.gopackage kubeconfig
import (
"errors"
)
// Common errors for kubeconfig operations
var (
ErrNoConfigDir = errors.New("kubeconfig directory not provided, please provide the directory containing kubeconfig files via the --config-dir flag or KUBECONFIG_DIR environment variable")
ErrNotADirectory = errors.New("the provided path is not a directory")
ErrNoPreviousConfig = errors.New("no previous configuration found")
)
07070100000013000081A400000000000000000000000168B36737000012E4000000000000000000000000000000000000003300000000kubectl-switch-2.2.13/pkg/kubeconfig/kubeconfig.gopackage kubeconfig
import (
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/tools/clientcmd"
)
// Manager handles operations related to kubeconfig files
type Manager struct{}
// NewManager creates a new kubeconfig manager
func NewManager() *Manager {
return &Manager{}
}
// GetPath returns the path to the current kubeconfig file
func (m *Manager) GetPath() string {
path := os.Getenv("KUBECONFIG")
if path == "" {
homeDir, err := os.UserHomeDir()
if err != nil {
log.Fatalf("Failed to determine home directory: %v", err)
}
path = filepath.Join(homeDir, ".kube", "config")
}
return path
}
// GetPreviousPath returns the path to the previous kubeconfig file
func (m *Manager) GetPreviousPath() string {
return filepath.Join(filepath.Dir(m.GetPath()), "config.previous")
}
// SaveCurrent backs up the current kubeconfig file
func (m *Manager) SaveCurrent() error {
kubeconfigPath := m.GetPath()
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
return err
}
prevPath := m.GetPreviousPath()
data, err := os.ReadFile(kubeconfigPath)
if err != nil {
return err
}
return os.WriteFile(prevPath, data, 0o600)
}
// SwitchToPrevious switches back to the previous Kubernetes config
func (m *Manager) SwitchToPrevious() error {
kubeconfigPath := m.GetPath()
prevPath := m.GetPreviousPath()
// Check if previous config exists
if _, err := os.Stat(prevPath); os.IsNotExist(err) {
return ErrNoPreviousConfig
}
// Swap the current and previous configs
tempPath := filepath.Join(filepath.Dir(kubeconfigPath), "config.temp")
// Read current config
currentConfig, err := os.ReadFile(kubeconfigPath)
if err != nil {
return err
}
// Read previous config
prevConfig, err := os.ReadFile(prevPath)
if err != nil {
return err
}
// Write current to temp
if err := os.WriteFile(tempPath, currentConfig, 0o600); err != nil {
return err
}
// Write previous to current
if err := os.WriteFile(kubeconfigPath, prevConfig, 0o600); err != nil {
return err
}
// Write temp to previous
if err := os.WriteFile(prevPath, currentConfig, 0o600); err != nil {
return err
}
// Remove temp file
if err := os.Remove(tempPath); err != nil {
log.Warnf("Failed to remove temporary file: %v", err)
}
return nil
}
// EnsureDir ensures that the directory for the kubeconfig file exists
func (m *Manager) EnsureDir() error {
destDir := filepath.Dir(m.GetPath())
return os.MkdirAll(destDir, 0o755)
}
// GetContextsFromDir gets all contexts from kubeconfig files in a directory
func (m *Manager) GetContextsFromDir(configDir string) (map[string]string, []string, error) {
contextMap := make(map[string]string)
var contextNames []string
files, err := os.ReadDir(configDir)
if err != nil {
return nil, nil, err
}
for _, file := range files {
if file.IsDir() {
continue
}
ext := filepath.Ext(file.Name())
if ext != ".yaml" && ext != ".yml" {
continue
}
path := filepath.Join(configDir, file.Name())
kubeconfig, err := clientcmd.LoadFromFile(path)
if err != nil {
log.WithFields(log.Fields{"file": file.Name()}).Warnf("Failed to parse kubeconfig file: %v", err)
continue
}
for contextName := range kubeconfig.Contexts {
if _, exists := contextMap[contextName]; exists {
log.Warnf("Duplicate context name '%s' found in files:\n- %s\n- %s", contextName, contextMap[contextName], path)
continue
}
contextMap[contextName] = path
contextNames = append(contextNames, contextName)
}
}
return contextMap, contextNames, nil
}
// SwitchContext switches to the specified context
func (m *Manager) SwitchContext(contextFilePath string, contextName string) error {
// Save the current config as the previous config
if err := m.SaveCurrent(); err != nil {
log.Warnf("Failed to save current configuration as previous: %v", err)
}
// Load the kubeconfig file for the selected context
kubeconfig, err := clientcmd.LoadFromFile(contextFilePath)
if err != nil {
return err
}
// Update the current context
kubeconfig.CurrentContext = contextName
// Write the updated kubeconfig back to the file
return clientcmd.WriteToFile(*kubeconfig, m.GetPath())
}
// SwitchNamespace switches the namespace in the current context
func (m *Manager) SwitchNamespace(namespace string) error {
// Save the current config as the previous config
if err := m.SaveCurrent(); err != nil {
log.Warnf("Failed to save current configuration as previous: %v", err)
}
// Load the kubeconfig file
kubeconfig, err := clientcmd.LoadFromFile(m.GetPath())
if err != nil {
return err
}
// Update the namespace in the current context
kubeconfig.Contexts[kubeconfig.CurrentContext].Namespace = namespace
// Write the updated kubeconfig back to the file
return clientcmd.WriteToFile(*kubeconfig, m.GetPath())
}
07070100000014000081A400000000000000000000000168B367370000058E000000000000000000000000000000000000003200000000kubectl-switch-2.2.13/pkg/kubeconfig/namespace.gopackage kubeconfig
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
// NamespaceManager handles operations related to Kubernetes namespaces
type NamespaceManager struct {
kubeconfigManager *Manager
}
// NewNamespaceManager creates a new namespace manager
func NewNamespaceManager(km *Manager) *NamespaceManager {
return &NamespaceManager{
kubeconfigManager: km,
}
}
// GetNamespaces gets all namespaces from the current context
func (nm *NamespaceManager) GetNamespaces() ([]string, error) {
kubeconfigPath := nm.kubeconfigManager.GetPath()
// Build the Kubernetes client configuration
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
if err != nil {
return nil, err
}
// Create the Kubernetes clientset
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, err
}
// Get all namespaces
var namespaceNames []string
namespaces, err := clientset.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})
if err != nil {
return nil, err
}
for _, ns := range namespaces.Items {
namespaceNames = append(namespaceNames, ns.Name)
}
return namespaceNames, nil
}
// SwitchNamespace switches the namespace in the current context
func (nm *NamespaceManager) SwitchNamespace(namespace string) error {
return nm.kubeconfigManager.SwitchNamespace(namespace)
}
07070100000015000041ED00000000000000000000000268B3673700000000000000000000000000000000000000000000001E00000000kubectl-switch-2.2.13/scripts07070100000016000081A400000000000000000000000168B3673700000D3F000000000000000000000000000000000000002600000000kubectl-switch-2.2.13/scripts/test.sh#!/bin/bash
set -e
# Create config directory if it doesn't exist
export KUBECONFIG_DIR="./configs/"
mkdir -p $KUBECONFIG_DIR
cleanup() {
echo "Performing cleanup..."
# Stop and delete minikube clusters
echo "Stopping and deleting test-cluster-1..."
KUBECONFIG=./configs/cluster1.yaml minikube stop -p test-cluster-1 || true
KUBECONFIG=./configs/cluster1.yaml minikube delete -p test-cluster-1 || true
echo "Stopping and deleting test-cluster-2..."
KUBECONFIG=./configs/cluster2.yaml minikube stop -p test-cluster-2 || true
KUBECONFIG=./configs/cluster2.yaml minikube delete -p test-cluster-2 || true
# Remove config directory
echo "Removing configs directory..."
rm -rf ./configs/
echo "Cleanup completed."
}
setup() {
echo "Performing setup..."
# Build kubectl-switch
echo "Building kubectl-switch..."
go build -o kubectl-switch
# Set up Kubernetes clusters
echo "Setting up test clusters..."
KUBECONFIG=./configs/cluster1.yaml minikube start -p test-cluster-1 &
KUBECONFIG=./configs/cluster2.yaml minikube start -p test-cluster-2 &
wait
echo "Setup completed."
}
run_tests() {
echo "Running tests..."
# Test cluster switching and namespace operations
echo "Switching context to test-cluster-1..."
./kubectl-switch context test-cluster-1
echo "Validating cluster switch to test-cluster-1..."
kubectl get nodes | grep "test-cluster-1" || {
echo "Error: test-cluster-1 not found in node list!" >&2
exit 1
}
echo "Checking no pods in default namespace..."
kubectl get pods --namespace=default 2>&1 | grep "No resources found" || {
echo "Error: Pods found in default namespace!" >&2
exit 1
}
echo "Switching to kube-system namespace..."
./kubectl-switch namespace kube-system
echo "Validating kube-system namespace selection and kube-apiserver running..."
kubectl get pods --namespace=kube-system | grep "kube-apiserver" || {
echo "Error: kube-apiserver not found in kube-system!" >&2
exit 1
}
echo "Switching back to default namespace..."
./kubectl-switch namespace default
echo "Checking again that no pods are in default namespace..."
kubectl get pods --namespace=default 2>&1 | grep "No resources found" || {
echo "Error: Pods found in default namespace!" >&2
exit 1
}
echo "Switching context to test-cluster-2..."
./kubectl-switch context test-cluster-2
echo "Validating cluster switch to test-cluster-2..."
kubectl get nodes | grep "test-cluster-2" || {
echo "Error: test-cluster-2 not found in node list!" >&2
exit 1
}
echo "Switching to previous context..."
./kubectl-switch -
echo "Validating cluster switch to test-cluster-1..."
kubectl get nodes | grep "test-cluster-1" || {
echo "Error: test-cluster-1 not found in node list!" >&2
exit 1
}
echo "========================================================================================="
echo "Tests completed successfully!"
echo "========================================================================================="
}
# Set up trap to ensure cleanup happens on exit
trap cleanup EXIT
# Main execution
echo "Starting E2E tests..."
setup
run_tests
echo "E2E tests completed successfully!"
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!117 blocks