Skip to content

Commit 33d3f3a

Browse files
committed
Adding ttl to crds. Default to 10.
1 parent 5e0c32e commit 33d3f3a

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

deploy/helm/superset-operator/crds/crds.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ spec:
8989
rule_name:
9090
default: user_rules
9191
type: string
92+
ttl:
93+
default: 10
94+
format: int8
95+
type: integer
9296
required:
9397
- configMapName
9498
type: object

rust/crd/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub enum SupersetConfigOptions {
9090
StackableOpaBaseUrl,
9191
StackableOpaPackage,
9292
StackableOpaRule,
93-
OpaRolesCache,
93+
OpaRolesCacheTTL,
9494
}
9595

9696
impl SupersetConfigOptions {
@@ -144,7 +144,7 @@ impl FlaskAppConfigOptions for SupersetConfigOptions {
144144
SupersetConfigOptions::StackableOpaBaseUrl => PythonType::StringLiteral,
145145
SupersetConfigOptions::StackableOpaPackage => PythonType::StringLiteral,
146146
SupersetConfigOptions::StackableOpaRule => PythonType::StringLiteral,
147-
SupersetConfigOptions::OpaRolesCache => PythonType::Expression,
147+
SupersetConfigOptions::OpaRolesCacheTTL => PythonType::IntLiteral,
148148
}
149149
}
150150
}
@@ -264,8 +264,13 @@ pub struct SupersetOpaConfig {
264264
pub opa: OpaConfig,
265265
#[serde(default = "opa_rule_name_default")]
266266
pub rule_name: String,
267+
#[serde(default = "ttl_default_time")]
268+
pub ttl: i8,
267269
}
268270

271+
fn ttl_default_time() -> i8 {
272+
10
273+
}
269274
fn opa_rule_name_default() -> String {
270275
"user_rules".to_string()
271276
}

rust/operator-binary/src/authorization/opa.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub struct SupersetOpaConfigResolved {
77
opa_base_url: String,
88
opa_package: Option<String>,
99
rule_name: String,
10+
ttl: i8,
1011
}
1112

1213
impl SupersetOpaConfigResolved {
@@ -34,6 +35,7 @@ impl SupersetOpaConfigResolved {
3435
opa_base_url,
3536
opa_package: opa_config.opa.package.to_owned(),
3637
rule_name: opa_config.rule_name.to_owned(),
38+
ttl: opa_config.ttl.to_owned(),
3739
})
3840
}
3941

@@ -64,8 +66,8 @@ impl SupersetOpaConfigResolved {
6466
self.opa_package.clone(),
6567
),
6668
(
67-
"OPA_ROLES_CACHE".to_string(),
68-
Some("os.getenv('OPA_ROLES_CACHE', '10')".to_string()),
69+
"OPA_ROLES_CACHE_TTL".to_string(),
70+
Some(self.ttl.to_string().clone()),
6971
),
7072
])
7173
}

0 commit comments

Comments
 (0)