refactor: give modules descriptive names
This commit is contained in:
1 parent
4315f50745
commit
832db62f67
25 files changed
+95
-95
No files matched your search
+2
-2
@@ -1,8 +1,8 @@
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use bootvine::{
|
||||
model::Phase,
|
||||
script::{Scenario, Step, failing, play, step},
|
||||
boot_model::Phase,
|
||||
scripted_boot::{Scenario, Step, failing, play, step},
|
||||
};
|
||||
|
||||
const INITRD: &[Step] = &[
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use bootvine::{
|
||||
model::Phase,
|
||||
script::{Scenario, Step, play, step, unlocking},
|
||||
boot_model::Phase,
|
||||
scripted_boot::{Scenario, Step, play, step, unlocking},
|
||||
};
|
||||
|
||||
const ROOT_PARTITION: &str =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use bootvine::{
|
||||
model::Phase,
|
||||
script::{Scenario, Step, play, step, stopping},
|
||||
boot_model::Phase,
|
||||
scripted_boot::{Scenario, Step, play, step, stopping},
|
||||
};
|
||||
|
||||
const SHUTDOWN: &[Step] = &[
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bootvine::{passphrase, view::PasswordPrompt};
|
||||
use bootvine::{boot_view::PasswordPrompt, passphrase_input};
|
||||
use crossterm::event::Event;
|
||||
use rustix::{
|
||||
fs::inotify::{self, CreateFlags, WatchFlags},
|
||||
@@ -17,7 +17,7 @@ use rustix::{
|
||||
};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use crate::clock::monotonic_now;
|
||||
use crate::monotonic_clock::monotonic_now;
|
||||
|
||||
const REQUESTS: &str = "/run/systemd/ask-password";
|
||||
const REQUEST_PREFIX: &str = "ask.";
|
||||
@@ -186,7 +186,7 @@ impl PasswordEntry {
|
||||
}
|
||||
Some(Self {
|
||||
request,
|
||||
typed: passphrase::empty(),
|
||||
typed: passphrase_input::empty(),
|
||||
sent: false,
|
||||
})
|
||||
}
|
||||
@@ -201,7 +201,7 @@ impl PasswordEntry {
|
||||
} else if self.request.echo {
|
||||
self.typed.to_string()
|
||||
} else {
|
||||
passphrase::masked(&self.typed)
|
||||
passphrase_input::masked(&self.typed)
|
||||
};
|
||||
PasswordPrompt {
|
||||
message: &self.request.message,
|
||||
@@ -214,7 +214,7 @@ impl PasswordEntry {
|
||||
if self.sent {
|
||||
return Ok(());
|
||||
}
|
||||
let Some(submitted) = passphrase::type_key(&mut self.typed, event) else {
|
||||
let Some(submitted) = passphrase_input::type_key(&mut self.typed, event) else {
|
||||
return Ok(());
|
||||
};
|
||||
self.request.answer(&submitted)?;
|
||||
@@ -271,7 +271,7 @@ mod tests {
|
||||
fn hides_what_is_typed() {
|
||||
let mut entry = PasswordEntry {
|
||||
request: PasswordRequest::parse(Path::new("ask.x"), CRYPTSETUP_ASK).expect("parsed"),
|
||||
typed: passphrase::empty(),
|
||||
typed: passphrase_input::empty(),
|
||||
sent: false,
|
||||
};
|
||||
"secret".chars().for_each(|character| {
|
||||
@@ -7,16 +7,16 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use bootvine::model::{
|
||||
use bootvine::boot_model::{
|
||||
BootState, HANDOFF_UNIT, HOST_MILESTONES, JobKind, Phase, SHUTDOWN_MILESTONES,
|
||||
};
|
||||
use dbus::Path;
|
||||
|
||||
use crate::{
|
||||
clock::monotonic_now,
|
||||
error::Error,
|
||||
sysroot::{INITRD_RELEASE, Sysroot},
|
||||
systemd::{Scope, Session, Signal},
|
||||
monotonic_clock::monotonic_now,
|
||||
switch_root::{INITRD_RELEASE, Sysroot},
|
||||
systemd_bus::{Scope, Session, Signal},
|
||||
watch_error::Error,
|
||||
};
|
||||
|
||||
const RECONNECT_PATIENCE: Duration = Duration::from_secs(60);
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
||||
mod chrome;
|
||||
mod stages;
|
||||
mod timeline;
|
||||
mod tree;
|
||||
mod run_timeline;
|
||||
mod screen_chrome;
|
||||
mod stage_summary;
|
||||
mod unit_tree;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -16,25 +16,25 @@ use ratatui::{
|
||||
use unicode_truncate::UnicodeTruncateStr;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
pub use self::chrome::PasswordPrompt;
|
||||
pub use self::screen_chrome::PasswordPrompt;
|
||||
use self::{
|
||||
chrome::{FOOTER_HEIGHT, Footer, Header, PasswordPopup},
|
||||
stages::Stages,
|
||||
timeline::{RunningRun, Timeline},
|
||||
tree::UnitTree,
|
||||
run_timeline::{RunningRun, Timeline},
|
||||
screen_chrome::{FOOTER_HEIGHT, Footer, Header, PasswordPopup},
|
||||
stage_summary::Stages,
|
||||
unit_tree::UnitTree,
|
||||
};
|
||||
use crate::{
|
||||
colors::Colors,
|
||||
config::Timing,
|
||||
glyphs::Glyphs,
|
||||
model::{BootState, RowStatus, TreeRow, UnitKind, fit_to_height, fold_chains},
|
||||
origin::BootOrigin,
|
||||
boot_model::{BootState, RowStatus, TreeRow, UnitKind, fit_to_height, fold_chains},
|
||||
boot_origin::BootOrigin,
|
||||
color_scheme::Colors,
|
||||
config_file::Timing,
|
||||
font_glyphs::Glyphs,
|
||||
};
|
||||
|
||||
const DURATION_WIDTH: u16 = 8;
|
||||
const MIN_BAR_WIDTH: u16 = 12;
|
||||
const MIN_HEIGHT_FOR_TIMELINE: u16 = 12;
|
||||
const MIN_TIMELINE_HEIGHT: u16 = timeline::CHROME_HEIGHT + 4;
|
||||
const MIN_TIMELINE_HEIGHT: u16 = run_timeline::CHROME_HEIGHT + 4;
|
||||
const HEADER_HEIGHT: u16 = 1;
|
||||
const BRANCH: &str = "├─ ";
|
||||
const LAST_BRANCH: &str = "└─ ";
|
||||
@@ -123,7 +123,7 @@ impl Widget for BootView<'_> {
|
||||
colors: &self.colors.footer,
|
||||
glyphs: self.glyphs,
|
||||
};
|
||||
let fits_timeline = area.width >= timeline::LABEL_WIDTH + 1 + MIN_BAR_WIDTH
|
||||
let fits_timeline = area.width >= run_timeline::LABEL_WIDTH + 1 + MIN_BAR_WIDTH
|
||||
&& area.height >= MIN_HEIGHT_FOR_TIMELINE;
|
||||
let free = area
|
||||
.height
|
||||
@@ -236,7 +236,7 @@ mod tests {
|
||||
use ratatui::{Terminal, backend::TestBackend};
|
||||
|
||||
use super::*;
|
||||
use crate::model::{ActiveState, Activity, JobKind, JobResult, Phase, UnitFacts};
|
||||
use crate::boot_model::{ActiveState, Activity, JobKind, JobResult, Phase, UnitFacts};
|
||||
|
||||
const MS: Duration = Duration::from_millis(1);
|
||||
|
||||
@@ -15,9 +15,9 @@ use ratatui::{
|
||||
|
||||
use super::{fit_width, rule, unit_count};
|
||||
use crate::{
|
||||
colors::TimelineColors,
|
||||
glyphs::Glyphs,
|
||||
model::{FinishedRun, MilestoneRow},
|
||||
boot_model::{FinishedRun, MilestoneRow},
|
||||
color_scheme::TimelineColors,
|
||||
font_glyphs::Glyphs,
|
||||
};
|
||||
|
||||
pub const LABEL_WIDTH: u16 = 28;
|
||||
@@ -10,10 +10,10 @@ use ratatui::{
|
||||
|
||||
use super::{DURATION_WIDTH, ELAPSED};
|
||||
use crate::{
|
||||
colors::{FooterColors, HeaderColors, PasswordColors},
|
||||
glyphs::Glyphs,
|
||||
model::Tally,
|
||||
origin::BootOrigin,
|
||||
boot_model::Tally,
|
||||
boot_origin::BootOrigin,
|
||||
color_scheme::{FooterColors, HeaderColors, PasswordColors},
|
||||
font_glyphs::Glyphs,
|
||||
};
|
||||
|
||||
pub const FOOTER_HEIGHT: u16 = 2;
|
||||
@@ -9,7 +9,7 @@ use ratatui::{
|
||||
};
|
||||
|
||||
use super::{BRANCH, ELAPSED, LAST_BRANCH, unit_count};
|
||||
use crate::{colors::StageColors, glyphs::Glyphs, model::BootState};
|
||||
use crate::{boot_model::BootState, color_scheme::StageColors, font_glyphs::Glyphs};
|
||||
|
||||
const SHUTDOWN_SUCCESSOR: &str = "systemd-shutdown";
|
||||
const PHASE_WIDTH: usize = 9;
|
||||
@@ -11,9 +11,9 @@ use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width};
|
||||
use crate::{
|
||||
colors::TreeColors,
|
||||
glyphs::Glyphs,
|
||||
model::{RowStatus, TreeRow, UnitKind},
|
||||
boot_model::{RowStatus, TreeRow, UnitKind},
|
||||
color_scheme::TreeColors,
|
||||
font_glyphs::Glyphs,
|
||||
};
|
||||
|
||||
const SPINNER: [char; 4] = ['|', '/', '-', '\\'];
|
||||
File renamed without changes.
@@ -5,7 +5,7 @@ use jiff::fmt::serde::unsigned_duration::friendly::compact::required as friendly
|
||||
use serde::{Deserialize, Serialize};
|
||||
use toml::{Table, Value, de::Error as ParseError, ser::Error as SerializeError};
|
||||
|
||||
use crate::colors::Colors;
|
||||
use crate::color_scheme::Colors;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{collections::HashSet, fs, ptr};
|
||||
|
||||
use bootvine::glyphs::Glyphs;
|
||||
use bootvine::font_glyphs::Glyphs;
|
||||
use rustix::{
|
||||
io::Errno,
|
||||
ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl},
|
||||
@@ -8,7 +8,7 @@ use rustix::{
|
||||
termios::ttyname,
|
||||
};
|
||||
|
||||
use crate::password;
|
||||
use crate::ask_password;
|
||||
|
||||
const GIO_UNIMAP: Opcode = 0x4B66;
|
||||
const VT_GETSTATE: Opcode = 0x5603;
|
||||
@@ -26,7 +26,7 @@ pub struct Console {
|
||||
|
||||
impl Console {
|
||||
pub fn take(for_system: bool) -> Self {
|
||||
let prompt_elsewhere = for_system && password::requested();
|
||||
let prompt_elsewhere = for_system && ask_password::requested();
|
||||
if prompt_elsewhere {
|
||||
eprintln!("bootvine: a password prompt is already showing, staying behind it");
|
||||
}
|
||||
@@ -48,7 +48,7 @@ impl Console {
|
||||
}
|
||||
|
||||
pub fn come_forward_once_prompts_are_gone(&mut self) -> bool {
|
||||
if !self.for_system || self.foreground.is_some() || password::requested() {
|
||||
if !self.for_system || self.foreground.is_some() || ask_password::requested() {
|
||||
return false;
|
||||
}
|
||||
self.foreground = ForegroundVt::take();
|
||||
@@ -194,7 +194,7 @@ impl ForegroundVt {
|
||||
|
||||
impl Drop for ForegroundVt {
|
||||
fn drop(&mut self) {
|
||||
if password::requested() {
|
||||
if ask_password::requested() {
|
||||
eprintln!("bootvine: leaving a password prompt to the console agent on this terminal");
|
||||
return;
|
||||
}
|
||||
File renamed without changes.
+8
-8
@@ -1,8 +1,8 @@
|
||||
pub mod colors;
|
||||
pub mod config;
|
||||
pub mod glyphs;
|
||||
pub mod model;
|
||||
pub mod origin;
|
||||
pub mod passphrase;
|
||||
pub mod script;
|
||||
pub mod view;
|
||||
pub mod boot_model;
|
||||
pub mod boot_origin;
|
||||
pub mod boot_view;
|
||||
pub mod color_scheme;
|
||||
pub mod config_file;
|
||||
pub mod font_glyphs;
|
||||
pub mod passphrase_input;
|
||||
pub mod scripted_boot;
|
||||
+12
-12
@@ -1,11 +1,11 @@
|
||||
mod clock;
|
||||
mod console;
|
||||
mod error;
|
||||
mod feed;
|
||||
mod password;
|
||||
mod run;
|
||||
mod sysroot;
|
||||
mod systemd;
|
||||
mod ask_password;
|
||||
mod boot_feed;
|
||||
mod console_takeover;
|
||||
mod monotonic_clock;
|
||||
mod switch_root;
|
||||
mod systemd_bus;
|
||||
mod watch_error;
|
||||
mod watch_loop;
|
||||
|
||||
use std::{
|
||||
error::Error,
|
||||
@@ -15,14 +15,14 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bootvine::config::{Config, ConfigError, Timing, default_config_table, read_config_file};
|
||||
use bootvine::config_file::{Config, ConfigError, Timing, default_config_table, read_config_file};
|
||||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
use jiff::fmt::friendly::SpanParser;
|
||||
|
||||
use crate::{
|
||||
feed::RootRequest,
|
||||
run::{Settings, run},
|
||||
systemd::Scope,
|
||||
boot_feed::RootRequest,
|
||||
systemd_bus::Scope,
|
||||
watch_loop::{Settings, run},
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -10,13 +10,13 @@ use ratatui::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
colors::Colors,
|
||||
config::Timing,
|
||||
glyphs::Glyphs,
|
||||
model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts},
|
||||
origin::BootOrigin,
|
||||
passphrase,
|
||||
view::{BootView, PasswordPrompt},
|
||||
boot_model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts},
|
||||
boot_origin::BootOrigin,
|
||||
boot_view::{BootView, PasswordPrompt},
|
||||
color_scheme::Colors,
|
||||
config_file::Timing,
|
||||
font_glyphs::Glyphs,
|
||||
passphrase_input,
|
||||
};
|
||||
|
||||
const FRAME_INTERVAL: Duration = Duration::from_millis(100);
|
||||
@@ -209,7 +209,7 @@ impl Script {
|
||||
fn prompt(&self, typed: &str, now: Duration) -> Option<PasswordPrompt<'static>> {
|
||||
Some(PasswordPrompt {
|
||||
message: self.asking()?.asks?,
|
||||
input: passphrase::masked(typed),
|
||||
input: passphrase_input::masked(typed),
|
||||
sent: self.is_checking(now),
|
||||
})
|
||||
}
|
||||
@@ -311,7 +311,7 @@ pub fn play(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<(
|
||||
let mut switched_root = scenario.after_switch_root.is_empty();
|
||||
let mut settled_at = None;
|
||||
let mut frame = 0;
|
||||
let mut typed = passphrase::empty();
|
||||
let mut typed = passphrase_input::empty();
|
||||
loop {
|
||||
script.advance(&mut state, now());
|
||||
if script.is_done() && !switched_root {
|
||||
@@ -351,7 +351,7 @@ pub fn play(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<(
|
||||
}
|
||||
if asking
|
||||
&& !script.is_checking(now())
|
||||
&& let Some(submitted) = passphrase::type_key(&mut typed, &event)
|
||||
&& let Some(submitted) = passphrase_input::type_key(&mut typed, &event)
|
||||
{
|
||||
script.answer(&submitted, now());
|
||||
}
|
||||
File renamed without changes.
@@ -4,14 +4,14 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bootvine::model::{ActiveState, Activity, JobKind, JobResult, UnitFacts};
|
||||
use bootvine::boot_model::{ActiveState, Activity, JobKind, JobResult, UnitFacts};
|
||||
use dbus::{
|
||||
Message, MessageType, Path,
|
||||
arg::{AppendAll, PropMap, RefArg, Variant},
|
||||
channel::{BusType, Channel},
|
||||
};
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::watch_error::Error;
|
||||
|
||||
const DESTINATION: &str = "org.freedesktop.systemd1";
|
||||
const MANAGER_PATH: &str = "/org/freedesktop/systemd1";
|
||||
File renamed without changes.
@@ -11,11 +11,11 @@ use std::{
|
||||
};
|
||||
|
||||
use bootvine::{
|
||||
colors::Colors,
|
||||
config::Timing,
|
||||
model::{BootState, Phase},
|
||||
origin::BootOrigin,
|
||||
view::BootView,
|
||||
boot_model::{BootState, Phase},
|
||||
boot_origin::BootOrigin,
|
||||
boot_view::BootView,
|
||||
color_scheme::Colors,
|
||||
config_file::Timing,
|
||||
};
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
|
||||
use ratatui::{
|
||||
@@ -33,13 +33,13 @@ use rustix::{
|
||||
use signal_hook::{consts::SIGTERM, flag};
|
||||
|
||||
use crate::{
|
||||
clock::monotonic_now,
|
||||
console::Console,
|
||||
error::Error,
|
||||
feed::{Feed, RootRequest},
|
||||
password::{PasswordEntry, RequestWatch},
|
||||
sysroot::INITRD_RELEASE,
|
||||
systemd::{Scope, Session},
|
||||
ask_password::{PasswordEntry, RequestWatch},
|
||||
boot_feed::{Feed, RootRequest},
|
||||
console_takeover::Console,
|
||||
monotonic_clock::monotonic_now,
|
||||
switch_root::INITRD_RELEASE,
|
||||
systemd_bus::{Scope, Session},
|
||||
watch_error::Error,
|
||||
};
|
||||
|
||||
const FRAME_INTERVAL: Duration = Duration::from_millis(100);
|
||||
Reference in new issue
Block a user