mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
(rubocop) Fix Style/IfUnlessModifier
This commit is contained in:
parent
c7c8e48e2f
commit
7bafee35a7
7 changed files with 15 additions and 45 deletions
|
|
@ -212,9 +212,7 @@ class Vmfloaty
|
|||
# Confirm deletion
|
||||
puts
|
||||
confirmed = true
|
||||
unless force
|
||||
confirmed = agree('Delete all these VMs? [y/N]')
|
||||
end
|
||||
confirmed = agree('Delete all these VMs? [y/N]') unless force
|
||||
if confirmed
|
||||
response = service.delete(verbose, running_vms)
|
||||
response.each do |hostname, result|
|
||||
|
|
@ -381,9 +379,7 @@ class Vmfloaty
|
|||
puts result
|
||||
when 'status'
|
||||
token_value = options.token
|
||||
if token_value.nil?
|
||||
token_value = args[1]
|
||||
end
|
||||
token_value = args[1] if token_value.nil?
|
||||
status = service.token_status(verbose, token_value)
|
||||
puts status
|
||||
when nil
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ class Auth
|
|||
end
|
||||
|
||||
def self.delete_token(verbose, url, user, password, token)
|
||||
if token.nil?
|
||||
raise TokenError, 'You did not provide a token'
|
||||
end
|
||||
raise TokenError, 'You did not provide a token' if token.nil?
|
||||
|
||||
conn = Http.get_conn_with_auth(verbose, url, user, password)
|
||||
|
||||
|
|
@ -36,9 +34,7 @@ class Auth
|
|||
end
|
||||
|
||||
def self.token_status(verbose, url, token)
|
||||
if token.nil?
|
||||
raise TokenError, 'You did not provide a token'
|
||||
end
|
||||
raise TokenError, 'You did not provide a token' if token.nil?
|
||||
|
||||
conn = Http.get_conn(verbose, url)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,21 +11,15 @@ class Http
|
|||
|
||||
uri = URI.parse(url)
|
||||
|
||||
if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
|
||||
return true
|
||||
end
|
||||
return true if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def self.get_conn(verbose, url)
|
||||
if url.nil?
|
||||
raise 'Did not provide a url to connect to'
|
||||
end
|
||||
raise 'Did not provide a url to connect to' if url.nil?
|
||||
|
||||
unless is_url(url)
|
||||
url = "https://#{url}"
|
||||
end
|
||||
url = "https://#{url}" unless is_url(url)
|
||||
|
||||
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
||||
faraday.request :url_encoded
|
||||
|
|
@ -37,17 +31,11 @@ class Http
|
|||
end
|
||||
|
||||
def self.get_conn_with_auth(verbose, url, user, password)
|
||||
if url.nil?
|
||||
raise 'Did not provide a url to connect to'
|
||||
end
|
||||
raise 'Did not provide a url to connect to' if url.nil?
|
||||
|
||||
if user.nil?
|
||||
raise 'You did not provide a user to authenticate with'
|
||||
end
|
||||
raise 'You did not provide a user to authenticate with' if user.nil?
|
||||
|
||||
unless is_url(url)
|
||||
url = "https://#{url}"
|
||||
end
|
||||
url = "https://#{url}" unless is_url(url)
|
||||
|
||||
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
||||
faraday.request :url_encoded
|
||||
|
|
|
|||
|
|
@ -94,9 +94,7 @@ class NonstandardPooler
|
|||
|
||||
response_body = {}
|
||||
|
||||
unless hosts.is_a? Array
|
||||
hosts = hosts.split(',')
|
||||
end
|
||||
hosts = hosts.split(',') unless hosts.is_a? Array
|
||||
hosts.each do |host|
|
||||
response = conn.delete "host/#{host}"
|
||||
res_body = JSON.parse(response.body)
|
||||
|
|
|
|||
|
|
@ -35,9 +35,7 @@ class Pooler
|
|||
# Developers can use `Utils.generate_os_hash` to
|
||||
# generate the os_type param.
|
||||
conn = Http.get_conn(verbose, url)
|
||||
if token
|
||||
conn.headers['X-AUTH-TOKEN'] = token
|
||||
end
|
||||
conn.headers['X-AUTH-TOKEN'] = token if token
|
||||
|
||||
os_string = os_type.map { |os, num| Array(os) * num }.flatten.join('+')
|
||||
if os_string.empty?
|
||||
|
|
@ -106,9 +104,7 @@ class Pooler
|
|||
|
||||
conn = Http.get_conn(verbose, url)
|
||||
|
||||
if token
|
||||
conn.headers['X-AUTH-TOKEN'] = token
|
||||
end
|
||||
conn.headers['X-AUTH-TOKEN'] = token if token
|
||||
|
||||
response_body = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ class Ssh
|
|||
|
||||
def self.ssh(verbose, host_os, token, url)
|
||||
ssh_path = which('ssh')
|
||||
if !ssh_path
|
||||
raise 'Could not determine path to ssh'
|
||||
end
|
||||
raise 'Could not determine path to ssh' if !ssh_path
|
||||
os_types = {}
|
||||
os_types[host_os] = 1
|
||||
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ class Utils
|
|||
|
||||
response_body.each do |os, value|
|
||||
hostnames = Array(value['hostname'])
|
||||
if domain
|
||||
hostnames.map! {|host| "#{host}.#{domain}"}
|
||||
end
|
||||
hostnames.map! {|host| "#{host}.#{domain}"} if domain
|
||||
result[os] = hostnames
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue