pub(crate) fn read_platform_env(platform_dir: impl AsRef<Path>) -> std::io::Result<Env> {
    let env_path = platform_dir.as_ref().join("env");
    let mut env_vars = Env::new();

    match fs::read_dir(env_path) {
        Ok(entries) => {
            for entry in entries {
                let entry = entry?;
                let path = entry.path();

                if let Some(file_name) = path.file_name() {
                    // k8s volume mounts will mount a directory symlink in, so we need to check
                    // that it's actually a file
                    if path.is_file() {
                        let file_contents = fs::read_to_string(&path)?;
                        env_vars.insert(file_name.to_owned(), file_contents);
                    }
                }
            }
        }
        Err(err) => {
            // don't fail if `<platform>/env` doesn't exist
            if err.kind() != std::io::ErrorKind::NotFound {
                return Err(err);
            }
        }
    }

    Ok(env_vars)
}
/// Initializes a new `Env` based on the given platform directory.
Initializes a new `Env` based on the given platform directory.
Initializes a new ` Env ` based on the given platform directory .
pub(crate) fn read_platform_env(platform_dir: impl AsRef<Path>) -> std::io::Result<Env> {
    let env_path = platform_dir.as_ref().join("env");
    let mut env_vars = Env::new();
    match fs::read_dir(env_path) {
        Ok(entries) => {
            for entry in entries {
                let entry = entry?;
                let path = entry.path();
                if let Some(file_name) = path.file_name() {
                    // k8s volume mounts will mount a directory symlink in, so we need to check
                    // that it's actually a file
                    if path.is_file() {
                        let file_contents = fs::read_to_string(&path)?;
                        env_vars.insert(file_name.to_owned(), file_contents);
                    }
                }
            }
        }
        Err(err) => {
            // don't fail if `<platform>/env` doesn't exist
            if err.kind() != std::io::ErrorKind::NotFound {
                return Err(err);
            }
        }
    }
    Ok(env_vars)
}
pub ( crate ) fn read_platform_env ( platform_dir : impl AsRef < Path > ) -> std :: io :: Result < Env > { let env_path = platform_dir . as_ref ( ) . join ( " " ) ; let mut env_vars = Env :: new ( ) ; match fs :: read_dir ( env_path ) { Ok ( entries ) => { for entry in entries { let entry = entry ? ; let path = entry . path ( ) ; if let Some ( file_name ) = path . file_name ( ) { // k8s volume mounts will mount a directory symlink in, so we need to check // that it's actually a file if path . is_file ( ) { let file_contents = fs :: read_to_string ( & path ) ? ; env_vars . insert ( file_name . to_owned ( ) , file_contents ) ; } } } } Err ( err ) => { // don't fail if `<platform>/env` doesn't exist if err . kind ( ) != std :: io :: ErrorKind :: NotFound { return Err ( err ) ; } } } Ok ( env_vars ) }
Initializes a new `Env` based on the given platform directory.
Initializes a new ` Env ` based on the given platform directory .
platform_dir
impl AsRef<Path>
platform_dir
impl AsRef<Path>