Skip to content

Commit

Permalink
Merge pull request #721 from kazk/fix-empty-kubeconfig-defaulting
Browse files Browse the repository at this point in the history
  • Loading branch information
kazk authored Nov 19, 2021
2 parents 6bd7e05 + 0bf551f commit 9ac2db8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ impl Kubeconfig {
merged_docs = Some(config);
}
}
let config = merged_docs.ok_or_else(|| KubeconfigError::EmptyConfig(path.as_ref().to_path_buf()))?;
Ok(config)
// Empty file defaults to an empty Kubeconfig
Ok(merged_docs.unwrap_or_default())
}

/// Read a Config from `KUBECONFIG` or the the default location.
Expand Down
4 changes: 0 additions & 4 deletions kube-client/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ pub enum KubeconfigError {
#[error("the structure of the parsed kubeconfig is invalid: {0}")]
InvalidStructure(#[source] serde_yaml::Error),

/// Failed to find a single YAML document in kubeconfig
#[error("failed to find a single YAML document in kubeconfig: {0}")]
EmptyConfig(PathBuf),

/// Failed to parse cluster url
#[error("failed to parse cluster url: {0}")]
ParseClusterUrl(#[source] http::uri::InvalidUri),
Expand Down

0 comments on commit 9ac2db8

Please sign in to comment.