From 46339d620ac885bb39a2015db8175426ba068cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 7 Jul 2017 12:00:19 +0300 Subject: [PATCH] MXS-1220: Interpret no relationships as old relationships When a PATCH request to a resource is made with no relationships defined, it should be interpreted to be the same as the old relationships. Removal of relationships can still be done by defining an empty relationships object. --- include/maxscale/config.h | 1 + server/core/config_runtime.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/maxscale/config.h b/include/maxscale/config.h index f5165839d..26a12f79f 100644 --- a/include/maxscale/config.h +++ b/include/maxscale/config.h @@ -45,6 +45,7 @@ MXS_BEGIN_DECLS #define MXS_JSON_PTR_PARAMETERS "/data/attributes/parameters" /** Pointers to relation lists */ +#define MXS_JSON_PTR_RELATIONSHIPS "/data/relationships" #define MXS_JSON_PTR_RELATIONSHIPS_SERVERS "/data/relationships/servers/data" #define MXS_JSON_PTR_RELATIONSHIPS_SERVICES "/data/relationships/services/data" #define MXS_JSON_PTR_RELATIONSHIPS_MONITORS "/data/relationships/monitors/data" diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 49fa3013e..9100ec974 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -1093,6 +1093,12 @@ SERVER* runtime_create_server_from_json(json_t* json) bool server_to_object_relations(SERVER* server, json_t* old_json, json_t* new_json) { + if (mxs_json_pointer(new_json, MXS_JSON_PTR_RELATIONSHIPS) == NULL) + { + /** No change to relationships */ + return true; + } + bool rval = false; set old_relations; set new_relations; @@ -1270,6 +1276,12 @@ MXS_MONITOR* runtime_create_monitor_from_json(json_t* json) bool object_to_server_relations(const char* target, json_t* old_json, json_t* new_json) { + if (mxs_json_pointer(new_json, MXS_JSON_PTR_RELATIONSHIPS) == NULL) + { + /** No change to relationships */ + return true; + } + bool rval = false; set old_relations; set new_relations;