class Broadside::Target
Constants
- CREATE_ONLY_SERVICE_ATTRIBUTES
Attributes
bootstrap_commands[R]
cluster[R]
command[R]
docker_image[R]
name[R]
predeploy_commands[R]
scale[R]
service_config[R]
tag[R]
task_definition_config[R]
Public Class Methods
new(name, options = {})
click to toggle source
# File lib/broadside/target.rb, line 55 def initialize(name, options = {}) @name = name config = options.deep_dup @bootstrap_commands = config.delete(:bootstrap_commands) @cluster = config.delete(:cluster) || Broadside.config.aws.ecs_default_cluster @command = config.delete(:command) @docker_image = config.delete(:docker_image) || Broadside.config.default_docker_image @predeploy_commands = config.delete(:predeploy_commands) @scale = config.delete(:scale) @service_config = config.delete(:service_config) @tag = config.delete(:tag) @task_definition_config = config.delete(:task_definition_config) @env_files = Array.wrap(config.delete(:env_files) || config.delete(:env_file)).map do |env_path| env_file = Pathname.new(env_path) next env_file if env_file.absolute? dir = Broadside.config.config_file ? Pathname.new(Broadside.config.config_file).dirname : Dir.pwd env_file.expand_path(dir) end raise ConfigurationError, errors.full_messages unless valid? raise ConfigurationError, "Target #{@name} was configured with invalid options: #{config}" unless config.empty? end
Public Instance Methods
ecs_env_vars()
click to toggle source
# File lib/broadside/target.rb, line 81 def ecs_env_vars @env_vars ||= @env_files.inject({}) do |env_variables, env_file| raise ConfigurationError, "Specified env_file: '#{env_file}' does not exist!" unless env_file.exist? begin env_variables.merge(Dotenv.load(env_file)) rescue Dotenv::FormatError => e raise e.class, "Error parsing #{env_file}: #{e.message}", e.backtrace end end.map { |k, v| { 'name' => k, 'value' => v } } end
family()
click to toggle source
# File lib/broadside/target.rb, line 93 def family "#{Broadside.config.application}_#{@name}" end
service_config_for_update()
click to toggle source
# File lib/broadside/target.rb, line 105 def service_config_for_update service_config.try(:except, *CREATE_ONLY_SERVICE_ATTRIBUTES) end
to_h()
click to toggle source
# File lib/broadside/target.rb, line 97 def to_h { Target: @name, Image: "#{@docker_image}:#{@tag || 'no_tag_configured'}", Cluster: @cluster } end