Class: CF::Deploy
- Inherits:
-
Object
show all
- Defined in:
- lib/cf/deploy.rb,
lib/cf/deploy/config.rb,
lib/cf/deploy/version.rb,
lib/cf/deploy/commands.rb,
lib/cf/deploy/blue_green.rb,
lib/cf/deploy/env_config.rb
Defined Under Namespace
Classes: BlueGreen, Commands, Config, EnvConfig
Constant Summary
collapse
- VERSION =
'0.1.8'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config_task) ⇒ Deploy
18
19
20
21
22
|
# File 'lib/cf/deploy.rb', line 18
def initialize(config_task)
@config_task = config_task
@config = config_task[:config]
@cf = config_task[:commands]
end
|
Instance Attribute Details
#cf ⇒ Object
Returns the value of attribute cf.
16
17
18
|
# File 'lib/cf/deploy.rb', line 16
def cf
@cf
end
|
#config ⇒ Object
Returns the value of attribute config.
16
17
18
|
# File 'lib/cf/deploy.rb', line 16
def config
@config
end
|
#config_task ⇒ Object
Returns the value of attribute config_task.
16
17
18
|
# File 'lib/cf/deploy.rb', line 16
def config_task
@config_task
end
|
Class Method Details
.rake_tasks!(&block) ⇒ Object
11
12
13
|
# File 'lib/cf/deploy.rb', line 11
def rake_tasks!(&block)
new(config: Config.new(&block), commands: Commands.new).rake_tasks!
end
|
Instance Method Details
#define_deploy_task(env, deployment) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/cf/deploy.rb', line 47
def define_deploy_task(env, deployment)
task = Rake::Task.define_task(deployment[:task_name] => env[:deps]) do
unless cf.push(deployment[:manifest])
raise "Failed to deploy #{deployment}"
end
env[:routes].reject { |r| r[:flip] == true }.each do |route|
deployment[:app_names].each do |app_name|
cf.map_route(route, app_name)
end
end
deployment[:apps].each do |app|
unless env[:runtime_memory].nil? and app[:runtime_memory].nil?
cf.scale_memory(app[:name], env[:runtime_memory] || app[:runtime_memory])
end
unless env[:runtime_instances].nil? and app[:runtime_instances].nil?
cf.scale_instances(app[:name], env[:runtime_instances] || app[:runtime_instances])
end
end
end
task.add_description("Deploy #{deployment[:app_names].join(', ')}")
end
|
#define_deploy_tasks(env) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/cf/deploy.rb', line 39
def define_deploy_tasks(env)
BlueGreen.new(env, config_task) if env[:deployments].size > 1
env[:deployments].each do |deployment|
define_deploy_task(env, deployment)
end
end
|
#define_login_task ⇒ Object
32
33
34
35
36
37
|
# File 'lib/cf/deploy.rb', line 32
def define_login_task
return Rake::Task['cf:login'] if Rake::Task.task_defined?('cf:login')
task = Rake::Task.define_task('cf:login') { cf.login(config) }
task.add_description('Login to cf command line')
end
|
#deploy_tasks ⇒ Object
28
29
30
|
# File 'lib/cf/deploy.rb', line 28
def deploy_tasks
config[:environments].map { |env| define_deploy_tasks(env) }
end
|
#rake_tasks! ⇒ Object
24
25
26
|
# File 'lib/cf/deploy.rb', line 24
def rake_tasks!
[define_login_task].concat(deploy_tasks)
end
|