Add ability to exclude environments from data export

This commit is contained in:
Gregory Schier
2025-01-11 11:36:00 -08:00
parent 88b410bf99
commit 8dff75ad4f
10 changed files with 59 additions and 41 deletions

View File

@@ -13,9 +13,6 @@ pub enum Error {
#[error("Unknown model: {0}")]
UnknownModel(String),
#[error("Workspace not configured for sync: {0}")]
WorkspaceSyncNotConfigured(String),
#[error("I/o error: {0}")]
IoError(#[from] io::Error),
@@ -24,7 +21,7 @@ pub enum Error {
#[error("Invalid sync file: {0}")]
InvalidSyncFile(String),
#[error("Watch error: {0}")]
NotifyError(#[from] notify::Error),
}

View File

@@ -111,7 +111,7 @@ pub(crate) async fn get_db_candidates<R: Runtime>(
sync_dir: &Path,
) -> Result<Vec<DbCandidate>> {
let models: HashMap<_, _> =
workspace_models(mgr, workspace_id).await.into_iter().map(|m| (m.id(), m)).collect();
workspace_models(mgr, workspace_id).await?.into_iter().map(|m| (m.id(), m)).collect();
let sync_states: HashMap<_, _> = list_sync_states_for_workspace(mgr, workspace_id, sync_dir)
.await?
.into_iter()
@@ -270,12 +270,15 @@ pub(crate) fn compute_sync_ops(
.collect()
}
async fn workspace_models<R: Runtime>(mgr: &impl Manager<R>, workspace_id: &str) -> Vec<SyncModel> {
let resources = get_workspace_export_resources(mgr, vec![workspace_id]).await.resources;
async fn workspace_models<R: Runtime>(
mgr: &impl Manager<R>,
workspace_id: &str,
) -> Result<Vec<SyncModel>> {
let resources = get_workspace_export_resources(mgr, vec![workspace_id], true).await?.resources;
let workspace = resources.workspaces.iter().find(|w| w.id == workspace_id);
let workspace = match workspace {
None => return Vec::new(),
None => return Ok(Vec::new()),
Some(w) => w,
};
@@ -294,7 +297,7 @@ async fn workspace_models<R: Runtime>(mgr: &impl Manager<R>, workspace_id: &str)
sync_models.push(SyncModel::GrpcRequest(m));
}
sync_models
Ok(sync_models)
}
pub(crate) async fn apply_sync_ops<R: Runtime>(