From: Tobias Ulmer Date: Wed, 26 Jun 2019 14:56:25 +0000 (+0200) Subject: source: provide deregister_source_class() for unloading plugins X-Git-Tag: e2factory-2.3.18rc4~8 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=78081f067f057c5787b0a2884f06353bce68091c;p=e2factory.git source: provide deregister_source_class() for unloading plugins Signed-off-by: Tobias Ulmer --- diff --git a/local/source.lua b/local/source.lua index ad51c10..7e76764 100644 --- a/local/source.lua +++ b/local/source.lua @@ -338,7 +338,7 @@ function source.register_source_class(typ, source_class) assert(type(source_class) == "table") if source_types[typ] then - return false, err.new("source %q already registered", typ) + return false, err.new("source class %q already registered", typ) end source_types[typ] = source_class @@ -346,6 +346,24 @@ function source.register_source_class(typ, source_class) return true end +--- Deregister a source class. +-- @param typ Source type name. +-- @param source_class Class derived from basic_source. +-- @return True on success, false on error. +-- @return Error object on failure. +function source.deregister_source_class(typ, source_class) + assert(type(typ) == "string" and typ ~= "") + assert(type(source_class) == "table") + + if source_types[typ] == nil then + return false, err.new("source class %q not registered", typ) + end + + source_types[typ] = nil + + return true +end + --- Iterate over registered source classes. -- @return Iterator function that returns a sorted typ, source class pair. function source.iterate_source_classes()