Skip to content

Commit 726c14a

Browse files
committed
install: Use a method to get the stateroot
Use a method to get the stateroot instead of repeating the defaulting logic
1 parent 1fd6c69 commit 726c14a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/src/install.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@ impl State {
355355
}
356356
Ok(())
357357
}
358+
359+
fn stateroot(&self) -> &str {
360+
self.config_opts
361+
.stateroot
362+
.as_deref()
363+
.unwrap_or(ostree_ext::container::deploy::STATEROOT_DEFAULT)
364+
}
358365
}
359366

360367
/// Path to initially deployed version information
@@ -569,11 +576,7 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
569576
// Another implementation: https://github.com/coreos/coreos-assembler/blob/3cd3307904593b3a131b81567b13a4d0b6fe7c90/src/create_disk.sh#L295
570577
crate::lsm::ensure_dir_labeled(rootfs_dir, "", Some("/".into()), 0o755.into(), sepolicy)?;
571578

572-
let stateroot = state
573-
.config_opts
574-
.stateroot
575-
.as_deref()
576-
.unwrap_or(ostree_ext::container::deploy::STATEROOT_DEFAULT);
579+
let stateroot = state.stateroot();
577580

578581
Task::new_and_run(
579582
"Initializing ostree layout",
@@ -644,11 +647,7 @@ async fn install_container(
644647
) -> Result<(ostree::Deployment, InstallAleph)> {
645648
let sepolicy = state.load_policy()?;
646649
let sepolicy = sepolicy.as_ref();
647-
let stateroot = state
648-
.config_opts
649-
.stateroot
650-
.as_deref()
651-
.unwrap_or(ostree_ext::container::deploy::STATEROOT_DEFAULT);
650+
let stateroot = state.stateroot();
652651

653652
let container_rootfs = &Dir::open_ambient_dir("/", cap_std::ambient_authority())?;
654653

0 commit comments

Comments
 (0)