aboutsummaryrefslogtreecommitdiff
path: root/src/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/context.rs')
-rw-r--r--src/context.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/context.rs b/src/context.rs
index f67c302..4c1b639 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -15,6 +15,7 @@ pub struct Context {
15 job_id: Option<u32>, 15 job_id: Option<u32>,
16 infer_job_id: bool, 16 infer_job_id: bool,
17 frontend_hostname: Option<String>, 17 frontend_hostname: Option<String>,
18 cluster_username: Option<String>
18} 19}
19 20
20impl Context { 21impl Context {
@@ -22,12 +23,14 @@ impl Context {
22 job_id: Option<u32>, 23 job_id: Option<u32>,
23 infer_job_id: bool, 24 infer_job_id: bool,
24 frontend_hostname: Option<String>, 25 frontend_hostname: Option<String>,
26 cluster_username: Option<String>
25 ) -> Result<Self> { 27 ) -> Result<Self> {
26 Ok(Self { 28 Ok(Self {
27 node: get_execution_node().await?, 29 node: get_execution_node().await?,
28 job_id, 30 job_id,
29 infer_job_id, 31 infer_job_id,
30 frontend_hostname, 32 frontend_hostname,
33 cluster_username
31 }) 34 })
32 } 35 }
33 36
@@ -57,6 +60,12 @@ impl Context {
57 .as_deref() 60 .as_deref()
58 .ok_or_else(|| eyre::eyre!("missing frontend hostname")) 61 .ok_or_else(|| eyre::eyre!("missing frontend hostname"))
59 } 62 }
63
64 pub fn cluster_username(&self) -> Result<&str> {
65 self.cluster_username
66 .as_deref()
67 .ok_or_else(|| eyre::eyre!("missing cluster username"))
68 }
60} 69}
61 70
62async fn get_execution_node() -> Result<ExecutionNode> { 71async fn get_execution_node() -> Result<ExecutionNode> {