pub struct TalosConfig {
pub context: Option<String>,
pub contexts: HashMap<String, TalosContext>,
}Expand description
Represents the entire talosctl configuration file structure
Fields§
§context: Option<String>The currently active context name
contexts: HashMap<String, TalosContext>Map of context names to their configurations
Implementations§
Source§impl TalosConfig
impl TalosConfig
Sourcepub fn load_default() -> Result<Self>
pub fn load_default() -> Result<Self>
Load configuration from the default location (~/.talos/config)
§Errors
Returns an error if:
- The home directory cannot be determined
- The config file cannot be read
- The config file is malformed
Sourcepub fn load_from_path<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_path<P: AsRef<Path>>(path: P) -> Result<Self>
Sourcepub fn default_path() -> Result<PathBuf>
pub fn default_path() -> Result<PathBuf>
Get the default config file path (~/.talos/config)
§Errors
Returns an error if the home directory cannot be determined
Sourcepub fn config_path() -> Result<PathBuf>
pub fn config_path() -> Result<PathBuf>
Get the path to the config file, respecting TALOSCONFIG environment variable
§Errors
Returns an error if the home directory cannot be determined when TALOSCONFIG is not set
Sourcepub fn active_context(&self) -> Option<&TalosContext>
pub fn active_context(&self) -> Option<&TalosContext>
Get the currently active context
§Returns
Returns None if no active context is set or if the context doesn’t exist
Sourcepub fn get_context(&self, name: &str) -> Option<&TalosContext>
pub fn get_context(&self, name: &str) -> Option<&TalosContext>
Sourcepub fn context_names(&self) -> Vec<&str>
pub fn context_names(&self) -> Vec<&str>
List all available context names
Sourcepub fn load_with_env() -> Result<Self>
pub fn load_with_env() -> Result<Self>
Load configuration with environment variable overrides
This method respects the following environment variables:
TALOSCONFIG: Path to the config file (default:~/.talos/config)TALOS_CONTEXT: Override the active contextTALOS_ENDPOINTS: Override endpoints (comma-separated)TALOS_NODES: Override target nodes (comma-separated)
§Example
use talos_api_rs::config::TalosConfig;
// Load config with env overrides
let config = TalosConfig::load_with_env()?;
// Get effective context (may be overridden by TALOS_CONTEXT)
if let Some(ctx) = config.active_context() {
println!("Using endpoints: {:?}", ctx.endpoints);
}Sourcepub fn effective_context_name(&self) -> Option<&str>
pub fn effective_context_name(&self) -> Option<&str>
Get the effective context name (respects TALOS_CONTEXT env var)
Trait Implementations§
Source§impl Clone for TalosConfig
impl Clone for TalosConfig
Source§fn clone(&self) -> TalosConfig
fn clone(&self) -> TalosConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TalosConfig
impl Debug for TalosConfig
Source§impl<'de> Deserialize<'de> for TalosConfig
impl<'de> Deserialize<'de> for TalosConfig
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>,
Source§impl PartialEq for TalosConfig
impl PartialEq for TalosConfig
Source§impl Serialize for TalosConfig
impl Serialize for TalosConfig
impl StructuralPartialEq for TalosConfig
Auto Trait Implementations§
impl Freeze for TalosConfig
impl RefUnwindSafe for TalosConfig
impl Send for TalosConfig
impl Sync for TalosConfig
impl Unpin for TalosConfig
impl UnwindSafe for TalosConfig
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§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request