Skip to content

Commit e951bbf

Browse files
committed
Clean up i18n and rubocop
1 parent b3658f8 commit e951bbf

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

lib/puppet/provider/mysql.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,18 @@ def defaults_file
5454
self.class.defaults_file
5555
end
5656

57-
def self.mysql_caller(textOfSQL, type = 'undefined')
57+
def self.mysql_caller(text_of_sql, type)
5858
if type.eql? 'system'
59-
mysql_raw([defaults_file, '--host=', system_database, '-e', textOfSQL].flatten.compact)
59+
mysql_raw([defaults_file, '--host=', system_database, '-e', text_of_sql].flatten.compact)
6060
elsif type.eql? 'regular'
61-
mysql_raw([defaults_file, '-NBe', textOfSQL].flatten.compact)
62-
elsif type.eql? 'undefined'
63-
begin
64-
raise Puppet::Error, "#mysql had an error -> did not pass in type parameter"
65-
rescue => e
66-
puts "Error during processing: #{$!}"
67-
puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
68-
end
61+
mysql_raw([defaults_file, '-NBe', text_of_sql].flatten.compact)
6962
else
70-
raise Puppet::Error, "#mysql had an error -> Unrecognised type '#type'"
63+
raise Puppet::Error, _("#mysql_caller: Unrecognised type '%{type}'" % { type: type })
7164
end
7265
end
7366

7467
def self.users
75-
self.mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n")
68+
mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n")
7669
end
7770

7871
# Optional parameter to run a statement on the MySQL system database.

lib/puppet/provider/mysql_database/mysql.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
commands mysql_raw: 'mysql'
66

77
def self.instances
8-
self.mysql_caller('show databases', 'regular').split("\n").map do |name|
8+
mysql_caller('show databases', 'regular').split("\n").map do |name|
99
attributes = {}
10-
self.mysql_caller(["show variables like '%_database'", name], 'regular').split("\n").each do |line|
10+
mysql_caller(["show variables like '%_database'", name], 'regular').split("\n").each do |line|
1111
k, v = line.split(%r{\s})
1212
attributes[k] = v
1313
end

lib/puppet/provider/mysql_grant/mysql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def self.instances
1010
user_string = cmd_user(user)
1111
query = "SHOW GRANTS FOR #{user_string};"
1212
begin
13-
grants = self.mysql_caller(query, 'regular')
13+
grants = mysql_caller(query, 'regular')
1414
rescue Puppet::ExecutionFailure => e
1515
# Silently ignore users with no grants. Can happen e.g. if user is
1616
# defined with fqdn and server is run with skip-name-resolve. Example:

lib/puppet/provider/mysql_plugin/mysql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
commands mysql_raw: 'mysql'
66

77
def self.instances
8-
self.mysql_caller('show plugins', 'regular').split("\n").map do |line|
8+
mysql_caller('show plugins', 'regular').split("\n").map do |line|
99
name, _status, _type, library, _license = line.split(%r{\t})
1010
new(name: name,
1111
ensure: :present,

lib/puppet/provider/mysql_user/mysql.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Build a property_hash containing all the discovered information about MySQL
77
# users.
88
def self.instances
9-
users = self.mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n")
9+
users = mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n")
1010
# To reduce the number of calls to MySQL we collect all the properties in
1111
# one big swoop.
1212
users.map do |name|
@@ -21,7 +21,7 @@ def self.instances
2121
end
2222
@max_user_connections, @max_connections_per_hour, @max_queries_per_hour,
2323
@max_updates_per_hour, ssl_type, ssl_cipher, x509_issuer, x509_subject,
24-
@password, @plugin = self.mysql_caller(query, 'regular').split(%r{\s})
24+
@password, @plugin = mysql_caller(query, 'regular').split(%r{\s})
2525
@tls_options = parse_tls_options(ssl_type, ssl_cipher, x509_issuer, x509_subject)
2626
# rubocop:enable Metrics/LineLength
2727
new(name: name,

0 commit comments

Comments
 (0)