diff --git a/crates/common/mqtt_channel/src/topics.rs b/crates/common/mqtt_channel/src/topics.rs index 29eae52c805..9e3f1e8d8b0 100644 --- a/crates/common/mqtt_channel/src/topics.rs +++ b/crates/common/mqtt_channel/src/topics.rs @@ -41,8 +41,8 @@ impl Topic { /// An MQTT topic filter #[derive(Debug, Clone, Eq, PartialEq)] pub struct TopicFilter { - pub patterns: Vec, - pub qos: QoS, + patterns: Vec, + qos: QoS, } impl Default for TopicFilter { diff --git a/crates/extensions/tedge_config_manager/src/actor.rs b/crates/extensions/tedge_config_manager/src/actor.rs index 598e3d01c65..eeec9abc8b1 100644 --- a/crates/extensions/tedge_config_manager/src/actor.rs +++ b/crates/extensions/tedge_config_manager/src/actor.rs @@ -513,9 +513,9 @@ impl ConfigManagerActor { async fn publish_supported_config_types(&mut self) -> Result<(), ChannelError> { let mut config_types = self.plugin_config.get_all_file_types(); config_types.sort(); - for topic in self.config.config_reload_topics.patterns.iter() { + for topic in self.config.config_reload_topics.iter() { let metadata = ConfigOperationData::Metadata { - topic: Topic::new_unchecked(topic), + topic: topic.clone(), types: config_types.clone(), }; self.mqtt_publisher.send(metadata.into()).await?; diff --git a/crates/extensions/tedge_config_manager/src/config.rs b/crates/extensions/tedge_config_manager/src/config.rs index 53614ea2f31..a75b70356e7 100644 --- a/crates/extensions/tedge_config_manager/src/config.rs +++ b/crates/extensions/tedge_config_manager/src/config.rs @@ -18,6 +18,7 @@ use tedge_api::mqtt_topics::MqttSchema; use tedge_api::mqtt_topics::OperationType; use tedge_config::ReadError; use tedge_config::SudoCommandBuilder; +use tedge_mqtt_ext::Topic; use tedge_mqtt_ext::TopicFilter; use tedge_utils::file::PermissionEntry; @@ -35,7 +36,7 @@ pub struct ConfigManagerConfig { pub plugin_config_path: PathBuf, pub tmp_path: Arc, pub mqtt_schema: MqttSchema, - pub config_reload_topics: TopicFilter, + pub config_reload_topics: Vec, pub config_update_topic: TopicFilter, pub config_snapshot_topic: TopicFilter, pub tedge_http_host: Arc, @@ -66,12 +67,7 @@ impl ConfigManagerConfig { let config_reload_topics = [OperationType::ConfigSnapshot, OperationType::ConfigUpdate] .into_iter() - .map(|cmd| { - mqtt_topic_root.topics( - EntityFilter::Entity(&mqtt_device_topic_id), - ChannelFilter::CommandMetadata(cmd), - ) - }) + .map(|cmd| mqtt_topic_root.capability_topic_for(&mqtt_device_topic_id, cmd)) .collect(); let config_update_topic = mqtt_topic_root.topics( diff --git a/crates/extensions/tedge_config_manager/src/tests.rs b/crates/extensions/tedge_config_manager/src/tests.rs index 51fbb147162..c1e15d2fb7b 100644 --- a/crates/extensions/tedge_config_manager/src/tests.rs +++ b/crates/extensions/tedge_config_manager/src/tests.rs @@ -80,12 +80,13 @@ async fn new_config_manager_builder( config_dir: temp_dir.to_path_buf(), plugin_config_dir: temp_dir.to_path_buf(), plugin_config_path: temp_dir.join("tedge-configuration-plugin.toml"), - config_reload_topics: vec![ + config_reload_topics: [ "te/device/main///cmd/config_snapshot", "te/device/main///cmd/config_update", ] - .try_into() - .expect("Infallible"), + .into_iter() + .map(Topic::new_unchecked) + .collect(), tmp_path: Arc::from(Utf8Path::from_path(&std::env::temp_dir()).unwrap()), use_tedge_write: TedgeWriteStatus::Disabled, mqtt_schema: MqttSchema::new(),