Class: ElasticGraph::Admin::ClusterConfigurator::ScriptConfigurator
- Inherits:
-
Object
- Object
- ElasticGraph::Admin::ClusterConfigurator::ScriptConfigurator
- Defined in:
- lib/elastic_graph/admin/cluster_configurator/script_configurator.rb
Instance Method Summary collapse
- #configure! ⇒ Object
-
#initialize(datastore_client:, script_context:, script_id:, script:, output:) ⇒ ScriptConfigurator
constructor
A new instance of ScriptConfigurator.
- #validate ⇒ Object
Constructor Details
#initialize(datastore_client:, script_context:, script_id:, script:, output:) ⇒ ScriptConfigurator
16 17 18 19 20 21 22 |
# File 'lib/elastic_graph/admin/cluster_configurator/script_configurator.rb', line 16 def initialize(datastore_client:, script_context:, script_id:, script:, output:) @datastore_client = datastore_client @script_context = script_context @script_id = script_id @script = script @action_reporter = ActionReporter.new(output) end |
Instance Method Details
#configure! ⇒ Object
37 38 39 40 41 42 |
# File 'lib/elastic_graph/admin/cluster_configurator/script_configurator.rb', line 37 def configure! if existing_datastore_script == :not_found @datastore_client.put_script(id: @script_id, body: {script: @script}, context: @script_context) @action_reporter.report_action "Stored #{@script_context} script: #{@script_id}" end end |
#validate ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/elastic_graph/admin/cluster_configurator/script_configurator.rb', line 24 def validate case existing_datastore_script when :not_found, @script [] else [ "#{@script_context} script #{@script_id} already exists in the datastore but has different contents. " \ "\n\nScript in the datastore:\n#{::YAML.dump(existing_datastore_script)}" \ "\n\nDesired script:\n#{::YAML.dump(@script)}" ] end end |