Skip to content

Commit

Permalink
Apply updated formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroberts committed Jun 2, 2018
1 parent a5032a4 commit 4cce6cc
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 104 deletions.
36 changes: 18 additions & 18 deletions lib/sfn/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ module Sfn
class Command < Bogo::Cli::Command
include CommandModule::Callbacks

autoload :Conf, 'sfn/command/conf'
autoload :Create, 'sfn/command/create'
autoload :Describe, 'sfn/command/describe'
autoload :Destroy, 'sfn/command/destroy'
autoload :Diff, 'sfn/command/diff'
autoload :Events, 'sfn/command/events'
autoload :Export, 'sfn/command/export'
autoload :Graph, 'sfn/command/graph'
autoload :Import, 'sfn/command/import'
autoload :Init, 'sfn/command/init'
autoload :Inspect, 'sfn/command/inspect'
autoload :Lint, 'sfn/command/lint'
autoload :List, 'sfn/command/list'
autoload :Plan, 'sfn/command/plan'
autoload :Print, 'sfn/command/print'
autoload :Promote, 'sfn/command/promote'
autoload :Update, 'sfn/command/update'
autoload :Validate, 'sfn/command/validate'
autoload :Conf, "sfn/command/conf"
autoload :Create, "sfn/command/create"
autoload :Describe, "sfn/command/describe"
autoload :Destroy, "sfn/command/destroy"
autoload :Diff, "sfn/command/diff"
autoload :Events, "sfn/command/events"
autoload :Export, "sfn/command/export"
autoload :Graph, "sfn/command/graph"
autoload :Import, "sfn/command/import"
autoload :Init, "sfn/command/init"
autoload :Inspect, "sfn/command/inspect"
autoload :Lint, "sfn/command/lint"
autoload :List, "sfn/command/list"
autoload :Plan, "sfn/command/plan"
autoload :Print, "sfn/command/print"
autoload :Promote, "sfn/command/promote"
autoload :Update, "sfn/command/update"
autoload :Validate, "sfn/command/validate"

# Base name of configuration file
CONFIG_BASE_NAME = ".sfn"
Expand Down
28 changes: 14 additions & 14 deletions lib/sfn/command/plan.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'sfn'
require "sfn"

module Sfn
class Command
Expand All @@ -14,7 +14,7 @@ def execute!
name_required!
name = name_args.first

stack_info = "#{ui.color('Name:', :bold)} #{name}"
stack_info = "#{ui.color("Name:", :bold)} #{name}"
begin
stack = provider.stacks.get(name)
rescue Miasma::Error::ApiError::RequestError
Expand All @@ -31,13 +31,13 @@ def execute!
c_setter = lambda do |c_stack|
if c_stack.outputs
compile_params = c_stack.outputs.detect do |output|
output.key == 'CompileState'
output.key == "CompileState"
end
end
if compile_params
compile_params = MultiJson.load(compile_params.value)
c_current = config[:compile_parameters].fetch(s_name.join('__'), Smash.new)
config[:compile_parameters][s_name.join('__')] = compile_params.merge(c_current)
c_current = config[:compile_parameters].fetch(s_name.join("__"), Smash.new)
config[:compile_parameters][s_name.join("__")] = compile_params.merge(c_current)
end
c_stack.nested_stacks(false).each do |n_stack|
s_name.push(n_stack.data.fetch(:logical_id, n_stack.name))
Expand All @@ -52,13 +52,13 @@ def execute!

ui.debug "Compile parameters - #{config[:compile_parameters]}"
file = load_template_file(:stack => stack)
stack_info << " #{ui.color('Path:', :bold)} #{config[:file]}"
stack_info << " #{ui.color("Path:", :bold)} #{config[:file]}"
else
file = stack.template.dup
end

unless config[:print_only]
ui.info "#{ui.color('SparkleFormation:', :bold)} #{ui.color('plan', :green)}"
ui.info "#{ui.color("SparkleFormation:", :bold)} #{ui.color("plan", :green)}"
if stack && stack.plan
ui.warn "Found existing plan for this stack"
begin
Expand All @@ -74,9 +74,9 @@ def execute!
unless file
if config[:template]
file = config[:template]
stack_info << " #{ui.color('(template provided)', :green)}"
stack_info << " #{ui.color("(template provided)", :green)}"
else
stack_info << " #{ui.color('(no template update)', :yellow)}"
stack_info << " #{ui.color("(no template update)", :yellow)}"
end
end
unless config[:print_only]
Expand Down Expand Up @@ -150,19 +150,19 @@ def execute!
if config[:poll]
poll_stack(stack.name)
if stack.reload.state == :update_complete || stack.reload.state == :create_complete
ui.info "Stack plan apply complete: #{ui.color('SUCCESS', :green)}"
ui.info "Stack plan apply complete: #{ui.color("SUCCESS", :green)}"
namespace.const_get(:Describe).new({:outputs => true}, [name]).execute!
else
ui.fatal "Update of stack #{ui.color(name, :bold)}: #{ui.color('FAILED', :red, :bold)}"
raise 'Stack did not reach a successful completion state.'
ui.fatal "Update of stack #{ui.color(name, :bold)}: #{ui.color("FAILED", :red, :bold)}"
raise "Stack did not reach a successful completion state."
end
else
ui.warn 'Stack state polling has been disabled.'
ui.warn "Stack state polling has been disabled."
ui.info "Stack plan apply initialized for #{ui.color(name, :green)}"
end
end
rescue Miasma::Error::ApiError::RequestError => e
if e.message.downcase.include?('no updates')
if e.message.downcase.include?("no updates")
ui.warn "No changes detected for stack (#{stack.name})"
else
raise
Expand Down
10 changes: 5 additions & 5 deletions lib/sfn/command_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

module Sfn
module CommandModule
autoload :Base, 'sfn/command_module/base'
autoload :Callbacks, 'sfn/command_module/callbacks'
autoload :Planning, 'sfn/command_module/planning'
autoload :Stack, 'sfn/command_module/stack'
autoload :Template, 'sfn/command_module/template'
autoload :Base, "sfn/command_module/base"
autoload :Callbacks, "sfn/command_module/callbacks"
autoload :Planning, "sfn/command_module/planning"
autoload :Stack, "sfn/command_module/stack"
autoload :Template, "sfn/command_module/template"
end
end
52 changes: 26 additions & 26 deletions lib/sfn/command_module/planning.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'sfn'
require 'sparkle_formation'
require "sfn"
require "sparkle_formation"

module Sfn
module CommandModule
Expand All @@ -10,7 +10,7 @@ module Planning
# @param [Miasma::Models::Orchestration::Stack]
# @return [Sfn::Planner]
def build_planner(stack)
klass_name = stack.api.class.to_s.split('::').last
klass_name = stack.api.class.to_s.split("::").last
if Planner.const_defined?(klass_name)
Planner.const_get(klass_name).new(ui, config, arguments, stack)
else
Expand All @@ -23,11 +23,11 @@ def build_planner(stack)
#
# @param result [Miasma::Models::Orchestration::Stack::Plan]
def display_plan_information(result)
ui.info ui.color('Pre-update resource planning report:', :bold)
ui.info ui.color("Pre-update resource planning report:", :bold)
unless print_plan_result(result)
ui.info 'No resources life cycle changes detected in this update!'
ui.info "No resources life cycle changes detected in this update!"
end
cmd = self.class.to_s.split('::').last.downcase
cmd = self.class.to_s.split("::").last.downcase
ui.confirm "Apply this stack #{cmd}?" unless config[:plan_only]
end

Expand All @@ -45,47 +45,47 @@ def print_plan_result(info, names = [])
end
if !names.flatten.compact.empty? || info.name
said_things = false
output_name = names.empty? ? info.name : names.join(' > ')
output_name = names.empty? ? info.name : names.join(" > ")
ui.puts
ui.puts " #{ui.color('Update plan for:', :bold)} #{ui.color(names.join(' > '), :blue)}"
ui.puts " #{ui.color("Update plan for:", :bold)} #{ui.color(names.join(" > "), :blue)}"
unless Array(info.unknown).empty?
ui.puts " #{ui.color('!!! Unknown update effect:', :red, :bold)}"
ui.puts " #{ui.color("!!! Unknown update effect:", :red, :bold)}"
print_plan_items(info, :unknown, :red)
ui.puts
said_any_things = said_things = true
end
unless Array(info.unavailable).empty?
ui.puts " #{ui.color('Update request not allowed:', :red, :bold)}"
ui.puts " #{ui.color("Update request not allowed:", :red, :bold)}"
print_plan_items(info, :unavailable, :red)
ui.puts
said_any_things = said_things = true
end
unless Array(info.replace).empty?
ui.puts " #{ui.color('Resources to be replaced:', :red, :bold)}"
ui.puts " #{ui.color("Resources to be replaced:", :red, :bold)}"
print_plan_items(info, :replace, :red)
ui.puts
said_any_things = said_things = true
end
unless Array(info.interrupt).empty?
ui.puts " #{ui.color('Resources to be interrupted:', :yellow, :bold)}"
ui.puts " #{ui.color("Resources to be interrupted:", :yellow, :bold)}"
print_plan_items(info, :interrupt, :yellow)
ui.puts
said_any_things = said_things = true
end
unless Array(info.remove).empty?
ui.puts " #{ui.color('Resources to be removed:', :red, :bold)}"
ui.puts " #{ui.color("Resources to be removed:", :red, :bold)}"
print_plan_items(info, :remove, :red)
ui.puts
said_any_things = said_things = true
end
unless Array(info.add).empty?
ui.puts " #{ui.color('Resources to be added:', :green, :bold)}"
ui.puts " #{ui.color("Resources to be added:", :green, :bold)}"
print_plan_items(info, :add, :green)
ui.puts
said_any_things = said_things = true
end
unless said_things
ui.puts " #{ui.color('No resource lifecycle changes detected!', :green)}"
ui.puts " #{ui.color("No resource lifecycle changes detected!", :green)}"
ui.puts
said_any_things = true
end
Expand All @@ -106,16 +106,16 @@ def print_plan_items(info, key, color)
max_o = collection.map(&:diffs).flatten(1).map(&:current).map(&:to_s).map(&:size).max
collection.each do |val|
name = val.name
ui.print ' ' * 6
ui.print " " * 6
ui.print ui.color("[#{val.type}]", color)
ui.print ' ' * (max_type - val.type.size)
ui.print ' ' * 4
ui.print " " * (max_type - val.type.size)
ui.print " " * 4
ui.print ui.color(name, :bold)
properties = Array(val.diffs).map(&:name)
unless properties.empty?
ui.print ' ' * (max_name - name.size)
ui.print ' ' * 4
ui.print "Reason: Updated properties: `#{properties.join('`, `')}`"
ui.print " " * (max_name - name.size)
ui.print " " * 4
ui.print "Reason: Updated properties: `#{properties.join("`, `")}`"
end
ui.puts
if config[:diffs]
Expand All @@ -124,19 +124,19 @@ def print_plan_items(info, key, color)
val.diffs.each do |diff|
if !diff.proposed.nil? || !diff.current.nil?
p_name = diff.name
ui.print ' ' * 8
ui.print " " * 8
ui.print "#{p_name}: "
ui.print ' ' * (max_p - p_name.size)
ui.print " " * (max_p - p_name.size)
ui.print ui.color("-#{diff.current}", :red) if diff.current
ui.print ' ' * (max_o - diff.current.to_s.size)
ui.print ' '
ui.print " " * (max_o - diff.current.to_s.size)
ui.print " "
if diff.proposed == Sfn::Planner::RUNTIME_MODIFIED
ui.puts ui.color("+#{diff.current} <Dependency Modified>", :green)
else
if diff.proposed.nil?
ui.puts
else
ui.puts ui.color("+#{diff.proposed.to_s.gsub('__MODIFIED_REFERENCE_VALUE__', '<Dependency Modified>')}", :green)
ui.puts ui.color("+#{diff.proposed.to_s.gsub("__MODIFIED_REFERENCE_VALUE__", "<Dependency Modified>")}", :green)
end
end
end
Expand Down
38 changes: 19 additions & 19 deletions lib/sfn/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ def self.attribute(name, type, info = Smash.new)
# Only values allowed designating bool type
BOOLEAN = BOOLEAN_VALUES = [TrueClass, FalseClass]

autoload :Conf, 'sfn/config/conf'
autoload :Create, 'sfn/config/create'
autoload :Describe, 'sfn/config/describe'
autoload :Destroy, 'sfn/config/destroy'
autoload :Describe, 'sfn/config/describe'
autoload :Diff, 'sfn/config/diff'
autoload :Events, 'sfn/config/events'
autoload :Export, 'sfn/config/export'
autoload :Graph, 'sfn/config/graph'
autoload :Import, 'sfn/config/import'
autoload :Init, 'sfn/config/init'
autoload :Inspect, 'sfn/config/inspect'
autoload :Lint, 'sfn/config/lint'
autoload :List, 'sfn/config/list'
autoload :Plan, 'sfn/config/plan'
autoload :Print, 'sfn/config/print'
autoload :Promote, 'sfn/config/promote'
autoload :Update, 'sfn/config/update'
autoload :Validate, 'sfn/config/validate'
autoload :Conf, "sfn/config/conf"
autoload :Create, "sfn/config/create"
autoload :Describe, "sfn/config/describe"
autoload :Destroy, "sfn/config/destroy"
autoload :Describe, "sfn/config/describe"
autoload :Diff, "sfn/config/diff"
autoload :Events, "sfn/config/events"
autoload :Export, "sfn/config/export"
autoload :Graph, "sfn/config/graph"
autoload :Import, "sfn/config/import"
autoload :Init, "sfn/config/init"
autoload :Inspect, "sfn/config/inspect"
autoload :Lint, "sfn/config/lint"
autoload :List, "sfn/config/list"
autoload :Plan, "sfn/config/plan"
autoload :Print, "sfn/config/print"
autoload :Promote, "sfn/config/promote"
autoload :Update, "sfn/config/update"
autoload :Validate, "sfn/config/validate"

attribute(
:config, String,
Expand Down
8 changes: 4 additions & 4 deletions lib/sfn/config/plan.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'sfn'
require "sfn"

module Sfn
class Config
Expand All @@ -15,14 +15,14 @@ class Plan < Create

attribute(
:plan_name, String,
:description => 'Custom plan name or ID (not applicable to all providers)',
:description => "Custom plan name or ID (not applicable to all providers)",
)

attribute(
:list, BOOLEAN,
:description => 'List all available plans for stack',
:description => "List all available plans for stack",
:default => false,
:short_flag => 'l',
:short_flag => "l",
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion sfn.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 10'
s.add_development_dependency 'minitest'
s.add_development_dependency 'rspec', '~> 3.5'
s.add_development_dependency 'rufo', '~> 0.2.0'
s.add_development_dependency 'rufo', '~> 0.3.0'
s.add_development_dependency 'mocha'
s.add_development_dependency 'yard'
s.executables << 'sfn'
Expand Down
Loading

0 comments on commit 4cce6cc

Please sign in to comment.