Skip to content

Commit

Permalink
Fix RuboCop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
sinfomicien committed Oct 1, 2014
1 parent 4bfb2f8 commit 2aff521
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 11 additions & 6 deletions providers/replication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def whyrun_supported?
true
end

def get_mysql_command(host,port,user,password)
def get_mysql_command(host, port, user, password)
mysql_command = '/usr/bin/mysql'
mysql_command += ' -h ' + host unless host.nil?
mysql_command += ' -P ' + port unless port.nil?
Expand All @@ -19,8 +19,10 @@ def get_mysql_command(host,port,user,password)
end

action :add do
if new_resource.master_host.nil? || new_resource.master_user.nil? || new_resource.master_password.nil?
raise "[ERROR] When adding a slave, you have to define master_host master_user and master_password !"
if new_resource.master_host.nil? || new_resource.master_user.nil? ||
new_resource.master_password.nil?
fail '[ERROR] When adding a slave, you have to define master_host' \
' master_user and master_password !'
end
sql_string = 'CHANGE MASTER '
sql_string += '\'' + new_resource.name + \
Expand All @@ -34,7 +36,8 @@ def get_mysql_command(host,port,user,password)
if new_resource.master_use_gtid == 'no'
# Use non GTID replication setup
if new_resource.master_log_file.nil? || new_resource.master_log_pos.nil?
raise "[ERROR] When adding a slave without GTID, you have to define master_log_file and master_log_pos !"
fail '[ERROR] When adding a slave without GTID, you have to' \
'define master_log_file and master_log_pos !'
end
unless new_resource.master_log_file.nil?
sql_string += ', MASTER_LOG_FILE=\'' + \
Expand Down Expand Up @@ -70,7 +73,8 @@ def get_mysql_command(host,port,user,password)
end

action :start do
command_master_connection = ' \'' + new_resource.name + '\'' unless new_resource.name == 'default'
command_master_connection = ' \'' + new_resource.name + \
'\'' unless new_resource.name == 'default'
execute 'start_replication_from_master_' + new_resource.name do
command '/bin/echo "START SLAVE' + command_master_connection + ';' \
'" | ' + get_mysql_command(
Expand All @@ -83,7 +87,8 @@ def get_mysql_command(host,port,user,password)
end

action :stop do
command_master_connection = ' \'' + new_resource.name + '\'' unless new_resource.name == 'default'
command_master_connection = ' \'' + new_resource.name + \
'\'' unless new_resource.name == 'default'
execute 'start_replication_from_master_' + new_resource.name do
command '/bin/echo "STOP SLAVE' + command_master_connection + ';' \
'" | ' + get_mysql_command(
Expand Down
14 changes: 7 additions & 7 deletions resources/replication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

# name of the extra conf file, used for .cnf filename
attribute :connection_name, kind_of: String, name_attribute: true
attribute :host, kind_of: [String,nil], default: nil
attribute :port, kind_of: [String,nil], default: nil
attribute :user, kind_of: [String,nil], default: nil
attribute :password, kind_of: [String,nil], default: nil
attribute :master_host, kind_of: [String,nil], default: nil
attribute :master_user, kind_of: [String,nil], default: nil
attribute :master_password, kind_of: [String,nil], default: nil
attribute :host, kind_of: [String, nil], default: nil
attribute :port, kind_of: [String, nil], default: nil
attribute :user, kind_of: [String, nil], default: nil
attribute :password, kind_of: [String, nil], default: nil
attribute :master_host, kind_of: [String, nil], default: nil
attribute :master_user, kind_of: [String, nil], default: nil
attribute :master_password, kind_of: [String, nil], default: nil
attribute :master_connect_retry, kind_of: [String, nil], default: nil
attribute :master_port, kind_of: [Integer, nil], default: nil
attribute :master_log_pos, kind_of: [Integer, nil], default: nil
Expand Down

0 comments on commit 2aff521

Please sign in to comment.