Module: Terraspace::Plugin
- Extended by:
- Memoist, Plugin
- Included in:
- Plugin
- Defined in:
- lib/terraspace/plugin.rb,
lib/terraspace/plugin/meta.rb,
lib/terraspace/plugin/finder.rb,
lib/terraspace/plugin/infer_provider.rb
Defined Under Namespace
Modules: Backend, Config, Decorator, Expander, InferProvider, Layer, Summary Classes: Finder, Meta
Constant Summary collapse
- @@meta =
The plugin metadata
Example meta:
{ "aws => {root: "/path", backend: "s3"} "google" => {root: "/path", backend: "gcs"}, }
{}
Instance Method Summary collapse
- #config_classes ⇒ Object
- #find_with(options = {}) ⇒ Object
-
#klass(interface_class, options = {}) ⇒ Object
Example return:.
- #layer_classes ⇒ Object
- #meta ⇒ Object
- #register(plugin, data) ⇒ Object
-
#resource_map ⇒ Object
The resource map can be used to customized the mapping from the resource “first word” to the plugin.
Instance Method Details
#config_classes ⇒ Object
23 24 25 |
# File 'lib/terraspace/plugin.rb', line 23 def config_classes @@meta.map { |plugin, data| data[:config_class] }.compact end |
#find_with(options = {}) ⇒ Object
66 67 68 |
# File 'lib/terraspace/plugin.rb', line 66 def find_with(={}) Finder.new.find_with() end |
#klass(interface_class, options = {}) ⇒ Object
Example return:
TerraspacePluginAws::Interfaces::Backend
TerraspacePluginAws::Interfaces::Expander
TerraspacePluginGcp::Interfaces::Backend
TerraspacePluginGcp::Interfaces::Expander
60 61 62 63 64 |
# File 'lib/terraspace/plugin.rb', line 60 def klass(interface_class, ={}) = find_with() return unless "TerraspacePlugin#{.plugin}::Interfaces::#{interface_class}" end |
#layer_classes ⇒ Object
19 20 21 |
# File 'lib/terraspace/plugin.rb', line 19 def layer_classes @@meta.map { |plugin, data| data[:layer_class] }.compact end |
#meta ⇒ Object
15 16 17 |
# File 'lib/terraspace/plugin.rb', line 15 def @@meta end |
#register(plugin, data) ⇒ Object
49 50 51 |
# File 'lib/terraspace/plugin.rb', line 49 def register(plugin, data) @@meta[plugin] = data end |
#resource_map ⇒ Object
The resource map can be used to customized the mapping from the resource “first word” to the plugin.
resource map is in meta structure.
{
"long_cloud_plugin_name" => {resource_map: {"long_cloud_plugin_name" => "short_name"}
}
This is use by Plugin::Finder#find_with_resource Allows mapping of different values in case the terraspace plugin name doesnt match with the resource first word.
Generally we try to avoid this and the terraspace plugin name should match the resource “first word” when possible.
42 43 44 45 46 47 |
# File 'lib/terraspace/plugin.rb', line 42 def resource_map @@meta.inject({}) do |result, (plugin, data)| map = data[:resource_map] || {} result.merge(map.deep_stringify_keys) end end |