subspace_core/diagnostics/
issue_paths.rs1use super::{LaunchKind, RedactionContext, RuntimeDetails};
2
3#[derive(Debug, Clone)]
6pub struct IssuePaths {
7 executable: String,
8 launch: LaunchKind,
9 path_source: String,
10 az_path: String,
11 config_path: Option<String>,
12}
13
14impl IssuePaths {
15 pub(super) fn project(
16 runtime: Option<&RuntimeDetails>,
17 redaction: &RedactionContext,
18 config_path: Option<&str>,
19 ) -> Self {
20 Self {
21 executable: redaction.path_field(
22 runtime
23 .map(|runtime| runtime.executable.as_str())
24 .unwrap_or("unavailable"),
25 ),
26 launch: runtime
27 .map(|runtime| runtime.launch)
28 .unwrap_or(LaunchKind::Unknown),
29 path_source: redaction.source(
30 runtime
31 .map(|runtime| runtime.path_source.as_str())
32 .unwrap_or("unavailable"),
33 ),
34 az_path: runtime
35 .and_then(|runtime| runtime.az_path.as_deref())
36 .map(|path| redaction.path_field(path))
37 .unwrap_or_else(|| "not found on the app's PATH".into()),
38 config_path: config_path.map(|path| redaction.path_field(path)),
39 }
40 }
41
42 pub fn fields(&self) -> impl Iterator<Item = (&'static str, &str)> {
44 [
45 ("Executable", self.executable.as_str()),
46 ("Launch", self.launch.label()),
47 ("PATH source", self.path_source.as_str()),
48 ("Azure CLI", self.az_path.as_str()),
49 ]
50 .into_iter()
51 .chain(
52 self.config_path
53 .as_deref()
54 .map(|path| ("Configuration file", path)),
55 )
56 }
57}