use std::path::PathBuf;
use anyhow::Result;
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;
use liboci_cli::Create;
use crate::workload::executor::default_executor;
pub fn create(args: Create, root_path: PathBuf, systemd_cgroup: bool) -> Result<()> {
ContainerBuilder::new(args.container_id.clone(), SyscallType::default())
.with_executor(default_executor())
.with_pid_file(args.pid_file.as_ref())?
.with_console_socket(args.console_socket.as_ref())
.with_root_path(root_path)?
.with_preserved_fds(args.preserve_fds)
.validate_id()?
.as_init(&args.bundle)
.with_systemd(systemd_cgroup)
.with_detach(true)
.with_no_pivot(args.no_pivot)
.build()?;
Ok(())
}