Skip to content

Commit

Permalink
Add metadata to cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-consoli committed Oct 30, 2023
1 parent 9dd4ec3 commit 54f89c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions crates/fluvio/src/config/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//!
//! Stores configuration parameter retrieved from the default or custom profile file.
//!
use std::collections::HashMap;

use serde::{Serialize, Deserialize};

use crate::{config::TlsPolicy, FluvioError};
Expand All @@ -13,7 +11,7 @@ use super::ConfigFile;

/// Fluvio Cluster Target Configuration
/// This is part of profile
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct FluvioConfig {
/// The address to connect to the Fluvio cluster
Expand All @@ -31,9 +29,8 @@ pub struct FluvioConfig {
#[serde(default)]
pub tls: TlsPolicy,

/// Custom annotations attached to clusters
#[serde(default)]
pub annotations: HashMap<String, String>,
/// Cluster custom metadata
pub metadata: Option<toml::Value>,

/// This is not part of profile and doesn't persist.
/// It is purely to override client id when creating ClientConfig
Expand All @@ -55,7 +52,7 @@ impl FluvioConfig {
endpoint: addr.into(),
use_spu_local_address: false,
tls: TlsPolicy::Disabled,
annotations: HashMap::new(),
metadata: None,
client_id: None,
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/fluvio/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl ConfigFile {
pub const LOCAL_PROFILE: &str = "local";
const CONFIG_VERSION: &str = "2.0";

#[derive(Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct Config {
version: String,
current_profile: Option<String>,
Expand Down Expand Up @@ -570,6 +570,8 @@ pub mod test {

#[test]
fn test_profile_with_metadata() {
use std::collections::BTreeMap;

let config_file = ConfigFile::load(Some("test-data/profiles/config.toml".to_owned()))
.expect("could not parse config file");
let config = config_file.config();
Expand Down
12 changes: 6 additions & 6 deletions crates/fluvio/test-data/profiles/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ isolation = "read_committed"
[topic.test4.2]
isolation = "uncommitted"

# cluster annotations
[cluster.with_annotations]
# cluster metadata
[cluster.extra]
endpoint = "127.0.0.1:9003"

[cluster.with_annotations.annotations]
custom = "annotation"
[cluster.extra.metadata.deep.nesting.example]
key = "custom field"

[cluster.no_annotations]
endpoint = "127.0.0.1:9003"
[cluster.extra.metadata.installation]
type = "local"

0 comments on commit 54f89c2

Please sign in to comment.