Skip to content

Commit 7201109

Browse files
committed
YAML: Define macro to hold the supported yaml version.
The idea is to remove this from the code and make it defined by the automake scripts. Eventually the version could be read from the yaml source when added. This is needed to validate the YAML version used by plugins when registering to the JSONRPC manager to avoid ABI compatibility issues.
1 parent bc23826 commit 7201109

5 files changed

Lines changed: 9 additions & 13 deletions

File tree

build/yaml-cpp.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ fi
8282
AC_SUBST([YAMLCPP_INCLUDES])
8383
AC_SUBST([YAMLCPP_LIBS])
8484
AC_SUBST([YAMLCPP_LDFLAGS])
85+
AC_DEFINE([YAMLCPP_LIB_VERSION], ["0.7.0"], [yamlcpp library version])
8586
8687
])
8788

doc/developer-guide/api/functions/TSRPCRegister.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Description
6969

7070
.. code-block:: cpp
7171
72-
TSRPCProviderHandle info = TSRPCRegister("FooBar's Plugin!", "0.6.3");
72+
TSRPCProviderHandle info = TSRPCRegister("FooBar's Plugin!", "0.7.0");
7373
...
7474
TSRPCRegisterMethodHandler("my_join_string_handler", &func, info);
7575

doc/developer-guide/jsonrpc/jsonrpc-handler-development.en.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ RPC method registration and implementation examples
202202
#include <ts/ts.h>
203203
204204
namespace {
205-
static const std::string MY_YAML_VERSION{"0.6.3"};
205+
static const std::string MY_YAML_VERSION{"0.7.0"};
206206
}
207207
208208
void
@@ -231,7 +231,7 @@ RPC method registration and implementation examples
231231
{
232232
...
233233
// Check-in to make sure we are compliant with the YAML version in TS.
234-
TSRPCProviderHandle rpcRegistrationInfo = TSRPCRegister("My plugin's info", "0.6.3");
234+
TSRPCProviderHandle rpcRegistrationInfo = TSRPCRegister("My plugin's info", "0.7.0");
235235
if (rpcRegistrationInfo == nullptr) {
236236
TSError("[%s] RPC handler registration failed, yaml version not supported.", PLUGIN_NAME);
237237
}
@@ -250,7 +250,7 @@ RPC method registration and implementation examples
250250
#include <ts/ts.h>
251251
252252
namespace {
253-
static const std::string MY_YAML_VERSION{"0.6.3"};
253+
static const std::string MY_YAML_VERSION{"0.7.0"};
254254
}
255255
256256
int
@@ -286,7 +286,7 @@ RPC method registration and implementation examples
286286
{
287287
// ...
288288
// Check-in to make sure we are compliant with the YAML version in TS.
289-
TSRPCProviderHandle rpcRegistrationInfo = TSRPCRegister("My plugin's info", "0.6.3");
289+
TSRPCProviderHandle rpcRegistrationInfo = TSRPCRegister("My plugin's info", "0.7.0");
290290
if (rpcRegistrationInfo == nullptr) {
291291
TSError("[%s] RPC handler registration failed, yaml version not supported.", PLUGIN_NAME);
292292
}

src/traffic_server/InkAPI.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10356,13 +10356,8 @@ TSRPCRegister(const char *provider_name, const char *yaml_version)
1035610356

1035710357
// We want to make sure that plugins are using the same yaml library version as we use internally. Plugins have to cast the TSYaml
1035810358
// to the YAML::Node, in order for them to make sure the version compatibility they need to register here and make sure the
10359-
// version is ok.
10360-
10361-
// IMPORTANT: YAML library version should be available to query from here. This could
10362-
// be an issue if the user specify their own library and it's a different version
10363-
// This should be discussed, can we guarantee not changing the YAML version in minor
10364-
// releases can only change it in major versions.
10365-
if (std::string_view{yaml_version} != "0.6.3") {
10359+
// version is the same.
10360+
if (std::string_view{yaml_version} != YAMLCPP_LIB_VERSION) {
1036610361
return nullptr;
1036710362
}
1036810363

tests/gold_tests/jsonrpc/plugins/jsonrpc_plugin_handler_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace
3737
{
3838
static constexpr char PLUGIN_NAME[] = "jsonrpc_plugin_handler_test";
3939

40-
static const std::string MY_YAML_VERSION{"0.6.3"};
40+
static const std::string MY_YAML_VERSION{"0.7.0"};
4141
static const std::string RPC_PROVIDER_NAME{"RPC Plugin test"};
4242
} // namespace
4343

0 commit comments

Comments
 (0)