Compare commits

..

4 Commits

Author SHA1 Message Date
9a1aad62c9 Merge pull request 'fix: kubeconfig falls back to .kube if KUBECONFIG env variable is not set' (#205) from fix/kubeconfig into master
All checks were successful
Run Check Script / check (push) Successful in 1m9s
Compile and package harmony_composer / package_harmony_composer (push) Successful in 7m49s
Reviewed-on: #205
2026-01-07 21:05:49 +00:00
0f9a53c8f6 cargo fmt
All checks were successful
Run Check Script / check (pull_request) Successful in 1m4s
2026-01-07 15:57:56 -05:00
b21829470d Merge pull request 'fix: modified nats box to use image tag non root for use in openshift environment' (#204) from fix/nats_non_root into master
All checks were successful
Run Check Script / check (push) Successful in 1m5s
Compile and package harmony_composer / package_harmony_composer (push) Successful in 7m36s
Reviewed-on: #204
2026-01-07 20:52:42 +00:00
4dcaf55dc5 fix: kubeconfig falls back to .kube if KUBECONFIG env variable is not set
Some checks failed
Run Check Script / check (pull_request) Failing after 2s
2026-01-07 15:47:08 -05:00

View File

@@ -1006,8 +1006,28 @@ impl K8sAnywhereConfig {
} }
fn from_env() -> Self { fn from_env() -> Self {
fn get_kube_config_path() -> Option<std::path::PathBuf> {
// 1. Check for the KUBECONFIG environment variable first (standard practice)
if let Ok(val) = std::env::var("KUBECONFIG") {
if !val.is_empty() {
return Some(std::path::PathBuf::from(val));
}
}
// 2. Use the standard library to find the home directory
// As of recent Rust versions, this is the preferred cross-platform method.
let mut path = std::env::home_dir()?;
// 3. Construct the path to .kube/config
// .push() handles OS-specific separators (\ for Windows, / for Unix)
path.push(".kube");
path.push("config");
Some(path)
}
Self { Self {
kubeconfig: std::env::var("KUBECONFIG").ok().map(|v| v.to_string()), kubeconfig: get_kube_config_path().map(|s| s.to_string_lossy().into_owned()),
use_system_kubeconfig: std::env::var("HARMONY_USE_SYSTEM_KUBECONFIG") use_system_kubeconfig: std::env::var("HARMONY_USE_SYSTEM_KUBECONFIG")
.map_or_else(|_| false, |v| v.parse().ok().unwrap_or(false)), .map_or_else(|_| false, |v| v.parse().ok().unwrap_or(false)),
autoinstall: std::env::var("HARMONY_AUTOINSTALL") autoinstall: std::env::var("HARMONY_AUTOINSTALL")