Skip to content

Commit

Permalink
Refactor Kubeconfig::read_from to use kubeconfig_from_text internally
Browse files Browse the repository at this point in the history
  • Loading branch information
imp committed Nov 18, 2021
1 parent ab4de37 commit 7f5d807
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,10 @@ impl Kubeconfig {
pub fn read_from<P: AsRef<Path>>(path: P) -> Result<Kubeconfig, KubeconfigError> {
let data = fs::read_to_string(&path)
.map_err(|source| KubeconfigError::ReadConfig(source, path.as_ref().into()))?;
// support multiple documents
let mut documents: Vec<Kubeconfig> = vec![];
for doc in serde_yaml::Deserializer::from_str(&data) {
let value = serde_yaml::Value::deserialize(doc).map_err(KubeconfigError::Parse)?;
let kconf = serde_yaml::from_value(value).map_err(KubeconfigError::InvalidStructure)?;
documents.push(kconf)
}

// Remap all files we read to absolute paths.
let mut merged_docs = None;
for mut config in documents {
for mut config in kubeconfig_from_text(&data)? {
if let Some(dir) = path.as_ref().parent() {
for named in config.clusters.iter_mut() {
if let Some(path) = &named.cluster.certificate_authority {
Expand Down

0 comments on commit 7f5d807

Please sign in to comment.