gantree 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 989d5b1c7d4cf9dc43ea5878da05220175efd519
4
- data.tar.gz: 77b5026d514ad52ecba27300a29b823fd7658154
3
+ metadata.gz: cce358ed6f7b1f92b6cf7e154bd20485153ef893
4
+ data.tar.gz: e3553dedfb9b4d7464b8ce3651b88382e9c12df4
5
5
  SHA512:
6
- metadata.gz: b9ef6e67aa0f145b87158ddabd93bb56f44824bf76176e45ac27b0199bb5364552515ea401e2b4b85f1bd64e197b364b99474eb08ab8438fa9c1651fa25bdb89
7
- data.tar.gz: 53b49e2886b4d5fe4cd6bd0d6a39770c8d25407ac9da4e82c2e672af66f465426ed120a2ce04656f913aa3853e8b72b740f3a1013ed8d3b34fb7f67619aa3599
6
+ metadata.gz: d3b793e7936d386df9306277c279804f131c1dd338bc66a3b5300bd1803abb10b9683b03000db2cfb0e7bd8d2993f13cfcbeff932b688c04ff8dbf08eaed3253
7
+ data.tar.gz: f5ab580a8933cb291db0c557b0defd08428a203a167dd66eda27a34cedf6d9de5b1e80f429d8c9f40122a946c5f885a59ed5714d27c970104eff915f8001a9b5
data/lib/gantree/cfn.rb CHANGED
@@ -6,6 +6,8 @@ require_relative 'cfn/resources'
6
6
  module Gantree
7
7
  class Stack
8
8
  def initialize stack_name,options
9
+ puts "*** CREATE OPTIONS"
10
+ puts options
9
11
  check_credentials
10
12
  AWS.config(
11
13
  :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
@@ -28,10 +30,10 @@ module Gantree
28
30
  env: @env,
29
31
  stag_domain: "sbleacherreport.com",
30
32
  prod_domain: "bleacherreport.com",
31
- rds_enabled: rds_enabled?,
32
33
  env_type: env_type,
33
34
  }
34
35
  @options = options.merge(additional_options)
36
+ @options[:rds_enabled] = rds_enabled?
35
37
  end
36
38
 
37
39
  def check_credentials
@@ -45,6 +47,8 @@ module Gantree
45
47
  generate("beanstalk", BeanstalkTemplate.new(@options).create)
46
48
  generate("resources", ResourcesTemplate.new(@options).create)
47
49
  puts "All templates created"
50
+ puts "*** OPTIONS + ADDITIONAL pt 2"
51
+ puts @options
48
52
  create_aws_cfn_stack if @options[:dry_run].nil?
49
53
  end
50
54
 
@@ -84,10 +88,10 @@ module Gantree
84
88
  end
85
89
 
86
90
  def rds_enabled?
87
- if @rds == nil
91
+ if @options[:rds] == nil
88
92
  puts "RDS is not enabled, no DB created"
89
93
  false
90
- elsif @rds == "pg" || @rds == "mysql"
94
+ elsif @options[:rds] == "pg" || @rds == "mysql"
91
95
  puts "RDS is enabled, creating DB"
92
96
  true
93
97
  else
data/lib/gantree/cli.rb CHANGED
@@ -12,7 +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
  def deploy app
15
- Gantree::Deploy.new(app, options.merge(gantreecfg)).run
15
+ Gantree::Deploy.new(app, merge_defaults(options)).run
16
16
  end
17
17
 
18
18
  desc "init IMAGE", "create a dockerrun for your IMAGE"
@@ -29,16 +29,19 @@ module Gantree
29
29
  option :dry_run, :aliases => "-d", :desc => "do not actually create the stack"
30
30
  option :docker_version, :desc => "set the version of docker to use as solution stack"
31
31
  def create app
32
- Gantree::Stack.new(app, options.merge(gantreecfg)).create
32
+ Gantree::Stack.new(app, merge_defaults(options)).create
33
33
  end
34
34
 
35
35
  protected
36
- def gantreecfg
37
- if File.exist?(".gantreecfg")
38
- defaults = JSON.parse(IO.read(".gantreecfg"))
39
- else
40
- {}
41
- end
42
- end
36
+
37
+ def merge_defaults(options={})
38
+ if File.exist?(".gantreecfg")
39
+ defaults = JSON.parse(File.open(".gantreecfg").read)
40
+ hash = defaults.merge(options)
41
+ Hash[hash.map{ |k, v| [k.to_sym, v] }]
42
+ else
43
+ Hash[options.map{ |k, v| [k.to_sym, v] }]
44
+ end
45
+ end
43
46
  end
44
47
  end
@@ -35,27 +35,17 @@ module Gantree
35
35
  end
36
36
 
37
37
  def create_eb_version
38
- begin
39
- @eb.create_application_version({
40
- :application_name => @app,
41
- :version_label => @packeged_version,
42
- :source_bundle => {
43
- :s3_bucket => "#{@app}-versions",
44
- :s3_key => @packeged_version
45
- }
46
- })
47
- rescue AWS::ElasticBeanstalk::Errors::InvalidParameterValue
48
- puts "Version already exists, recreating..."
49
- begin
50
- @eb.delete_application_version({
51
- :application_name => @app,
52
- :version_label => @packeged_version,
53
- :delete_source_bundle => false
54
- })
55
- retry
56
- rescue AWS::ElasticBeanstalk::Errors::InvalidParameterValue
57
- puts "No Application named #{@app} found"
58
- end
38
+ begin
39
+ @eb.create_application_version({
40
+ :application_name => @app,
41
+ :version_label => @packeged_version,
42
+ :source_bundle => {
43
+ :s3_bucket => "#{@app}-versions",
44
+ :s3_key => @packeged_version
45
+ }
46
+ })
47
+ rescue AWS::ElasticBeanstalk::Errors::InvalidParameterValue => e
48
+ puts "No Application named #{@app} found #{e}"
59
49
  end
60
50
  end
61
51
 
@@ -71,11 +61,12 @@ module Gantree
71
61
  end
72
62
 
73
63
  def create_version_files
64
+ unique_hash = (0...8).map { (65 + rand(26)).chr }.join
74
65
  branch = `git rev-parse --abbrev-ref HEAD`
75
66
  puts "branch: #{branch}"
76
67
  hash = `git rev-parse --verify --short #{branch}`.strip
77
68
  puts "hash #{hash}"
78
- version = "#{@env}-#{hash}"
69
+ version = "#{@env}-#{hash}-#{unique_hash}"
79
70
  puts "version: #{version}"
80
71
  dockerrun = "Dockerrun.aws.json"
81
72
  set_tag_to_deploy(dockerrun) if @options[:tag]
@@ -107,6 +98,7 @@ module Gantree
107
98
 
108
99
  def repo?
109
100
  if @ext.include? "github"
101
+ puts "Cloning: #{@ext}..."
110
102
  true
111
103
  else
112
104
  false
@@ -1,3 +1,3 @@
1
1
  module Gantree
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/spec/lib/cli_spec.rb CHANGED
@@ -32,15 +32,15 @@ describe Gantree::CLI do
32
32
 
33
33
  describe "deploy" do
34
34
  it "should deploy images" do
35
- out = execute("bin/gantree deploy #{@env}")
35
+ out = execute("bin/gantree deploy #{@env} --dry-run")
36
36
  expect(out).to include("Deploying")
37
37
  end
38
38
  it "should deploy images with remote extensions" do
39
- out = execute("bin/gantree deploy #{@env} -x 'git@github.com:br/.ebextensions'")
39
+ out = execute("bin/gantree deploy #{@env} -x 'git@github.com:br/.ebextensions' --dry-run")
40
40
  expect(out).to include("Deploying")
41
41
  end
42
42
  it "should deploy images with remote extensions on a branch" do
43
- out = execute("bin/gantree deploy #{@env} -x 'git@github.com:br/.ebextensions:feature'")
43
+ out = execute("bin/gantree deploy #{@env} -x 'git@github.com:br/.ebextensions:basic' --dry-run")
44
44
  expect(out).to include("Deploying")
45
45
  end
46
46
  end
@@ -48,16 +48,22 @@ describe Gantree::CLI do
48
48
  describe "create" do
49
49
  it "should create clusters" do
50
50
  out = execute("bin/gantree create #{@env} --dry-run")
51
- beanstalk = IO.read("cfn/#{@app}-beanstalk.cfn.json")
51
+ beanstalk = JSON.parse(IO.read("cfn/#{@app}-beanstalk.cfn.json"))["Resources"]["ConfigurationTemplate"]["Properties"]["SolutionStackName"]
52
52
  expect(beanstalk).to include "Docker 1.2.0"
53
53
  expect(out).to include "All templates created"
54
+ expect(out).to include "RDS is not enabled, no DB created"
54
55
  end
55
56
 
56
57
  it "should create clusters with any docker version" do
57
58
  out = execute("bin/gantree create #{@env} --dry-run --docker-version '64bit Amazon Linux 2014.03 v1.0.1 running Docker 1.0.0'")
58
- beanstalk = IO.read("cfn/#{@app}-beanstalk.cfn.json")
59
+ beanstalk = JSON.parse(IO.read("cfn/#{@app}-beanstalk.cfn.json"))["Resources"]["ConfigurationTemplate"]["Properties"]["SolutionStackName"]
59
60
  expect(beanstalk).to include "Docker 1.0.0"
60
61
  expect(out).to include "All templates created"
61
62
  end
63
+
64
+ it "should create clusters with databases" do
65
+ out = execute("bin/gantree create stag-knarr-app-s7 --dry-run --rds pg")
66
+ expect(out).to_not include "RDS is not enabled, no DB created"
67
+ end
62
68
  end
63
69
  end
@@ -3,7 +3,7 @@ require_relative '../../lib/gantree/deploy'
3
3
 
4
4
  describe "#Deploy" do
5
5
  before(:all) do
6
- @env = "stag-app-knarr-s1"
6
+ @env = "stag-knarr-app-s1"
7
7
  @owner = "bleacher"
8
8
  @repo = "cauldron"
9
9
  @tag = "master"
@@ -12,17 +12,19 @@ describe "#Deploy" do
12
12
 
13
13
  describe ".get_ext_branch" do
14
14
  it "returns branch name of repo url" do
15
- options = { ext: "git@github.com:br/.ebextensions:feature" }
15
+ options = { ext: "git@github.com:br/.ebextensions:basic" }
16
16
  deploy = Gantree::Deploy.new(@env,options)
17
- expect(deploy.instance_eval { get_ext_branch }).to eq "feature"
17
+ expect(deploy.instance_eval { get_ext_branch }).to eq "basic"
18
18
  end
19
19
  end
20
20
 
21
21
  describe ".get_ext_repo" do
22
22
  it "returns just the repo url" do
23
- options = { ext: "git@github.com:br/.ebextensions:feature" }
23
+ options = { ext: "git@github.com:br/.ebextensions:basic" }
24
24
  deploy = Gantree::Deploy.new(@env,options)
25
25
  puts deploy.instance_eval { get_ext_repo }
26
26
  end
27
- end
27
+ end
28
+
29
+ describe ".create_"
28
30
  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.1.8
4
+ version: 0.1.9
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-10 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor