Skip to content

Commit f524a25

Browse files
committed
fix: adapt recent changes
1 parent e0cb184 commit f524a25

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

agent-control/src/cli/on_host/host_monitoring_gen/infra_config_gen.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use crate::config_migrate::migration::defaults::NEWRELIC_INFRA_AGENT_TYPE_CONFIG
1313
use crate::config_migrate::migration::migrator::{ConfigMigrator, MigratorError};
1414
use crate::config_migrate::migration::persister::legacy_config_renamer::LegacyConfigRenamer;
1515
use crate::config_migrate::migration::persister::values_persister_file::ValuesPersisterFile;
16-
use crate::values::file::ConfigRepositoryFile;
16+
use crate::on_host::file_store::FileStore;
17+
use crate::values::ConfigRepo;
1718
use std::path::{Path, PathBuf};
1819
use std::sync::Arc;
1920
use tracing::{debug, info, warn};
@@ -79,7 +80,10 @@ impl InfraConfigGenerator {
7980

8081
fn create_new_infra_values(&self, infra_config: InfraConfig) -> Result<(), CliError> {
8182
info!("Creating new infra agent configuration");
82-
let vr = ConfigRepositoryFile::new(self.local_dir.clone(), self.remote_dir.clone());
83+
let vr = ConfigRepo::new(Arc::new(FileStore::new_local_fs(
84+
self.local_dir.clone(),
85+
self.remote_dir.clone(),
86+
)));
8387
let sa_local_config_loader = AgentControlConfigStore::new(Arc::new(vr));
8488

8589
let config_getter = AgentConfigGetter::new(sa_local_config_loader);
@@ -118,7 +122,10 @@ impl InfraConfigGenerator {
118122
let config = MigrationConfig::parse(modified_yaml.as_str())
119123
.map_err(|err| CliError::Command(format!("error parsing migration config: {err}")))?;
120124

121-
let vr = ConfigRepositoryFile::new(self.local_dir.clone(), self.remote_dir.clone());
125+
let vr = ConfigRepo::new(Arc::new(FileStore::new_local_fs(
126+
self.local_dir.clone(),
127+
self.remote_dir.clone(),
128+
)));
122129
let sa_local_config_loader = AgentControlConfigStore::new(Arc::new(vr));
123130
let config_migrator = ConfigMigrator::new(
124131
ConfigConverter::default(),
@@ -169,7 +176,6 @@ mod tests {
169176
use crate::agent_control::defaults::{
170177
AGENT_CONTROL_ID, FOLDER_NAME_LOCAL_DATA, STORE_KEY_LOCAL_DATA_CONFIG,
171178
};
172-
use crate::opamp::instance_id::on_host::storer::build_config_name;
173179
use std::fs;
174180
use std::fs::create_dir_all;
175181
use tempfile::TempDir;
@@ -195,6 +201,8 @@ agents:
195201
#[test]
196202
fn test_migrate_old_infra_config() {
197203
// Create a temporary directory
204+
205+
use crate::on_host::file_store::build_config_name;
198206
let temp_dir = TempDir::new().unwrap();
199207
let infra_file_path = temp_dir.path().join("newrelic-infra.yml");
200208
let agents_file_path = temp_dir
@@ -264,6 +272,8 @@ config_agent:
264272
#[cfg(target_family = "unix")] //TODO This should be removed when Windows support is added (DirectoryManager unimplemented)
265273
#[test]
266274
fn test_generate_new_infra_config() {
275+
use crate::on_host::file_store::build_config_name;
276+
267277
let temp_dir = TempDir::new().unwrap();
268278
let agents_file_path = temp_dir
269279
.path()

agent-control/src/cli/on_host/migrate_folders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::agent_control::defaults::{
33
STORE_KEY_LOCAL_DATA_CONFIG, STORE_KEY_OPAMP_DATA_CONFIG,
44
};
55
use crate::cli::error::CliError;
6-
use crate::opamp::instance_id::on_host::storer::build_config_name;
6+
use crate::on_host::file_store::build_config_name;
77
use std::fs;
88
use std::path::{Path, PathBuf};
99
use tracing::{debug, error};

agent-control/src/config_migrate/migration/migrator.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ mod tests {
109109
use crate::config_migrate::migration::converter::ConfigConverter;
110110
use crate::config_migrate::migration::migrator::ConfigMigrator;
111111
use crate::config_migrate::migration::persister::values_persister_file::ValuesPersisterFile;
112-
use crate::opamp::instance_id::on_host::storer::build_config_name;
113-
use crate::values::file::ConfigRepositoryFile;
114112
use std::fs::create_dir_all;
115113
use std::sync::Arc;
116114
use tempfile::TempDir;
@@ -134,6 +132,11 @@ agents:
134132
#[cfg(target_family = "unix")] //TODO This should be removed when Windows support is added
135133
#[test]
136134
fn test_migrate() {
135+
use crate::{
136+
on_host::file_store::{FileStore, build_config_name},
137+
values::ConfigRepo,
138+
};
139+
137140
let tmp_dir = TempDir::new().unwrap();
138141
let infra_file_path = tmp_dir.path().join("newrelic-infra.yml");
139142
let agents_file_path = tmp_dir
@@ -151,8 +154,10 @@ agents:
151154
)
152155
.unwrap();
153156

154-
let vr =
155-
ConfigRepositoryFile::new(tmp_dir.path().to_path_buf(), tmp_dir.path().to_path_buf());
157+
let vr = ConfigRepo::new(Arc::new(FileStore::new_local_fs(
158+
tmp_dir.path().to_path_buf(),
159+
tmp_dir.path().to_path_buf(),
160+
)));
156161
let sa_local_config_loader = AgentControlConfigStore::new(Arc::new(vr));
157162

158163
let config_migrator = ConfigMigrator::new(

0 commit comments

Comments
 (0)