Class: LogStash::Modules::Scaffold

Inherits:
Object
  • Object
show all
Includes:
Util::Loggable
Defined in:
lib/logstash/modules/scaffold.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, directory) ⇒ Scaffold

Returns a new instance of Scaffold.



14
15
16
17
18
19
# File 'lib/logstash/modules/scaffold.rb', line 14

def initialize(name, directory)
  @module_name = name
  @directory = directory  # this is the 'configuration folder in the GEM root.'
  @kibana_version_parts = "6.0.0".split('.') # this is backup in case kibana client fails to connect
  logger.debug("Found module", :module_name => name, :directory => directory)
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



11
12
13
# File 'lib/logstash/modules/scaffold.rb', line 11

def directory
  @directory
end

#elasticsearch_configurationObject (readonly)

Returns the value of attribute elasticsearch_configuration.



12
13
14
# File 'lib/logstash/modules/scaffold.rb', line 12

def elasticsearch_configuration
  @elasticsearch_configuration
end

#kibana_configurationObject (readonly)

Returns the value of attribute kibana_configuration.



12
13
14
# File 'lib/logstash/modules/scaffold.rb', line 12

def kibana_configuration
  @kibana_configuration
end

#kibana_version_partsObject (readonly)

Returns the value of attribute kibana_version_parts.



11
12
13
# File 'lib/logstash/modules/scaffold.rb', line 11

def kibana_version_parts
  @kibana_version_parts
end

#logstash_configurationObject (readonly)

Returns the value of attribute logstash_configuration.



12
13
14
# File 'lib/logstash/modules/scaffold.rb', line 12

def logstash_configuration
  @logstash_configuration
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



11
12
13
# File 'lib/logstash/modules/scaffold.rb', line 11

def module_name
  @module_name
end

Instance Method Details

#add_kibana_version(version_parts) ⇒ Object



21
22
23
# File 'lib/logstash/modules/scaffold.rb', line 21

def add_kibana_version(version_parts)
  @kibana_version_parts = version_parts
end

#config_stringObject



41
42
43
44
45
46
47
# File 'lib/logstash/modules/scaffold.rb', line 41

def config_string()
  # settings should be set earlier by the caller.
  # settings should be the subset from the YAML file with a structure like
  # {"name" => "plugin name", "k1" => "v1", "k2" => "v2"}, etc.
  return nil if @logstash_configuration.nil?
  @logstash_configuration.config_string
end

#import(import_engine, kibana_import_engine) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/logstash/modules/scaffold.rb', line 25

def import(import_engine, kibana_import_engine)
  @elasticsearch_configuration.resources.each do |resource|
    import_engine.put(resource)
  end
  @kibana_configuration.resources.each do |resource|
    kibana_import_engine.put(resource)
  end
end

#is_enabled?(settings) ⇒ Boolean

subclass may override

Returns:

  • (Boolean)


50
51
52
# File 'lib/logstash/modules/scaffold.rb', line 50

def is_enabled?(settings)
  true
end

#with_settings(module_settings) ⇒ Object



34
35
36
37
38
39
# File 'lib/logstash/modules/scaffold.rb', line 34

def with_settings(module_settings)
  @logstash_configuration = LogStashConfig.new(self, module_settings)
  @kibana_configuration = KibanaConfig.new(self, module_settings)
  @elasticsearch_configuration = ElasticsearchConfig.new(self, module_settings)
  self
end