Skip to content

Commit 31f1fea

Browse files
committed
Replace unwrap with Snafu error type
1 parent 2c05926 commit 31f1fea

File tree

1 file changed

+5
-2
lines changed
  • rust/krb5-provision-keytab/src

1 file changed

+5
-2
lines changed

rust/krb5-provision-keytab/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77

88
use serde::{Deserialize, Serialize};
9-
use snafu::{ResultExt, Snafu};
9+
use snafu::{OptionExt, ResultExt, Snafu};
1010
use stackable_secret_operator_crd_utils::SecretReference;
1111
use tokio::{io::AsyncWriteExt, process::Command};
1212

@@ -62,6 +62,9 @@ pub enum Error {
6262

6363
#[snafu(display("failed to write request"))]
6464
WriteRequest { source: std::io::Error },
65+
66+
#[snafu(display("failed to obtain stdin for child process"))]
67+
ChildStdin,
6568
}
6669

6770
/// Provisions a Kerberos Keytab based on the [`Request`].
@@ -93,7 +96,7 @@ pub async fn provision_keytab(krb5_config_path: &Path, req: &Request) -> Result<
9396
// Get a `ChildStdin` object for the spawned process and write the serialized request
9497
// for a Principal into it in order for the child process to deserialize it and
9598
// process the request
96-
let mut stdin = child.stdin.take().unwrap();
99+
let mut stdin = child.stdin.take().context(ChildStdinSnafu)?;
97100
stdin.write_all(&req_str).await.context(WriteRequestSnafu)?;
98101
stdin.flush().await.context(WriteRequestSnafu)?;
99102
drop(stdin);

0 commit comments

Comments
 (0)