From 77ea64dfff1ff559b783110cdfe0cc78aa9c2630 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 3 Feb 2023 17:40:56 +0300 Subject: [PATCH] fix: pre-hotreload cartridge support `crud` module is cartridge-independent in nature, but provides cartridge roles which are the most popular way to setup the module. The roles also not use any modern cartridge features and should work with any cartridge version. But since crud.cfg was introduced [1], it was required to add some code for roles reload [2] proper support. Now cartridge.hotreload module is unconditionally required, so roles cannot be used with cartridge older than 2.4.0. This patch fixes the behavior. 1. https://github.com/tarantool/crud/commit/6da4f5684a00fe39106ac139538b06821c8c829c 2. https://github.com/tarantool/cartridge/commit/941952e004c86c5883f492a63f62d98d2b3453af Follows #244 --- CHANGELOG.md | 5 +++++ crud/common/stash.lua | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6783f58e..f9da5d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed +* Pre-hotreload `cartridge` support (older than 2.4.0) (PR #341). + ## [1.0.0] - 02-02-23 ### Added diff --git a/crud/common/stash.lua b/crud/common/stash.lua index 0fef9af3..43fa09f2 100644 --- a/crud/common/stash.lua +++ b/crud/common/stash.lua @@ -37,7 +37,11 @@ stash.name = { -- @return Returns -- function stash.setup_cartridge_reload() - local hotreload = require('cartridge.hotreload') + local hotreload_supported, hotreload = pcall(require, 'cartridge.hotreload') + if not hotreload_supported then + return + end + for _, name in pairs(stash.name) do hotreload.whitelist_globals({ name }) end