Class: Itamae::Plugin::Resource::MysqlQuery

Inherits:
Resource::Base
  • Object
show all
Defined in:
lib/itamae/plugin/resource/mysql_query.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#action_run(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/itamae/plugin/resource/mysql_query.rb', line 28

def action_run(options)
  user_opt = attributes.user.empty? ? '' : "-u#{attributes.user}"
  password_opt = attributes.password.empty? ? '' : "-p#{attributes.password}"

  begin
    run_command(%Q{mysql #{user_opt} #{password_opt} < #{@temppath}})
  ensure
    run_specinfra(:remove_file, @temppath)
  end

  updated!
end

#pre_actionObject



15
16
17
18
19
20
21
22
# File 'lib/itamae/plugin/resource/mysql_query.rb', line 15

def pre_action
  case @current_action
  when :run
    attributes.executed = true
  end

  send_tempfile
end

#set_current_attributesObject



24
25
26
# File 'lib/itamae/plugin/resource/mysql_query.rb', line 24

def set_current_attributes
  current.executed = false
end