Skip to content

Commit

Permalink
allow loading kubeconfig from other paths
Browse files Browse the repository at this point in the history
Signed-off-by: goenning <me@goenning.net>
  • Loading branch information
goenning committed Dec 4, 2022
1 parent 593fa89 commit 199906f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,17 @@ impl Kubeconfig {
///
/// Panics if `KUBECONFIG` value contains the NUL character.
pub fn from_env() -> Result<Option<Self>, KubeconfigError> {
match std::env::var_os(KUBECONFIG) {
Self::from_custom_env(KUBECONFIG)
}

/// Create `Kubeconfig` from a given environment variable.
/// Supports list of files to be merged.
///
/// # Panics
///
/// Panics if the environment variable value contains the NUL character.
pub fn from_custom_env(env_name: &str) -> Result<Option<Self>, KubeconfigError> {
match std::env::var_os(env_name) {
Some(value) => {
let paths = std::env::split_paths(&value)
.filter(|p| !p.as_os_str().is_empty())
Expand Down

0 comments on commit 199906f

Please sign in to comment.