libraries/deploy-context/deploy/deployer.rb in deploy-context-2.2.0.3.gec16643.4.g20d2d42.4.g17e8559.12.g831d0a8.4.gbb2ab14.12.g0bc028d vs libraries/deploy-context/deploy/deployer.rb in deploy-context-2.13.0
- old
+ new
@@ -13,10 +13,15 @@
context.get_context_file(context, 'contexts')
end
def show_help(context)
help_message = <<MESSAGE_END
+#{
+ context.actions_permitted.each do |action|
+ puts "Available action '#{action}'"
+ end
+}
Use not option or the option 'cycle' to cycle through the deployer once
Use the option 'agent' to made a continual loop of the cycle
Use the option 'bump' to bump the patch version
Use the option 'release' to bump the minor version
Use the option 'upgrade' to bump the major version
@@ -25,59 +30,36 @@
Use the option 'help' to show this message
MESSAGE_END
context.error_log(context.context_name, help_message)
end
+ def actions_permitted?(action)
+ log "Is Default action '#{action}' permitted?"
+ action_is_permit = actions_permitted.include?(action)
+
+ log "The answer is #{action_is_permit} through '#{actions_permitted}'"
+ action_is_permit
+ end
+
def execute_action(context, action)
state_action = if action.nil?
show_help(context)
false
else
- case action
- when 'cycle'
- context.log "\nExecute only the cycle once\n"
- context.cycle
- true
- when 'agent'
- context.log "\nAlways in execution\n"
- while true do
- context.cycle
- end
- true
- when 'bump'
- context.log "\nBump minor version\n"
- context.patch_bump
- true
- when 'release'
- context.log "\nBump major version\n"
- context.minor_bump
- true
- when 'upgrade'
- context.log "\nBump major version\n"
- context.major_bump
- true
- when 'test'
- context.log "\nExecute tests\n"
- context.test_context_successful?
- when 'reset'
- context.log "\nReset versionning\n"
- system('rake')
- # context.cucumber_test(deployer)
- true
- when 'help'
- context.show_help(context)
- true
+ if context.respond_to?(action)
+ context.log("\n\nStarting Action '#{action}'")
+ context.send(action)
else
- context.error_log context.context_name, "Unknown setting #{action}"
- show_help(context)
+ context.error_log(context, "Action '#{action}' is unavailable")
false
end
end
- context.commit
+ # context.commit
if state_action
context.log "\n\nAction #{action} executed correctly in context #{context}"
+ state_action.perform unless state_action.kind_of?(TrueClass) || state_action.kind_of?(Integer)
else
- context.error_log(context.context_name, "Failed to execute action #{action} in context #{context}")
+ context.error_log(context.context_name, "Failed to execute action #{action} in context #{context.context_name} resulting to a #{state_action}")
end
end
end
end
end