Merge pull request #156 from puppetlabs/DIO-2700

(DIO-2700) Vmfloaty should not use the Colorize gem
This commit is contained in:
trvs-sdlr 2022-02-16 11:12:14 -08:00 committed by GitHub
commit 85c833a290
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 8 deletions

View file

@ -2,7 +2,6 @@
require 'rubygems' require 'rubygems'
require 'commander' require 'commander'
require 'colorize'
require 'json' require 'json'
require 'pp' require 'pp'
require 'uri' require 'uri'

View file

@ -137,7 +137,7 @@ class Utils
metadata = [host_data['state'], host_data['template'], duration, *tag_pairs] metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent) message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
if host_data['state'] && host_data['state'] == 'destroyed' if host_data['state'] && host_data['state'] == 'destroyed'
output_target.puts message.colorize(:red) output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
else else
output_target.puts message output_target.puts message
end end
@ -201,7 +201,7 @@ class Utils
rescue StandardError => e rescue StandardError => e
FloatyLogger.error "#{name.ljust(width)} #{e.red}" FloatyLogger.error "#{name.ljust(width)} #{e.red}"
end end
puts message.colorize(status_response['status']['ok'] ? :default : :red) puts message
when 'NonstandardPooler' when 'NonstandardPooler'
pools = status_response pools = status_response
pools.delete 'ok' pools.delete 'ok'

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
class Vmfloaty class Vmfloaty
VERSION = '1.5.0' VERSION = '1.6.0'
end end

View file

@ -466,13 +466,13 @@ describe Utils do
subject subject
end end
it 'prints in red when destroyed' do it 'prints DESTROYED and hostname when destroyed' do
fallback = { 'vmpooler_fallback' => 'vmpooler' } fallback = { 'vmpooler_fallback' => 'vmpooler' }
service.config.merge! fallback service.config.merge! fallback
response_body_vmpooler[fqdn_hostname]['state'] = 'destroyed' response_body_vmpooler[fqdn_hostname]['state'] = 'destroyed'
default_output_second_line_red = " - #{fqdn} (destroyed, #{template}, 7.67/48 hours, user: bob, role: agent)".red default_output_second_line = " - DESTROYED #{fqdn}"
expect($stdout).to receive(:puts).with(default_output_first_line) expect($stdout).to receive(:puts).with(default_output_first_line)
expect($stdout).to receive(:puts).with(default_output_second_line_red) expect($stdout).to receive(:puts).with(default_output_second_line)
subject subject
end end

View file

@ -24,7 +24,6 @@ Gem::Specification.new do |s|
s.test_files = Dir['spec/**/*'] s.test_files = Dir['spec/**/*']
s.require_path = 'lib' s.require_path = 'lib'
s.add_dependency 'colorize', '~> 0.8.1'
s.add_dependency 'commander', '>= 4.4.3', '< 4.7.0' s.add_dependency 'commander', '>= 4.4.3', '< 4.7.0'
s.add_dependency 'faraday', '~> 1.5', '>= 1.5.1' s.add_dependency 'faraday', '~> 1.5', '>= 1.5.1'
end end