Skip to content

Commit

Permalink
feat: specify kubeconfig location via env vars
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
Stef16Robbe committed Nov 19, 2024
1 parent 358c01f commit e93c7a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Options:
-V, --version Print version
```

You can specify a Kubeconfig file other than the default (`$HOME/.kube/config`) using the `KUBECONFIG` environment variable

## TODO's

- [x] CI & releases
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ fn main() -> Result<()> {
.init();

let base_dirs = BaseDirs::new().unwrap();
// for now assuming we always use $HOME/.kube/
let kubeconfig_location = base_dirs.home_dir().join(Path::new(".kube/config"));
let kubeconfig_location = std::env::var("KUBECONFIG")
.map(|v| v.into())
.unwrap_or_else(|_| base_dirs.home_dir().join(Path::new(".kube/config")));

let kubeconfig = Kman::load_kubeconfig(&kubeconfig_location).unwrap();
let mut kman = Kman::new(kubeconfig);

Expand Down

0 comments on commit e93c7a3

Please sign in to comment.