pub struct Kubeconfig {
pub preferences: Option<Preferences>,
pub clusters: Vec<NamedCluster>,
pub auth_infos: Vec<NamedAuthInfo>,
pub contexts: Vec<NamedContext>,
pub current_context: Option<String>,
pub extensions: Option<Vec<NamedExtension>>,
pub kind: Option<String>,
pub api_version: Option<String>,
}
config
only.Expand description
Kubeconfig
represents information on how to connect to a remote Kubernetes cluster
Stored in ~/.kube/config
by default, but can be distributed across multiple paths in passed through KUBECONFIG
.
An analogue of the config type from client-go.
This type (and its children) are exposed primarily for convenience.
Config
is the intended developer interface to help create a Client
,
and this will handle the difference between in-cluster deployment and local development.
Fields§
§preferences: Option<Preferences>
General information to be use for cli interactions
clusters: Vec<NamedCluster>
Referencable names to cluster configs
auth_infos: Vec<NamedAuthInfo>
Referencable names to user configs
contexts: Vec<NamedContext>
Referencable names to context configs
current_context: Option<String>
The name of the context that you would like to use by default
extensions: Option<Vec<NamedExtension>>
Additional information for extenders so that reads and writes don’t clobber unknown fields.
kind: Option<String>
Legacy field from TypeMeta
api_version: Option<String>
Legacy field from TypeMeta
Implementations§
source§impl Kubeconfig
impl Kubeconfig
Some helpers on the raw Config object are exposed for people needing to parse it
sourcepub fn read_from<P: AsRef<Path>>(path: P) -> Result<Kubeconfig, KubeconfigError>
pub fn read_from<P: AsRef<Path>>(path: P) -> Result<Kubeconfig, KubeconfigError>
Read a Config from an arbitrary location
sourcepub fn from_yaml(text: &str) -> Result<Kubeconfig, KubeconfigError>
pub fn from_yaml(text: &str) -> Result<Kubeconfig, KubeconfigError>
Read a Config from an arbitrary YAML string
This is preferable to using serde_yaml::from_str() because it will correctly
parse multi-document YAML text and merge them into a single Kubeconfig
sourcepub fn read() -> Result<Kubeconfig, KubeconfigError>
pub fn read() -> Result<Kubeconfig, KubeconfigError>
Read a Config from KUBECONFIG
or the the default location.
sourcepub fn from_env() -> Result<Option<Self>, KubeconfigError>
pub fn from_env() -> Result<Option<Self>, KubeconfigError>
Create Kubeconfig
from KUBECONFIG
environment variable.
Supports list of files to be merged.
§Panics
Panics if KUBECONFIG
value contains the NUL character.
sourcepub fn merge(self, next: Kubeconfig) -> Result<Self, KubeconfigError>
pub fn merge(self, next: Kubeconfig) -> Result<Self, KubeconfigError>
Merge kubeconfig file according to the rules described in https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files
Merge the files listed in the
KUBECONFIG
environment variable according to these rules:
- Ignore empty filenames.
- Produce errors for files with content that cannot be deserialized.
- The first file to set a particular value or map key wins.
- Never change the value or map key. Example: Preserve the context of the first file to set
current-context
. Example: If two files specify ared-user
, use only values from the first file’sred-user
. Even if the second file has non-conflicting entries underred-user
, discard them.
Trait Implementations§
source§impl Clone for Kubeconfig
impl Clone for Kubeconfig
source§fn clone(&self) -> Kubeconfig
fn clone(&self) -> Kubeconfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Kubeconfig
impl Debug for Kubeconfig
source§impl Default for Kubeconfig
impl Default for Kubeconfig
source§fn default() -> Kubeconfig
fn default() -> Kubeconfig
source§impl<'de> Deserialize<'de> for Kubeconfig
impl<'de> Deserialize<'de> for Kubeconfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Kubeconfig
impl RefUnwindSafe for Kubeconfig
impl Send for Kubeconfig
impl Sync for Kubeconfig
impl Unpin for Kubeconfig
impl UnwindSafe for Kubeconfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more