Support a persistent, private plugins directory alongside the built-in ones
plugins/ ships baked into the image and gets wiped/replaced by the checkout sync on every deploy (docs/deployment.adoc), so a private plugin dropped there — the exact use case the plugin contract was designed for — didn't survive a redeploy the way uploaded GPX/kiwix data under data/ does. Plugins.list/run now accept either one directory or an array, and app.rb checks the built-in plugins/ plus data/plugins/ (already covered by the existing ./data bind mount, no new volume needed).
This commit is contained in:
1 parent
1733fc7c1b
commit
6e0b67f2a0
5 files changed
+82
-19
No files matched your search
@@ -52,4 +52,38 @@ class PluginsTest < Minitest::Test
|
||||
File.chmod(0o755, File.join(@plugin_dir, "run.sh"))
|
||||
assert_raises(Maptool::Plugins::RunError) { Maptool::Plugins.run(@dir, "hello", [1, 2, 3, 4]) }
|
||||
end
|
||||
|
||||
# Multiple dirs (app.rb's PLUGINS_DIRS: the built-in plugins/ plus an
|
||||
# optional private one under data/plugins/) — list/run both accept an
|
||||
# array, not just the single-dir form the tests above exercise.
|
||||
|
||||
def test_list_merges_plugins_across_several_dirs
|
||||
other_dir = Dir.mktmpdir("maptool-plugins-test-2")
|
||||
other_plugin_dir = File.join(other_dir, "private")
|
||||
FileUtils.mkdir_p(other_plugin_dir)
|
||||
File.write(File.join(other_plugin_dir, "plugin.json"), JSON.generate(label: "Private", command: "./run.sh"))
|
||||
|
||||
plugins = Maptool::Plugins.list([@dir, other_dir])
|
||||
|
||||
assert_equal [{ "name" => "hello", "label" => "Hello" }, { "name" => "private", "label" => "Private" }], plugins
|
||||
ensure
|
||||
FileUtils.remove_entry(other_dir)
|
||||
end
|
||||
|
||||
def test_list_prefers_the_first_dir_when_the_same_name_exists_in_both
|
||||
other_dir = Dir.mktmpdir("maptool-plugins-test-2")
|
||||
FileUtils.mkdir_p(File.join(other_dir, "hello"))
|
||||
File.write(File.join(other_dir, "hello", "plugin.json"), JSON.generate(label: "Shadowed", command: "./run.sh"))
|
||||
|
||||
plugins = Maptool::Plugins.list([@dir, other_dir])
|
||||
|
||||
assert_equal [{ "name" => "hello", "label" => "Hello" }], plugins
|
||||
ensure
|
||||
FileUtils.remove_entry(other_dir)
|
||||
end
|
||||
|
||||
def test_run_finds_a_plugin_in_a_later_dir_when_earlier_dirs_do_not_have_it
|
||||
result = Maptool::Plugins.run([Dir.mktmpdir, @dir], "hello", [1, 2, 3, 4])
|
||||
assert_equal({ "type" => "FeatureCollection", "features" => [] }, result)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user