Skip to content

Commit

Permalink
Fixes after merging
Browse files Browse the repository at this point in the history
  • Loading branch information
s373r committed Dec 19, 2024
1 parent 8eadc3c commit 2092d2e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 65 deletions.
17 changes: 10 additions & 7 deletions src/adapter/auth-oso-rebac/src/oso_resource_service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ impl OsoResourceServiceImpl {
Err(e) => return Err(e.into()),
};

let account_properties = self
.rebac_service
.get_account_properties(&account.id)
.await
.int_err()?;

UserActor::logged(&account.id, account_properties.is_admin)
// TODO: Private Datasets: absorb the `is_admin` attribute
// from the Accounts domain
// https://github.com/kamu-data/kamu-cli/issues/766
// let account_properties = self
// .rebac_service
// .get_account_properties(&account.id)
// .await
// .int_err()?;

UserActor::logged(&account.id, account.is_admin)
};

// Lastly, caching
Expand Down
27 changes: 11 additions & 16 deletions src/app/cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,16 @@ pub async fn run(workspace_layout: WorkspaceLayout, args: cli::Cli) -> Result<()
is_e2e_testing,
);

if workspace_svc.is_in_workspace() {
// TODO: Private Datasets: recheck after merge
// // NOTE: Register DatasetEntryIndexer in DI, since it is referenced by other
// // components (via InitOnStartup)
// // TODO: PERF: Do not register InitOnStartup-components if we are not inside the
// // workspace
// base_catalog_builder.add_builder(
// kamu_datasets_services::DatasetEntryIndexer::builder()
// .with_is_in_workspace(workspace_svc.is_in_workspace()),
// );
// // The indexer has no other interfaces
// base_catalog_builder
// .bind::<dyn InitOnStartup, kamu_datasets_services::DatasetEntryIndexer>();
// TODO: Use SQLite database in single-tenant
// https://github.com/kamu-data/kamu-cli/issues/981
//
// After implementing this ticket, we need to use "is_init_command"
// not "init_multi_tenant_workspace" here
let is_indexing_needed = init_multi_tenant_workspace || workspace_svc.is_in_workspace();
if is_indexing_needed {
base_catalog_builder.add::<kamu_datasets_services::DatasetEntryIndexer>();
base_catalog_builder.add::<kamu_datasets_services::DependencyGraphIndexer>();
base_catalog_builder.add::<kamu_auth_rebac_services::RebacIndexer>();
}

base_catalog_builder.add_value(JwtAuthenticationConfig::load_from_env());
Expand Down Expand Up @@ -485,14 +480,14 @@ pub fn configure_base_catalog(
b.add::<odf_server::AccessTokenRegistryService>();
b.add::<odf_server::CLIAccessTokenStore>();

kamu_auth_rebac_services::register_dependencies(&mut b, tenancy_config);

kamu_adapter_auth_oso_rebac::register_dependencies(&mut b);

b.add::<DatabaseTransactionRunner>();

b.add::<kamu_auth_rebac_services::RebacServiceImpl>();

if tenancy_config == TenancyConfig::MultiTenant {
b.add::<MultiTenantRebacDatasetLifecycleMessageConsumer>();
b.add::<kamu_auth_rebac_services::MultiTenantRebacDatasetLifecycleMessageConsumer>();
}

b.add::<kamu_datasets_services::DatasetEntryServiceImpl>();
Expand Down
26 changes: 0 additions & 26 deletions src/domain/auth-rebac/services/src/dependencies.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/domain/auth-rebac/services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
// Re-exports
pub use kamu_auth_rebac as domain;

mod dependencies;
mod jobs;
mod messages;
mod multi_tenant_rebac_dataset_lifecycle_message_consumer;
mod rebac_indexer;
mod rebac_service_impl;

pub use dependencies::*;
pub use jobs::*;
pub use messages::*;
pub use multi_tenant_rebac_dataset_lifecycle_message_consumer::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl MultiTenantRebacDatasetLifecycleMessageConsumer {
for (name, value) in [
DatasetPropertyName::allows_public_read(allows),
// TODO: Private Datasets: Read from a specific environment's config
DatasetPropertyName::allows_anonymous_read(false),
DatasetPropertyName::allows_anonymous_read(allows),
] {
self.rebac_service
.set_dataset_property(&message.dataset_id, name, &value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async fn test_rebac_properties_added() {
.get_dataset_properties(&public_dataset_id)
.await,
Ok(DatasetProperties {
allows_anonymous_read: false,
allows_anonymous_read: true,
allows_public_read: true
})
);
Expand Down Expand Up @@ -129,7 +129,7 @@ async fn test_rebac_properties_deleted() {
.get_dataset_properties(&dataset_id)
.await,
Ok(DatasetProperties {
allows_anonymous_read: false,
allows_anonymous_read: true,
allows_public_read: true
})
);
Expand Down
9 changes: 0 additions & 9 deletions src/domain/datasets/services/src/dataset_entry_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub struct DatasetEntryIndexer {
time_source: Arc<dyn SystemTimeSource>,
dataset_repo: Arc<dyn DatasetRepository>,
account_repository: Arc<dyn AccountRepository>,
is_in_workspace: bool,
}

#[component(pub)]
Expand All @@ -54,14 +53,12 @@ impl DatasetEntryIndexer {
time_source: Arc<dyn SystemTimeSource>,
dataset_repo: Arc<dyn DatasetRepository>,
account_repository: Arc<dyn AccountRepository>,
is_in_workspace: bool,
) -> Self {
Self {
dataset_entry_repo,
time_source,
dataset_repo,
account_repository,
is_in_workspace,
}
}

Expand Down Expand Up @@ -178,12 +175,6 @@ impl InitOnStartup for DatasetEntryIndexer {
name = "DatasetEntryIndexer::run_initialization"
)]
async fn run_initialization(&self) -> Result<(), InternalError> {
if !self.is_in_workspace {
tracing::debug!("Skip initialization: not in a workspace");

return Ok(());
}

if self.has_datasets_indexed().await? {
tracing::debug!("Skip initialization: datasets already have indexed");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl DatasetEntryServiceHarness {
let mut b = CatalogBuilder::new();

b.add::<DatasetEntryServiceImpl>();
b.add_builder(DatasetEntryIndexer::builder().with_is_in_workspace(true));
b.add::<DatasetEntryIndexer>();

b.add_value(mock_dataset_entry_repository);
b.bind::<dyn DatasetEntryRepository, MockDatasetEntryRepository>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub async fn test_init_exist_ok_mt(mut kamu: KamuCliPuppet) {
.unwrap();

// Verify that the database has not been overwritten
pretty_assertions::assert_eq!(modified_new, modified_old);
pretty_assertions::assert_eq!(modified_old, modified_new);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 10 additions & 0 deletions src/infra/core/src/repos/dataset_repository_local_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ impl DatasetStorageStrategy for DatasetSingleTenantStorageStrategy {

fn get_all_datasets(&self) -> DatasetHandleStream<'_> {
Box::pin(async_stream::try_stream! {
// While creating a workspace, the directory has not yet been created
if !self.root.exists() {
return;
}

let read_dataset_dir = std::fs::read_dir(&self.root).int_err()?;

for r_dataset_dir in read_dataset_dir {
Expand Down Expand Up @@ -749,6 +754,11 @@ impl DatasetStorageStrategy for DatasetMultiTenantStorageStrategy {

fn get_all_datasets(&self) -> DatasetHandleStream<'_> {
Box::pin(async_stream::try_stream! {
// While creating a workspace, the directory has not yet been created
if !self.root.exists() {
return;
}

let read_account_dir = std::fs::read_dir(&self.root).int_err()?;

for r_account_dir in read_account_dir {
Expand Down

0 comments on commit 2092d2e

Please sign in to comment.