gantree 0.2.6 → 0.2.7

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: 1b338332d981a5b7f9fdf5481a6586ab2b9f8bed
4
- data.tar.gz: db5516035b15ed2d4cbc653caed83dea5ddb5057
3
+ metadata.gz: 708602c71b4d2127bfe9f5d4208e61b07a42d372
4
+ data.tar.gz: 8c8d70dd8489294006bb77bebb60feccda1363fd
5
5
  SHA512:
6
- metadata.gz: 70ef9e1a8f769ca67e3f260a1cf4eec77a8600c1a0b5f425f44755e17c79a92efd55a23ff62d61861032c9b5427ffb1db4cd82be2cf70301834b9ed386353d91
7
- data.tar.gz: 328ebe29c9e08162c0ec4a5a798b9fdd874aa36317a9ff384e18b5858910a25da7a2fa0ebb74fb50e379101ef4fee3154977b8480081af46bfbfcb0a8e9cef1f
6
+ metadata.gz: e4b417f896a2d39ea17d173e558c04e57dadd3cbdb95fbb1c8cb23cc9fcb1a0e8a42d120fd77fed798b93d4429725077ba32bb8ccf7450558e445c4d2ceb506e
7
+ data.tar.gz: f8ec809fd5da2d4b7809360352c125c01f556b03ac1940a9c37e8d8ac127aee444266b9b702ba01a107bce40060bde48e6eebb7fd717ea7d7e7012e74396bb16
data/README.md CHANGED
@@ -89,7 +89,7 @@ gantre create your_app_name -e your_env_name
89
89
  Allow defaults for commands to be set in a json file
90
90
  ```json
91
91
  {
92
- "ebextensions" : "configs/.ebextensions",
92
+ "ebextensions" : "git@github.com:br/.ebextensions.git",
93
93
  "default_instance_size" : "m3.medium"
94
94
  }
95
95
  ```
@@ -1,4 +1,5 @@
1
1
  $:.unshift(File.expand_path("../", __FILE__))
2
+ require "gantree/base"
2
3
  require "gantree/version"
3
4
  require "gantree/deploy"
4
5
  require "gantree/init"
@@ -6,4 +7,4 @@ require "gantree/cfn"
6
7
 
7
8
  module Gantree
8
9
  autoload :CLI, 'gantree/cli'
9
- end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Gantree
2
+ class Base
3
+ def print_options
4
+ @options.each do |param, value|
5
+ puts "#{param}: #{value}"
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -5,7 +5,7 @@ require_relative 'cfn/beanstalk'
5
5
  require_relative 'cfn/resources'
6
6
 
7
7
  module Gantree
8
- class Stack
8
+ class Stack < Base
9
9
  def initialize stack_name,options
10
10
  check_credentials
11
11
  AWS.config(
@@ -40,6 +40,7 @@ module Gantree
40
40
 
41
41
  def create
42
42
  @options[:rds_enabled] = rds_enabled? if @options[:rds]
43
+ print_options
43
44
  create_cfn_if_needed
44
45
  create_all_templates
45
46
  upload_templates unless @options[:dry_run]
@@ -18,10 +18,12 @@ module Gantree
18
18
  end
19
19
 
20
20
  desc "init IMAGE", "create a dockerrun for your IMAGE"
21
- method_option :user, :aliases => "-u", :desc => "user credentials for private repo"
22
- method_option :port, :aliases => "-p", :desc => "port of running application"
21
+ method_option :user , :aliases => "-u", :desc => "user credentials for private repo"
22
+ method_option :port , :aliases => "-p", :desc => "port of running application"
23
+ method_option :bucket , :aliases => "-b", :desc => "set bucket name, default is 'docker-cfgs'"
24
+ option :dry_run, :aliases => "-d", :desc => "do not actually upload to s3 bucket"
23
25
  def init image
24
- Gantree::Init.new(image,options).run
26
+ Gantree::Init.new(image, options).run
25
27
  end
26
28
 
27
29
  desc "create APP", "create a cfn stack"
@@ -3,7 +3,7 @@ require 'archive/zip'
3
3
  require_relative 'notification'
4
4
 
5
5
  module Gantree
6
- class Deploy
6
+ class Deploy < Base
7
7
 
8
8
  def initialize app,options
9
9
  @options = options
@@ -19,7 +19,9 @@ module Gantree
19
19
  end
20
20
 
21
21
  def run
22
- puts "Deploying #{@app}"
22
+ puts "Deploying #{@env} on #{@app}"
23
+ print_options
24
+ return if @options[:dry_run]
23
25
  @packeged_version = create_version_files
24
26
  upload_to_s3 if @options[:dry_run].nil?
25
27
  clean_up
@@ -32,7 +34,6 @@ module Gantree
32
34
  end
33
35
 
34
36
  private
35
-
36
37
  def upload_to_s3
37
38
  key = File.basename(@packeged_version)
38
39
  check_version_bucket
@@ -3,10 +3,12 @@ require 'aws-sdk-v1'
3
3
 
4
4
  module Gantree
5
5
 
6
- class Init
6
+ class Init < Base
7
7
  def initialize image,options
8
- @image = image
9
- @options = options
8
+ @image = image
9
+ @options = options
10
+ @bucket_name = @options.bucket || "docker-cfgs"
11
+
10
12
  AWS.config(
11
13
  :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
12
14
  :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'])
@@ -15,15 +17,16 @@ module Gantree
15
17
 
16
18
  def run
17
19
  puts "initialize image #{@image}"
18
- puts "with user #{@options.user}" if @options.user
20
+ print_options
21
+
19
22
  FileUtils.rm("Dockerrun.aws.json") if File.exist?("Dockerrun.aws.json")
20
- create_docker_config_folder
23
+ create_docker_config_folder unless @options.dry_run?
21
24
  create_dockerrun
22
- upload_docker_config if @options.user
25
+ upload_docker_config if @options.user && !@options.dry_run?
23
26
  end
24
27
 
25
28
  def create_docker_config_folder
26
- bucket = @s3.buckets.create("docker-cfgs")
29
+ bucket = @s3.buckets.create(@bucket_name) unless @s3.buckets[@bucket_name].exists?
27
30
  end
28
31
 
29
32
  def dockerrun_object
@@ -42,7 +45,7 @@ module Gantree
42
45
  }
43
46
  if @options.user
44
47
  docker["Authentication"] = {
45
- Bucket: "docker-cfgs",
48
+ Bucket: @bucket_name,
46
49
  Key: "#{@options.user}.dockercfg"
47
50
  }
48
51
  end
@@ -58,8 +61,8 @@ module Gantree
58
61
  filename = "#{ENV['HOME']}/#{@options.user}.dockercfg"
59
62
  FileUtils.cp("#{ENV['HOME']}/.dockercfg", "#{ENV['HOME']}/#{@options.user}.dockercfg")
60
63
  key = File.basename(filename)
61
- @s3.buckets["docker-cfgs"].objects[key].write(:file => filename)
64
+ @s3.buckets[@bucket_name].objects[key].write(:file => filename)
62
65
  end
63
-
64
66
  end
65
67
  end
68
+
@@ -1,3 +1,3 @@
1
1
  module Gantree
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
@@ -17,32 +17,49 @@ describe Gantree::CLI do
17
17
 
18
18
  describe "init" do
19
19
  it "should create a new dockerrun for a private repo" do
20
- out = execute("bin/gantree init -u #{@user} #{@owner}/#{@repo}:#{@tag}")
20
+ out = execute("bin/gantree init -u #{@user} #{@owner}/#{@repo}:#{@tag} --dry-run")
21
21
  expect(out).to include "initialize image"
22
22
  expect(File.exist?("Dockerrun.aws.json")).to be true
23
23
  expect(IO.read("Dockerrun.aws.json").include? @user)
24
24
  end
25
25
 
26
26
  it "should create a new dockerrun for a public repo" do
27
- out = execute("bin/gantree init #{@owner}/#{@repo}:#{@tag}")
27
+ out = execute("bin/gantree init #{@owner}/#{@repo}:#{@tag} --dry-run")
28
28
  expect(out).to include "initialize image"
29
29
  expect(File.exist?("Dockerrun.aws.json")).to be true
30
30
  end
31
+
32
+ it "specifies the bucket" do
33
+ out = execute("bin/gantree init -u #{@user} -b my_bucket #{@owner}/#{@repo}:#{@tag} --dry-run")
34
+ expect(out).to include "bucket: my_bucket"
35
+ end
31
36
  end
32
37
 
33
38
  describe "deploy" do
34
39
  it "should deploy images" do
40
+ execute("bin/gantree init #{@owner}/#{@repo}:#{@tag} --dry-run")
35
41
  out = execute("bin/gantree deploy #{@env} --dry-run --silent")
36
- expect(out).to include("Deploying")
42
+ expect(out).to include("Deploying stag-knarr-app-s1 on knarr-stag-s1")
43
+ expect(out).to include("dry_run: dry_run")
44
+ expect(out).to include("silent: silent")
37
45
  end
46
+
38
47
  it "should deploy images with remote extensions" do
39
48
  out = execute("bin/gantree deploy #{@env} -x 'git@github.com:br/.ebextensions' --dry-run --silent")
40
- expect(out).to include("Deploying")
49
+ expect(out).to include("Deploying stag-knarr-app-s1 on knarr-stag-s1")
50
+ expect(out).to include("ext: git@github.com:br/.ebextensions")
51
+ expect(out).to include("dry_run: dry_run")
52
+ expect(out).to include("silent: silent")
41
53
  end
54
+
42
55
  it "should deploy images with remote extensions on a branch" do
43
56
  out = execute("bin/gantree deploy #{@env} -x 'git@github.com:br/.ebextensions:basic' --dry-run --silent")
44
- expect(out).to include("Deploying")
57
+ expect(out).to include("Deploying stag-knarr-app-s1 on knarr-stag-s1")
58
+ expect(out).to include("ext: git@github.com:br/.ebextensions:basic")
59
+ expect(out).to include("dry_run: dry_run")
60
+ expect(out).to include("silent: silent")
45
61
  end
62
+
46
63
  it "should notify slack of deploys" do
47
64
  out = execute("bin/gantree deploy #{@env} --dry-run")
48
65
  expect(out).to include("Deploying")
@@ -52,27 +69,29 @@ describe Gantree::CLI do
52
69
  describe "create" do
53
70
  it "should create clusters" do
54
71
  out = execute("bin/gantree create #{@env} --dry-run")
55
- beanstalk = JSON.parse(IO.read("cfn/#{@app}-beanstalk.cfn.json"))["Resources"]["ConfigurationTemplate"]["Properties"]["SolutionStackName"]
56
- expect(beanstalk).to include "Docker 1.2.0"
57
- expect(out).to include "Generating"
58
- expect_all_templates_created(out)
72
+ expect(out).to include "instance_size: t1.micro"
73
+ expect(out).to include "stack_name: stag-knarr-app-s1"
74
+ expect(out).to include "cfn_bucket: br-templates"
75
+ expect(out).to include "env: knarr-stag-s1"
76
+ expect(out).to include "env_type: stag"
77
+ expect(out).to include "stag_domain: sbleacherreport.com"
78
+ expect(out).to include "prod_domain: bleacherreport.com"
59
79
  end
60
80
 
61
81
  it "should create clusters with any docker version" do
62
82
  out = execute("bin/gantree create #{@env} --dry-run --docker-version '64bit Amazon Linux 2014.03 v1.0.1 running Docker 1.0.0'")
63
- beanstalk = JSON.parse(IO.read("cfn/#{@app}-beanstalk.cfn.json"))["Resources"]["ConfigurationTemplate"]["Properties"]["SolutionStackName"]
64
- expect(beanstalk).to include "Docker 1.0.0"
65
- expect_all_templates_created(out)
83
+ expect(out).to include "docker_version: 64bit Amazon Linux 2014.03 v1.0.1 running Docker 1.0.0"
66
84
  end
67
85
 
68
86
  it "should create clusters with databases" do
69
87
  out = execute("bin/gantree create #{@env} --dry-run --rds pg")
70
- expect(out).to_not include "RDS is not enabled, no DB created"
88
+ expect(out).to include "rds: pg"
89
+ expect(out).to include "rds_enabled: true"
71
90
  end
72
91
 
73
92
  it "should create dupliacte clusters from local cfn" do
74
93
  out = execute("bin/gantree create stag-knarr-app-s2 --dupe #{@env} --dry-run")
75
- expect(out).to include "Duplicating"
94
+ expect(out).to include "dupe: stag-knarr-app-s1"
76
95
  end
77
96
  end
78
97
 
@@ -89,10 +108,5 @@ describe Gantree::CLI do
89
108
  expect(out).to include "Deleting"
90
109
  end
91
110
  end
92
-
93
- def expect_all_templates_created(out)
94
- expect(out).to include "#{@app}-master.cfn.json"
95
- expect(out).to include "#{@app}-beanstalk.cfn.json"
96
- expect(out).to include "#{@app}-resources.cfn.json"
97
- end
98
111
  end
112
+
@@ -29,11 +29,8 @@ describe "#Deploy" do
29
29
  describe ".auto_detect_app_role" do
30
30
  it "sets app roles if enabled" do
31
31
  options = { autodetect_app_role: true}
32
- Dir.mkdir("roles") unless Dir.exist?("roles")
33
- IO.write("roles/listener", "bundle exec rake:listener")
34
32
  deploy = Gantree::Deploy.new("stag-knarr-listener-s1",options)
35
- puts deploy.instance_eval { auto_detect_app_role }
36
- FileUtils.rm_r "roles"
33
+ puts deploy.instance_eval { autodetect_app_role }
37
34
  end
38
35
  end
39
36
  end
@@ -6,6 +6,9 @@
6
6
  ENV['VCR'] ? ENV['VCR'] : ENV['VCR'] = '1'
7
7
  ENV['TEST'] = '1'
8
8
  ENV['CODECLIMATE_REPO_TOKEN'] = ENV['CODECLIMATE_GANTREE_TOKEN']
9
+ ENV['AWS_SECRET_ACCESS_KEY'] = 'asdfasdf2394230434'
10
+ ENV['AWS_ACCESS_KEY_ID'] = 'adsfasdf984443df'
11
+
9
12
 
10
13
  require "codeclimate-test-reporter"
11
14
  CodeClimate::TestReporter.start
@@ -40,6 +43,10 @@ RSpec.configure do |c|
40
43
  # example.run
41
44
  # end if ENV['VCR'] == '1'
42
45
  #end
46
+ c.after(:all) do
47
+ FileUtils.rm_rf("Dockerrun.aws.json")
48
+ FileUtils.rm_rf("*.zip")
49
+ end
43
50
  end
44
51
 
45
52
  #VCR.configure do |config|
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.6
4
+ version: 0.2.7
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-31 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -240,6 +240,7 @@ files:
240
240
  - bin/gantree
241
241
  - gantree.gemspec
242
242
  - lib/gantree.rb
243
+ - lib/gantree/base.rb
243
244
  - lib/gantree/cfn.rb
244
245
  - lib/gantree/cfn/beanstalk.rb
245
246
  - lib/gantree/cfn/master.rb