Skip to content

Commit

Permalink
refactor: change ContextConfiguration::current() function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Jan 3, 2024
1 parent a3b5bda commit e8f551c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "amp-common"
description = "Rust libraries shared across Amphitheatre components and libraries"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
license = "Apache-2.0"
homepage = "https://amphitheatre.app"
Expand Down
12 changes: 9 additions & 3 deletions src/config/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ impl ContextConfiguration {
self.clusters.get(name)
}

/// Get the current context.
pub fn current(&self) -> Option<&Cluster> {
/// Get the current context with name.
pub fn current(&self) -> Option<(String, Cluster)> {
if let Some(name) = &self.current {
return self.clusters.get(name).to_owned();
return Some((name.clone(), self.clusters.get(name).cloned().unwrap_or_default()));
}

None
}

Expand All @@ -82,6 +83,11 @@ impl ContextConfiguration {
self.clusters.iter()
}

/// Get the list of clusters.
pub fn clusters(&self) -> &HashMap<String, Cluster> {
&self.clusters
}

/// Check if the context with the given name exists.
pub fn exists(&self, name: &str) -> bool {
self.clusters.contains_key(name)
Expand Down

0 comments on commit e8f551c

Please sign in to comment.