INNER CODE UNIT · Rust

write_to_file

kubie-org/kubie · src/kubeconfig.rs:76

    pub fn write_to_file(&self, path: &Path) -> anyhow::Result<()> {
        let file = File::create(path).context("could not write file")?;
        fs::set_permissions(path, Permissions::from_mode(0o600))?;

        let buffer = BufWriter::new(file);
        serde_yaml::to_writer(buffer, self)?;
        Ok(())
    }
}

impl Installed {
    pub fn find_context_by_name(&self, name: &str) -> Option<&Sourced<NamedContext>> {
        self.contexts.iter().find(|s| s.item.name == name)
    }

    pub fn find_cluster_by_name(&self, name: &str, source: &Path) -> Option<&Sourced<NamedCluster>> {
        self.clusters
            .iter()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…