Class: Broadside::Configuration::DeployConfig
- Inherits:
-
ConfigStruct
- Object
- ConfigStruct
- Broadside::Configuration::DeployConfig
- Includes:
- Utils
- Defined in:
- lib/broadside/configuration/deploy.rb
Constant Summary collapse
- DEFAULT_PREDEPLOY_COMMANDS =
[ ['bundle', 'exec', 'rake', '--trace', 'db:migrate'] ]
- TARGET_ATTRIBUTE_VALIDATIONS =
{ scale: ->(target_attribute) { validate_types([Fixnum], target_attribute) }, env_file: ->(target_attribute) { validate_types([String], target_attribute) }, command: ->(target_attribute) { validate_types([Array, NilClass], target_attribute) }, predeploy_commands: ->(target_attribute) { validate_predeploy(target_attribute) } }
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#env_vars ⇒ Object
Returns the value of attribute env_vars.
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#predeploy_commands ⇒ Object
Returns the value of attribute predeploy_commands.
-
#rollback ⇒ Object
Returns the value of attribute rollback.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#ssh ⇒ Object
Returns the value of attribute ssh.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#target ⇒ Object
Returns the value of attribute target.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize ⇒ DeployConfig
constructor
A new instance of DeployConfig.
-
#load_target! ⇒ Object
Loads deploy target data using provided target.
-
#validate_targets! ⇒ Object
Validates format of deploy targets Checks existence of provided target.
Methods included from Utils
#config, #debug, #error, #exception, #info, #warn
Methods inherited from ConfigStruct
#method_missing, #to_h, #verify
Constructor Details
#initialize ⇒ DeployConfig
Returns a new instance of DeployConfig.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/broadside/configuration/deploy.rb', line 35 def initialize @type = 'ecs' @ssh = nil @tag = nil @rollback = 1 @timeout = 600 @target = nil @targets = nil @scale = nil @env_vars = nil @command = nil @predeploy_commands = DEFAULT_PREDEPLOY_COMMANDS @instance = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Broadside::Configuration::ConfigStruct
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def command @command end |
#env_vars ⇒ Object
Returns the value of attribute env_vars.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def env_vars @env_vars end |
#instance ⇒ Object
Returns the value of attribute instance.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def instance @instance end |
#predeploy_commands ⇒ Object
Returns the value of attribute predeploy_commands.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def predeploy_commands @predeploy_commands end |
#rollback ⇒ Object
Returns the value of attribute rollback.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def rollback @rollback end |
#scale ⇒ Object
Returns the value of attribute scale.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def scale @scale end |
#ssh ⇒ Object
Returns the value of attribute ssh.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def ssh @ssh end |
#tag ⇒ Object
Returns the value of attribute tag.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def tag @tag end |
#target ⇒ Object
Returns the value of attribute target.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def target @target end |
#targets ⇒ Object
Returns the value of attribute targets.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def targets @targets end |
#timeout ⇒ Object
Returns the value of attribute timeout.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def timeout @timeout end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/broadside/configuration/deploy.rb', line 13 def type @type end |
Instance Method Details
#load_target! ⇒ Object
Loads deploy target data using provided target
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/broadside/configuration/deploy.rb', line 69 def load_target! validate_targets! env_file = Pathname.new(@targets[@target][:env_file]) unless env_file.absolute? dir = config.file.nil? ? Dir.pwd : Pathname.new(config.file).dirname env_file = env_file.(dir) end if env_file.exist? vars = Dotenv.load(env_file) @env_vars = vars.map { |k,v| {'name'=> k, 'value' => v } } else exception "Could not find file '#{env_file}' for loading environment variables !" end @scale ||= @targets[@target][:scale] @command = @targets[@target][:command] @predeploy_commands = @targets[@target][:predeploy_commands] if @targets[@target][:predeploy_commands] end |
#validate_targets! ⇒ Object
Validates format of deploy targets Checks existence of provided target
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/broadside/configuration/deploy.rb', line 52 def validate_targets! @targets.each do |target, configuration| TARGET_ATTRIBUTE_VALIDATIONS.each do |var, validation| = validation.call(configuration[var]) unless .nil? exception "Deploy target '#{@target}' parameter '#{var}' is invalid: #{message}" end end end unless @targets.has_key?(@target) exception "Could not find deploy target #{@target} in configuration !" end end |