Skip to content

Commit

Permalink
Merge pull request #202 from Screenly/feature/2/validate_setting_names
Browse files Browse the repository at this point in the history
Adds: intervalidation of manifests for entrypoint
  • Loading branch information
korvyashka authored Aug 12, 2024
2 parents 30d0e31 + db51c56 commit 6cdc366
Show file tree
Hide file tree
Showing 6 changed files with 319 additions and 106 deletions.
49 changes: 49 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use crate::commands::edge_app_manifest::EdgeAppManifest;
use crate::commands::edge_app_server::MOCK_DATA_FILENAME;
use crate::commands::edge_app_utils::{
transform_edge_app_path_to_manifest, transform_instance_path_to_instance_manifest,
validate_manifests_dependacies,
};
use crate::commands::instance_manifest::InstanceManifest;
use crate::commands::playlist::PlaylistCommand;
use crate::commands::{CommandError, Formatter, OutputType, PlaylistFile};
const DEFAULT_ASSET_DURATION: u32 = 15;
Expand Down Expand Up @@ -996,6 +998,53 @@ pub fn handle_cli_edge_app_command(command: &EdgeAppCommands) {
std::process::exit(1);
}
}
let instance_manifest_path = match transform_instance_path_to_instance_manifest(path) {
Ok(path) => path,
Err(e) => {
eprintln!("Failed to build instance manifest filepath: {e}.");
std::process::exit(1);
}
};

if !instance_manifest_path.exists() {
println!("Instance manifest file does not exist.");
std::process::exit(0);
}

match InstanceManifest::ensure_manifest_is_valid(&instance_manifest_path) {
Ok(()) => {
println!("Instance manifest file is valid.");
}
Err(e) => {
eprintln!("{e}");
std::process::exit(1);
}
}

let manifest = match EdgeAppManifest::new(&manifest_path) {
Ok(manifest) => manifest,
Err(e) => {
eprintln!("Failed to validate edge app manifest file: {e}.");
std::process::exit(1);
}
};
let instance_manifest = match InstanceManifest::new(&instance_manifest_path) {
Ok(manifest) => manifest,
Err(e) => {
eprintln!("Failed to validate edge app instance manifest file: {e}.");
std::process::exit(1);
}
};

match validate_manifests_dependacies(&manifest, &instance_manifest) {
Ok(()) => {
println!("Manifests dependancies are valid.");
}
Err(e) => {
eprintln!("{e}");
std::process::exit(1);
}
}
}
EdgeAppCommands::Instance(command) => match command {
EdgeAppInstanceCommands::List { path, json } => {
Expand Down
Loading

0 comments on commit 6cdc366

Please sign in to comment.