Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty kubeconfig file not defaulting #721

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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