]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notification: Fix the filter_rules to be array vs dict in json output. 55796/head
authorkchheda3 <kchheda3@bloomberg.net>
Tue, 27 Feb 2024 20:59:15 +0000 (15:59 -0500)
committerkchheda3 <kchheda3@bloomberg.net>
Thu, 14 Mar 2024 19:46:17 +0000 (15:46 -0400)
FilterRules when processed as dict in json, emits samy key name for prefix, suffix causing failure while parsing the json notification output.
So change the type FilterRules from JsonDict to Array while dumping in json.

Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
src/rgw/rgw_pubsub.cc

index 7031c2363f0b8eea6a71b3804c3b15bd070fd000..79d9f989cc4f3f18bdf4965b6d752269b9d3412e 100644 (file)
@@ -23,20 +23,24 @@ void set_event_id(std::string& id, const std::string& hash, const utime_t& ts) {
 }
 
 void rgw_s3_key_filter::dump(Formatter *f) const {
+  if (!has_content()) {
+    return;
+  }
+  f->open_array_section("FilterRules");
   if (!prefix_rule.empty()) {
-    f->open_object_section("FilterRule");
+    f->open_object_section("");
     ::encode_json("Name", "prefix", f);
     ::encode_json("Value", prefix_rule, f);
     f->close_section();
   }
   if (!suffix_rule.empty()) {
-    f->open_object_section("FilterRule");
+    f->open_object_section("");
     ::encode_json("Name", "suffix", f);
     ::encode_json("Value", suffix_rule, f);
     f->close_section();
   }
   if (!regex_rule.empty()) {
-    f->open_object_section("FilterRule");
+    f->open_object_section("");
     ::encode_json("Name", "regex", f);
     ::encode_json("Value", regex_rule, f);
     f->close_section();
@@ -97,8 +101,12 @@ bool rgw_s3_key_filter::has_content() const {
 }
 
 void rgw_s3_key_value_filter::dump(Formatter *f) const {
+  if (!has_content()) {
+    return;
+  }
+  f->open_array_section("FilterRules");
   for (const auto& key_value : kv) {
-    f->open_object_section("FilterRule");
+    f->open_object_section("");
     ::encode_json("Name", key_value.first, f);
     ::encode_json("Value", key_value.second, f);
     f->close_section();