gantree 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d82d6a047ef518d49f7ae47631cfbe94dda93c7
4
- data.tar.gz: 214ebfd440d7ca4a7e4e1beb113abcc509f498c2
3
+ metadata.gz: c734667f4339044811f141d76836129103f7c2ac
4
+ data.tar.gz: 34709e12e3ac11f7d952bc4708bb5df84dbea6c6
5
5
  SHA512:
6
- metadata.gz: 8d7207313e3324499889bafe5e324d617a41c10a63c5c7ec8f6a71b4cdeebc456b48341a41139035101441f775ad3e8327505a1681501435373ea54282c1309c
7
- data.tar.gz: 200ade0101bce354214b37cbda53aae23cce24ec7e8d9beab3eda44071c8513076a5f8526b164bc8d9cbdcf8dab6831cc383aea3a7a552fffcc63649c3287003
6
+ metadata.gz: d4acf1fd2c8e4f94ac98c157f364c72dd883ab65554ab9a6ca4096aabbf777fdbea07f270f710017676acede0592830e5dc717b8007218173bb32a05c8185a9f
7
+ data.tar.gz: a1d4efdc55c637decaf16f87d13f6854efbb5bfc3c344fdbb4291372f49e4350031bf32172180f526013739228573df133abf2d7d9d92d877fccaf779e35e7c7
data/lib/gantree/cli.rb CHANGED
@@ -12,6 +12,7 @@ module Gantree
12
12
  method_option :ext, :aliases => "-x", :desc => "ebextensions folder/repo"
13
13
  option :dry_run, :aliases => "-d", :desc => "do not actually deploy the app"
14
14
  option :silent, :aliases => "-s", :desc => "mute notifications"
15
+ option :autodetect_app_role, :desc => "use naming convention to determin role"
15
16
  def deploy app
16
17
  Gantree::Deploy.new(app, merge_defaults(options)).run
17
18
  end
@@ -15,6 +15,7 @@ module Gantree
15
15
  @env = app
16
16
  @eb = AWS::ElasticBeanstalk::Client.new
17
17
  @s3 = AWS::S3.new
18
+ @dockerrun_file = "Dockerrun.aws.json"
18
19
  end
19
20
 
20
21
  def run
@@ -73,8 +74,8 @@ module Gantree
73
74
  puts "hash #{hash}"
74
75
  version = "#{@env}-#{hash}-#{unique_hash}"
75
76
  puts "version: #{version}"
76
- dockerrun = "Dockerrun.aws.json"
77
- set_tag_to_deploy(dockerrun) if @options[:tag]
77
+ auto_detect_app_role if @options[:autodetect_app_role] == true
78
+ set_tag_to_deploy if @options[:tag]
78
79
  unless ext?
79
80
  new_dockerrun = "#{version}-Dockerrun.aws.json"
80
81
  FileUtils.cp("Dockerrun.aws.json", new_dockerrun)
@@ -82,15 +83,28 @@ module Gantree
82
83
  else
83
84
  zip = "#{version}.zip"
84
85
  clone_repo if repo?
85
- Archive::Zip.archive(zip, ['.ebextensions/', dockerrun])
86
+ Archive::Zip.archive(zip, ['.ebextensions/', @dockerrun_file])
86
87
  zip
87
88
  end
88
89
  end
89
90
 
90
- def set_tag_to_deploy file
91
- docker = JSON.parse(IO.read(file))
92
- docker["Image"]["Name"].gsub!(/:(.*)$/, ":#{@options[:tag]}")
93
- IO.write(file,JSON.pretty_generate(docker))
91
+ def set_tag_to_deploy
92
+ docker = JSON.parse(IO.read(@dockerrun_file))
93
+ image = docker["Image"]["Name"]
94
+ image.gsub!(/:(.*)$/, ":#{@options[:tag]}")
95
+ IO.write(@dockerrun_file,JSON.pretty_generate(docker))
96
+ end
97
+
98
+ def auto_detect_app_role
99
+ role = @env.split('-')[2]
100
+ unless role == "app"
101
+ puts "Deploying app as a #{role}"
102
+ role_cmd = IO.read("roles/#{role}").gsub("\n",'')
103
+ docker = JSON.parse(IO.read(@dockerrun_file))
104
+ docker["Cmd"] = role_cmd
105
+ IO.write(@dockerrun_file,JSON.pretty_generate(docker))
106
+ puts "Setting role cmd to '#{role_cmd}'"
107
+ end
94
108
  end
95
109
 
96
110
  def ext?
@@ -1,3 +1,3 @@
1
1
  module Gantree
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -22,7 +22,18 @@ describe "#Deploy" do
22
22
  it "returns just the repo url" do
23
23
  options = { ext: "git@github.com:br/.ebextensions:basic" }
24
24
  deploy = Gantree::Deploy.new(@env,options)
25
- puts deploy.instance_eval { get_ext_repo }
25
+ expect(deploy.instance_eval { get_ext_repo }).to eq "git@github.com:br/.ebextensions"
26
+ end
27
+ end
28
+
29
+ describe ".auto_detect_app_role" do
30
+ it "sets app roles if enabled" do
31
+ options = { autodetect_app_role: true}
32
+ Dir.mkdir("roles") unless Dir.exist?("roles")
33
+ IO.write("roles/listener", "bundle exec rake:listener")
34
+ deploy = Gantree::Deploy.new("stag-knarr-listener-s1",options)
35
+ puts deploy.instance_eval { auto_detect_app_role }
36
+ FileUtils.rm_r "roles"
26
37
  end
27
38
  end
28
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gantree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-20 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor