Skip to content

Commit

Permalink
Update Kubeconfig::read_from to use YAML helper
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
  • Loading branch information
imp committed Nov 20, 2021
1 parent 4a7303b commit 841655c
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 @@ -226,17 +226,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_yaml(&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 841655c

Please sign in to comment.