Skip to content

Commit 24cb9c8

Browse files
committed
Make the platform builder flags part of the cli.
1 parent 9d56965 commit 24cb9c8

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

pmrctrl/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pmrac = { workspace = true }
1515
pmrcore = { workspace = true }
1616
pmrdb = { workspace = true }
1717
pmrmodel = { workspace = true }
18+
pmrrbac = { workspace = true }
1819
pmrrepo = { workspace = true }
1920
pmrtqs = { workspace = true }
2021
serde = { workspace = true, features = ["serde_derive"] }

pmrctrl/src/platform/builder.rs

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@ use std::{
22
error::Error,
33
fs,
44
};
5-
use clap::Parser;
5+
use clap::{ArgAction, Parser};
66
use pmrac::platform::Builder as ACPlatformBuilder;
77
use pmrdb::{
88
Backend,
99
ConnectorOption,
1010
};
11+
use pmrrbac::Builder as PmrRbacBuilder;
1112

1213
use super::Platform;
1314

1415
#[derive(Clone, Debug, Default, Parser)]
1516
pub struct Builder {
17+
#[clap(
18+
long,
19+
value_name = "PMR_ANONYMOUS_READER",
20+
env = "PMR_ANONYMOUS_READER",
21+
action = ArgAction::Set,
22+
default_value_t = true,
23+
default_missing_value = "true",
24+
)]
25+
pub pmr_anonymous_reader: bool,
26+
#[clap(
27+
long,
28+
value_name = "PMR_AUTO_CREATE_DB",
29+
env = "PMR_AUTO_CREATE_DB",
30+
action = ArgAction::Set,
31+
default_value_t = true,
32+
default_missing_value = "true",
33+
)]
34+
pub pmr_auto_create_db: bool,
1635
#[clap(long, value_name = "PMR_DATA_ROOT", env = "PMR_DATA_ROOT")]
1736
pub pmr_data_root: String,
1837
#[clap(long, value_name = "PMR_REPO_ROOT", env = "PMR_REPO_ROOT")]
@@ -30,6 +49,16 @@ impl Builder {
3049
Self::default()
3150
}
3251

52+
pub fn pmr_anonymous_reader(mut self, value: bool) -> Self {
53+
self.pmr_anonymous_reader = value;
54+
self
55+
}
56+
57+
pub fn pmr_auto_create_db(mut self, value: bool) -> Self {
58+
self.pmr_auto_create_db = value;
59+
self
60+
}
61+
3362
pub fn pmr_data_root(mut self, value: String) -> Self {
3463
self.pmr_data_root = value;
3564
self
@@ -61,20 +90,24 @@ impl Builder {
6190
.boxed_ac_platform(
6291
Backend::ac(
6392
ConnectorOption::from(&self.pmrac_db_url)
64-
.auto_create_db(true)
93+
.auto_create_db(self.pmr_auto_create_db)
6594
)
6695
.await?
6796
)
97+
.pmrrbac_builder(
98+
PmrRbacBuilder::new()
99+
.anonymous_reader(self.pmr_anonymous_reader)
100+
)
68101
.build(),
69102
Backend::mc(
70103
ConnectorOption::from(&self.pmrapp_db_url)
71-
.auto_create_db(true)
104+
.auto_create_db(self.pmr_auto_create_db)
72105
)
73106
.await?
74107
.into(),
75108
Backend::tm(
76109
ConnectorOption::from(&self.pmrtqs_db_url)
77-
.auto_create_db(true)
110+
.auto_create_db(self.pmr_auto_create_db)
78111
)
79112
.await?
80113
.into(),

0 commit comments

Comments
 (0)