Add basic parsing logic
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 10 May 2021 08:31:06 +0000 (17:31 +0900)
committer연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Wed, 12 May 2021 07:12:49 +0000 (16:12 +0900)
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/rpk/step/configuration/step_parse_rpk_manifest.cc
src/rpk/step/configuration/step_parse_rpk_manifest.h

index de24fad..b4eecb9 100644 (file)
@@ -37,6 +37,29 @@ common_installer::Step::Status StepParseRpkManifest::precheck() {
 }
 
 common_installer::Step::Status StepParseRpkManifest::process() {
+  if (context_->force_clean_from_db.get())
+    return Step::Status::OK;
+  if (!LocateConfigFile()) {
+    // continue if this is recovery, manifest file may never been created
+    if (manifest_location_ == ManifestLocation::RECOVERY) {
+      LOG(DEBUG) << "Manifest for recovery not found";
+      return Step::Status::OK;
+    }
+    LOG(ERROR) << "No manifest file exists";
+    return Step::Status::MANIFEST_NOT_FOUND;
+  }
+
+  parser_.reset(new rpk::parse::RPKConfigParser());
+  if (!parser_->ParseManifest(path_)) {
+    if (manifest_location_ == ManifestLocation::RECOVERY) {
+      LOG(DEBUG) << "Manifest for recovery is invalid";
+      bf::remove(path_);
+      return Step::Status::OK;
+    }
+    LOG(ERROR) << "[Parse] Parse failed. " <<  parser_->GetErrorMessage();
+    return Step::Status::PARSE_ERROR;
+  }
+
   return common_installer::Step::Status::OK;
 }
 
index 1f70cfe..2b0824c 100644 (file)
@@ -47,7 +47,7 @@ class StepParseRpkManifest : public common_installer::Step {
   Status precheck() override;
 
  private:
-
+  std::unique_ptr<rpk::parse::RPKConfigParser> parser_;
   ManifestLocation manifest_location_;
   StoreLocation store_location_;