beanstalkify 0.0.4 → 0.0.5

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beanstalkify (0.0.4)
4
+ beanstalkify (0.0.5)
5
5
  aws-sdk
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -17,7 +17,7 @@ Create a file called `credentials.yml`, with the following format:
17
17
 
18
18
  # Running
19
19
 
20
- beanstalkify -k credentials.yml -a app-version.zip -s "64bit Amazon Linux running Node.js" -e env [-c config.yml]
20
+ beanstalkify -k credentials.yml -a app-version.zip -s "64bit Amazon Linux running Node.js" -e env [-n my-awesome-app] [-c config.yml]
21
21
 
22
22
  Should do the following
23
23
 
data/bin/beanstalkify CHANGED
@@ -20,6 +20,9 @@ OptionParser.new do |opts|
20
20
  opts.on("-s", "--stack [stack]", "Stack to provision (e.g. '64bit Amazon Linux running Node.js')") do |v|
21
21
  options[:stack] = v
22
22
  end
23
+ opts.on("-n", "--cname [cname]", "CNAME prefix (e.g. my-awesome-app)") do |v|
24
+ options[:cname] = v
25
+ end
23
26
  opts.on("-c", "--config [file]", "Configuration overrides for the environment (optional)") do |v|
24
27
  options[:config] = YAML.load_file(v)
25
28
  end
@@ -30,13 +33,13 @@ end.parse!
30
33
 
31
34
  required_params = [:credentials, :archive, :environment, :stack]
32
35
  unless (required_params - options.keys).empty?
33
- puts "Example usage: beanstalkify -k credentials.yml -a AppName-version.zip -e Test -s '64bit Amazon Linux running Node.js' [-c config.yml] [-o info.yml]"
36
+ puts "Example usage: beanstalkify -k credentials.yml -a AppName-version.zip -e Test -s '64bit Amazon Linux running Node.js' [-c config.yml] [-n my-awesome-app] [-o info.yml]"
34
37
  exit
35
38
  end
36
39
 
37
40
  Beanstalkify::Beanstalk.configure! options[:credentials]
38
41
 
39
- app = Beanstalkify::Application.new(options[:stack], options[:config] || [])
42
+ app = Beanstalkify::Application.new(options[:stack], options[:cname], options[:config] || [])
40
43
  archive = Beanstalkify::Archive.new(options[:archive])
41
44
  environment = Beanstalkify::Environment.new(archive, options[:environment])
42
45
 
@@ -44,4 +47,4 @@ deployment_info = app.deploy! archive, environment
44
47
 
45
48
  File.open(options[:outfile], 'w') { |f| f.puts deployment_info.to_yaml } if options[:outfile]
46
49
 
47
- raise("Deployed environment is not healthy") unless environment.healthy?
50
+ raise("Deployed environment is not healthy") unless environment.healthy?
@@ -4,8 +4,9 @@ module Beanstalkify
4
4
 
5
5
  # config is an array of hashes:
6
6
  # :namespace, :option_name, :value
7
- def initialize(stack, config)
7
+ def initialize(stack, cname, config)
8
8
  @stack = stack
9
+ @cname = cname
9
10
  @config = config.map { |c| Hash[c.map { |k, v| [k.to_sym,v]}] }
10
11
  end
11
12
 
@@ -16,7 +17,7 @@ module Beanstalkify
16
17
 
17
18
  if env.status.empty?
18
19
  puts "Creating stack '#{@stack}' for #{archive.app_name}-#{archive.version}..."
19
- env.create!(archive, @stack, @config)
20
+ env.create!(archive, @stack, @cname, @config)
20
21
  env.wait!("Launching")
21
22
  else
22
23
  puts "Deploying #{archive.version} to #{env.name}..."
@@ -22,14 +22,28 @@ module Beanstalkify
22
22
 
23
23
  # Assuming the archive has already been uploaded,
24
24
  # create a new environment with the app deployed onto the provided stack.
25
- def create!(archive, stack, settings=[])
26
- @beanstalk.create_environment({
25
+ def create!(archive, stack, cname, settings=[])
26
+ params = {
27
27
  :application_name => archive.app_name,
28
28
  :version_label => archive.version,
29
29
  :environment_name => self.name,
30
30
  :solution_stack_name => stack,
31
31
  :option_settings => settings
32
- })
32
+ }
33
+ if cname
34
+ if dns_available(cname)
35
+ params[:cname_prefix] = cname
36
+ else
37
+ puts "CNAME #{cname} is unavailable."
38
+ end
39
+ end
40
+ @beanstalk.create_environment(params)
41
+ end
42
+
43
+ def dns_available(cname)
44
+ @beanstalk.check_dns_availability({
45
+ :cname_prefix => cname
46
+ })[:available]
33
47
  end
34
48
 
35
49
  def status
@@ -1,3 +1,3 @@
1
1
  module Beanstalkify
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -4,8 +4,51 @@ require './lib/beanstalkify/environment'
4
4
  describe Beanstalkify::Environment do
5
5
  before do
6
6
  allow(Beanstalkify::Beanstalk).to receive(:api).and_return @beanstalk_api = double
7
- archive = Beanstalkify::Archive.new '/path/to/my/archive/app-name-version.zip'
8
- @env = Beanstalkify::Environment.new archive, "Test"
7
+ @archive = Beanstalkify::Archive.new '/path/to/my/archive/app-name-version.zip'
8
+ @env = Beanstalkify::Environment.new @archive, "Test"
9
+ end
10
+
11
+ it 'creates a new environment with params' do
12
+ masettings = {}
13
+ expect(@beanstalk_api).to receive(:create_environment).with(
14
+ :application_name => 'app-name',
15
+ :version_label => 'version',
16
+ :environment_name => 'app-name-Test',
17
+ :solution_stack_name => 'mastack',
18
+ :option_settings => masettings
19
+ ).and_return nil
20
+ @env.create! @archive, 'mastack', nil, masettings
21
+ end
22
+
23
+ it 'creates a new environment with a cname, if available' do
24
+ masettings = {}
25
+ expect(@beanstalk_api).to receive(:create_environment).with(
26
+ :application_name => 'app-name',
27
+ :version_label => 'version',
28
+ :environment_name => 'app-name-Test',
29
+ :solution_stack_name => 'mastack',
30
+ :cname_prefix => 'ma-cname',
31
+ :option_settings => masettings
32
+ ).and_return nil
33
+ expect(@beanstalk_api).to receive(:check_dns_availability).and_return(
34
+ :available => true
35
+ )
36
+ @env.create! @archive, 'mastack', 'ma-cname', masettings
37
+ end
38
+
39
+ it 'creates an environment without the cname, if the cname was unavailable' do
40
+ masettings = {}
41
+ expect(@beanstalk_api).to receive(:create_environment).with(
42
+ :application_name => 'app-name',
43
+ :version_label => 'version',
44
+ :environment_name => 'app-name-Test',
45
+ :solution_stack_name => 'mastack',
46
+ :option_settings => masettings
47
+ ).and_return nil
48
+ expect(@beanstalk_api).to receive(:check_dns_availability).and_return(
49
+ :available => false
50
+ )
51
+ @env.create! @archive, 'mastack', 'ma-cname', masettings
9
52
  end
10
53
 
11
54
  it 'prepends the application name because environment names must be unique within an AWS account' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beanstalkify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  segments:
85
85
  - 0
86
- hash: -4062555010533808231
86
+ hash: -3858020732862147076
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements:
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: -4062555010533808231
95
+ hash: -3858020732862147076
96
96
  requirements: []
97
97
  rubyforge_project:
98
98
  rubygems_version: 1.8.24