cnf_lib/environment/container.rs
1// SPDX-License-Identifier: GPL-3.0-or-later
2// SPDX-FileCopyrightText: (C) 2023 Andreas Hartmann <hartan@7x.de>
3// This file is part of cnf-lib, available at <https://gitlab.com/hartang/rust/cnf>
4
5//! # Container Environment Handler
6//!
7//! This runs ad-hoc containers from local container storage or a remote container registry if
8//! configured.
9//!
10//! **This is not currently implemented but planned for later on. If you have a need for this
11//! feature, please let us know!**
12
13use crate::error::CnfError;
14use std::path::Path;
15
16const CONTAINER_ENV: &str = "/run/.containerenv";
17
18/// Detect if the current environment is a container.
19pub fn detect() -> bool {
20 Path::new(CONTAINER_ENV).exists()
21}
22
23/// Run a command in a container environment.
24pub fn run(_args: &[&str]) -> Result<(), CnfError> {
25 Err(CnfError::NotImplemented("Environment Container".into()))
26}