[][src]Function dishub::ops::init::verify

pub fn verify(
    config_dir: &(String, PathBuf),
    force: bool
) -> Result<PathBuf, Error>

Verify if, given the current configuration, it's permitted to continue with the subsequent steps of the init subsystem.

The return value contains either the path to the file containing the global app tokens or why getting it failed.

Examples

Verifying a nonexistant file or an existing file with forcing.

let tf = temp_dir().join("dishub-doctest").join("ops-init-verify-0");
assert_eq!(init::verify(&("$TEMP/ops-init-verify-0".to_string(), tf.clone()), true),
           Ok(tf.join("tokens.toml")));

Verifying an existing file without forcing.

let tf = temp_dir().join("dishub-doctest").join("ops-init-verify-1");
fs::create_dir_all(&tf).unwrap();
File::create(tf.join("tokens.toml")).unwrap().write(&[]).unwrap();

assert_eq!(init::verify(&("$TEMP/ops-init-verify-1".to_string(), tf), false),
           Err(Error::OverrideNoForce("$TEMP/ops-init-verify-1/tokens.toml".to_string())));