-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmod.rs
More file actions
64 lines (55 loc) · 1.62 KB
/
Copy pathmod.rs
File metadata and controls
64 lines (55 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use snafu::{ResultExt, Snafu};
use stackable_operator::{
builder::pod::volume::SecretFormat, client::Client, k8s_openapi::api::core::v1::Volume,
shared::time::Duration,
};
use crate::crd::v1alpha1;
pub mod authentication;
pub mod authorization;
pub mod oidc;
pub mod sensitive_key;
pub mod tls;
type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("tls failure"))]
Tls { source: tls::Error },
#[snafu(display("sensitive key failure"))]
SensitiveKey { source: sensitive_key::Error },
#[snafu(display("failed to ensure OIDC admin password exists"))]
OidcAdminPassword { source: oidc::Error },
}
pub async fn check_or_generate_sensitive_key(
client: &Client,
nifi: &v1alpha1::NifiCluster,
) -> Result<bool> {
sensitive_key::check_or_generate_sensitive_key(client, nifi)
.await
.context(SensitiveKeySnafu)
}
pub async fn check_or_generate_oidc_admin_password(
client: &Client,
nifi: &v1alpha1::NifiCluster,
) -> Result<bool> {
oidc::check_or_generate_oidc_admin_password(client, nifi)
.await
.context(OidcAdminPasswordSnafu)
}
pub fn build_tls_volume(
nifi: &v1alpha1::NifiCluster,
volume_name: &str,
service_scopes: impl IntoIterator<Item = impl AsRef<str>>,
secret_format: SecretFormat,
requested_secret_lifetime: &Duration,
listener_scope: Option<&str>,
) -> Result<Volume> {
tls::build_tls_volume(
nifi,
volume_name,
service_scopes,
secret_format,
requested_secret_lifetime,
listener_scope,
)
.context(TlsSnafu)
}