Skip to content

Commit 2be550f

Browse files
committed
Tidy some details in environment module
Signed-off-by: Richard Lupton <richard.lupton@gmail.com>
1 parent f3f7ea1 commit 2be550f

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ version number is tracked in the file `VERSION`.
88

99
## Unreleased
1010
### Changed
11+
- Small tidyups of environment collection module - PATCH
1112
### Added
1213
- Forward host working directory as `FLOKI_HOST_WORKDIR` - MINOR
1314

src/environment.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct Environment {
1313

1414

1515
impl Environment {
16+
/// Gather information on the environment floki is running in
1617
pub fn gather() -> Result<Self, Error> {
1718
Ok(Environment{
1819
user_details: get_user_details()?,
@@ -23,12 +24,14 @@ impl Environment {
2324
}
2425

2526

27+
/// Run a command and extract stdout as a String
2628
fn run_and_get_raw_output(cmd: &mut Command) -> Result<String, Error> {
2729
let output = String::from_utf8(cmd.output()?.stdout)?;
2830
Ok(output.trim_end().into())
2931
}
3032

31-
pub fn get_user_details() -> Result<(String, String), Error> {
33+
/// Get the user and group ids of the current user
34+
fn get_user_details() -> Result<(String, String), Error> {
3235
let user = run_and_get_raw_output(Command::new("id").arg("-u"))?;
3336
debug!("User's current id: {:?}", user);
3437
let group = run_and_get_raw_output(Command::new("id").arg("-g"))?;
@@ -38,7 +41,7 @@ pub fn get_user_details() -> Result<(String, String), Error> {
3841

3942
/// Get the current working directory as a String
4043
fn get_current_working_directory() -> Result<String, Error> {
41-
Ok(format!("{}", env::current_dir()?.display()))
44+
Ok(env::current_dir()?.display().to_string())
4245
}
4346

4447

0 commit comments

Comments
 (0)