INNER CODE UNIT · Rust

make_kubeconfig_for_context

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

    pub fn make_kubeconfig_for_context(
        &self,
        context_name: &str,
        namespace_name: Option<impl Into<String>>,
    ) -> Result<KubeConfig> {
        let mut context_src = self
            .contexts
            .iter()
            .find(|c| c.item.name == context_name)
            .cloned()
            .ok_or_else(|| anyhow!("Could not find context {}", context_name))?;

        context_src.item.context.namespace = namespace_name.map(Into::into);
        let kubeconfig_dir = context_src.source.parent().expect("kubeconfig path should have a parent dir");

        let cluster_src = self
            .find_cluster_by_name(&context_src.item.context.cluster, &context_src.source)
            .cloned()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…