buffet: Use command schema to define "progress"
According to the GCD specification command progress is dictionary,
defined same way as parameters and results.
Mapping between "done" and "progress" dictionary is not obvious, so patch
removes updates of progress from CommandInstance::Done().
BUG=brillo:915
TEST=FEATURES=test emerge-gizmo buffet
Change-Id: If6f6d52dbc0595a8f1cf0cf949a741675c9e5f3c
Reviewed-on: https://chromium-review.googlesource.com/268352
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_dictionary.cc b/buffet/commands/command_dictionary.cc
index cbfd46b..a73d73f 100644
--- a/buffet/commands/command_dictionary.cc
+++ b/buffet/commands/command_dictionary.cc
@@ -68,6 +68,7 @@
chromeos::string_utils::Join(".", package_name, command_name);
const ObjectSchema* base_parameters_def = nullptr;
+ const ObjectSchema* base_progress_def = nullptr;
const ObjectSchema* base_results_def = nullptr;
// By default make it available to all clients.
auto visibility = CommandDefinition::Visibility::GetAll();
@@ -75,6 +76,7 @@
auto cmd = base_commands->FindCommand(full_command_name);
if (cmd) {
base_parameters_def = cmd->GetParameters();
+ base_progress_def = cmd->GetProgress();
base_results_def = cmd->GetResults();
visibility = cmd->GetVisibility();
}
@@ -105,6 +107,12 @@
if (!parameters_schema)
return false;
+ auto progress_schema = BuildObjectSchema(
+ command_def_json, commands::attributes::kCommand_Progress,
+ base_progress_def, full_command_name, error);
+ if (!progress_schema)
+ return false;
+
auto results_schema = BuildObjectSchema(
command_def_json,
commands::attributes::kCommand_Results,
@@ -127,9 +135,10 @@
}
std::unique_ptr<CommandDefinition> command_def{
- new CommandDefinition{category, std::move(parameters_schema),
- std::move(results_schema)}
- };
+ new CommandDefinition{category,
+ std::move(parameters_schema),
+ std::move(progress_schema),
+ std::move(results_schema)}};
command_def->SetVisibility(visibility);
new_defs.emplace(full_command_name, std::move(command_def));