Skip to content

Commit

Permalink
install: Use a method to get the stateroot
Browse files Browse the repository at this point in the history
Use a method to get the stateroot instead of repeating the defaulting
logic
  • Loading branch information
omertuc committed Sep 11, 2024
1 parent 1fd6c69 commit 726c14a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ impl State {
}
Ok(())
}

fn stateroot(&self) -> &str {
self.config_opts
.stateroot
.as_deref()
.unwrap_or(ostree_ext::container::deploy::STATEROOT_DEFAULT)
}
}

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

let stateroot = state
.config_opts
.stateroot
.as_deref()
.unwrap_or(ostree_ext::container::deploy::STATEROOT_DEFAULT);
let stateroot = state.stateroot();

Task::new_and_run(
"Initializing ostree layout",
Expand Down Expand Up @@ -644,11 +647,7 @@ async fn install_container(
) -> Result<(ostree::Deployment, InstallAleph)> {
let sepolicy = state.load_policy()?;
let sepolicy = sepolicy.as_ref();
let stateroot = state
.config_opts
.stateroot
.as_deref()
.unwrap_or(ostree_ext::container::deploy::STATEROOT_DEFAULT);
let stateroot = state.stateroot();

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

Expand Down

0 comments on commit 726c14a

Please sign in to comment.