Class: Jack::Create
- Inherits:
-
Object
show all
- Includes:
- Util
- Defined in:
- lib/jack/create.rb
Instance Method Summary
collapse
Methods included from Util
#app_name_convention, #aws_bin, #check_aws_setup, #confirm, #eb, #eb_base_flags, #eb_bin, #ensure_folder_exist, #get_answer, #get_region, #settings, #sh
Constructor Details
#initialize(options = {}) ⇒ Create
Returns a new instance of Create.
7
8
9
10
11
12
|
# File 'lib/jack/create.rb', line 7
def initialize(options={})
@options = options
@root = options[:root] || '.'
@env_name = options[:env_name]
@app_name = options[:app] || app_name_convention(@env_name)
end
|
Instance Method Details
#app_exist? ⇒ Boolean
27
28
29
30
31
|
# File 'lib/jack/create.rb', line 27
def app_exist?
return true if @options[:noop]
r = eb.describe_applications
r.applications.collect(&:application_name).include?(@app_name)
end
|
#build_command ⇒ Object
38
39
40
41
42
|
# File 'lib/jack/create.rb', line 38
def build_command
@cfg = upload_cfg
flags = settings.create_flags
"#{eb_bin} create#{eb_base_flags} --sample --nohang #{flags} #{@cfg}#{cname}#{@env_name}"
end
|
#cname ⇒ Object
52
53
54
|
# File 'lib/jack/create.rb', line 52
def cname
"--cname #{@env_name} "
end
|
#create_app ⇒ Object
21
22
23
24
25
|
# File 'lib/jack/create.rb', line 21
def create_app
eb.create_application(
application_name: @app_name
) unless app_exist?
end
|
#create_env ⇒ Object
33
34
35
36
|
# File 'lib/jack/create.rb', line 33
def create_env
command = build_command
sh(command, @options)
end
|
#run ⇒ Object
14
15
16
17
18
19
|
# File 'lib/jack/create.rb', line 14
def run
check_aws_setup
create_app
EbConfig::Create.new(@options).sync unless @options[:noop]
create_env
end
|
#upload_cfg ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/jack/create.rb', line 44
def upload_cfg
@upload = Config::Upload.new(@options)
if @upload.local_cfg_exist?
@upload.upload
cfg = "--cfg #{@upload.upload_name} "
end
end
|