engineyard-dnsimple 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/ChangeLog.md +6 -0
- data/Gemfile +4 -0
- data/README.md +65 -0
- data/Rakefile +24 -0
- data/bin/ey-dnsimple +17 -0
- data/engineyard-dnsimple.gemspec +35 -0
- data/features/assign_dns_to_environment.feature +24 -0
- data/features/step_definitions/common_steps.rb +168 -0
- data/features/step_definitions/dnsimple_steps.rb +9 -0
- data/features/step_definitions/ey_api_steps.rb +15 -0
- data/features/support/common.rb +29 -0
- data/features/support/engineyard.rb +24 -0
- data/features/support/env.rb +18 -0
- data/features/support/matchers.rb +11 -0
- data/lib/engineyard-dnsimple.rb +5 -0
- data/lib/engineyard-dnsimple/cli.rb +97 -0
- data/lib/engineyard-dnsimple/version.rb +5 -0
- data/spec/spec_helper.rb +11 -0
- metadata +273 -0
data/.rspec
ADDED
data/.travis.yml
ADDED
data/ChangeLog.md
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Simple DNS for Engine Yard AppCloud environments
|
2
|
+
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
Setup `ey` and `dnsimple` gems and credentials (see below).
|
6
|
+
|
7
|
+
$ ey-dnsimple assign myapp.com
|
8
|
+
Assigning myapp.com --> 1.2.3.4 (drnic/myapp_production)
|
9
|
+
Created A record for myapp.com (id:12345)
|
10
|
+
Complete!
|
11
|
+
Found 1 records for myapp.com
|
12
|
+
.myapp.com (A)-> 1.2.3.4 (ttl:, id:12345)
|
13
|
+
|
14
|
+
If an AppCloud environment cannot be automatically detected, explicitly pass -e or -a flags
|
15
|
+
like the `ey` CLI itself:
|
16
|
+
|
17
|
+
$ ey-dnsimple assign myapp.com -e myapp_production
|
18
|
+
|
19
|
+
## Setup
|
20
|
+
|
21
|
+
$ gem install engineyard-dnsimple
|
22
|
+
|
23
|
+
This will install the `engineyard` and `dnsimple-ruby` gems as well.
|
24
|
+
|
25
|
+
To setup credentials for AppCloud, run the following command for the first time and
|
26
|
+
you will be prompted for credentials:
|
27
|
+
|
28
|
+
$ ey environments --all
|
29
|
+
|
30
|
+
To setup credentials for DNSimple, create a file `~/.dnsimple` to look like:
|
31
|
+
|
32
|
+
username: DNSIMPLE_USERNAME
|
33
|
+
password: DNSIMPLE_PASSWORD
|
34
|
+
|
35
|
+
On Unix, make this file readable to you only:
|
36
|
+
|
37
|
+
$ chmod 600 ~/.dnsimple
|
38
|
+
|
39
|
+
Test you have DNSimple working:
|
40
|
+
|
41
|
+
$ dnsimple list
|
42
|
+
Found 1 domains:
|
43
|
+
myapp.com
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
Copyright (c) 2010 Engine Yard, Inc
|
48
|
+
|
49
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
50
|
+
of this software and associated documentation files (the "Software"), to deal
|
51
|
+
in the Software without restriction, including without limitation the rights
|
52
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
53
|
+
copies of the Software, and to permit persons to whom the Software is
|
54
|
+
furnished to do so, subject to the following conditions:
|
55
|
+
|
56
|
+
The above copyright notice and this permission notice shall be included in
|
57
|
+
all copies or substantial portions of the Software.
|
58
|
+
|
59
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
60
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
61
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
62
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
63
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
64
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
65
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
desc "Run all examples"
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
namespace :cucumber do
|
10
|
+
require 'cucumber/rake/task'
|
11
|
+
Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
|
12
|
+
t.cucumber_opts = "--tags @wip"
|
13
|
+
end
|
14
|
+
Cucumber::Rake::Task.new(:ok, 'Run features that should be working') do |t|
|
15
|
+
t.cucumber_opts = "--tags ~@wip"
|
16
|
+
end
|
17
|
+
task :all => [:ok, :wip]
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Alias for cucumber:ok'
|
21
|
+
task :cucumber => 'cucumber:ok'
|
22
|
+
|
23
|
+
desc "Specs and Cucumber features by default"
|
24
|
+
task :default => ["spec", "cucumber"]
|
data/bin/ey-dnsimple
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
4
|
+
require 'engineyard-dnsimple'
|
5
|
+
require 'engineyard-dnsimple/cli'
|
6
|
+
|
7
|
+
begin
|
8
|
+
EngineYard::DNSimple::CLI.start
|
9
|
+
rescue EY::Error => e
|
10
|
+
EY.ui.print_exception(e)
|
11
|
+
exit(1)
|
12
|
+
rescue Interrupt => e
|
13
|
+
puts
|
14
|
+
EY.ui.print_exception(e)
|
15
|
+
EY.ui.say("Quitting...")
|
16
|
+
exit(1)
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "engineyard-dnsimple/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "engineyard-dnsimple"
|
7
|
+
s.version = EngineYard::DNSimple::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Dr Nic Williams"]
|
10
|
+
s.email = ["drnicwilliams@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Configure your Engine Yard AppCloud environment and your DNSimple domain.}
|
13
|
+
s.description = %q{Easily configure your DNS with Engine Yard AppCloud via DNSimple.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "engineyard-dnsimple"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency("thor")
|
23
|
+
s.add_dependency("engineyard")
|
24
|
+
s.add_dependency("dnsimple-ruby")
|
25
|
+
|
26
|
+
s.add_development_dependency("rake", ["~> 0.9.0"])
|
27
|
+
s.add_development_dependency("cucumber", ["~> 0.10"])
|
28
|
+
s.add_development_dependency("rspec", ["~> 2.5"])
|
29
|
+
s.add_development_dependency("json", ["~>1.4.0"])
|
30
|
+
s.add_development_dependency("awesome_print")
|
31
|
+
s.add_development_dependency("realweb", '~>0.1.6')
|
32
|
+
s.add_development_dependency("open4")
|
33
|
+
s.add_development_dependency("sinatra")
|
34
|
+
s.add_development_dependency("fakeweb", "~>1.3.0")
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Assign DNS to environment IP address
|
2
|
+
I want to assign DNS record to an AppCloud environment IP address
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given I have setup my engineyard email/password for API access
|
6
|
+
And I have "two apps" in AppCloud
|
7
|
+
And I expect to create DNSimple::Record with attributes:
|
8
|
+
| domain | myapp.com |
|
9
|
+
| content | 174.129.7.113 |
|
10
|
+
| record_type | A |
|
11
|
+
|
12
|
+
Scenario: Assign DNS A Record to an environment
|
13
|
+
When I run local executable "ey-dnsimple" with arguments "assign myapp.com --account main --environment giblets"
|
14
|
+
Then I should see exactly
|
15
|
+
"""
|
16
|
+
Assigning myapp.com --> 174.129.7.113 (main/giblets)
|
17
|
+
Complete!
|
18
|
+
|
19
|
+
Found 1 records for myapp.com
|
20
|
+
.myapp.com (A)-> 174.129.7.113 (ttl:0, id:40424)
|
21
|
+
"""
|
22
|
+
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,168 @@
|
|
1
|
+
Given /^this project is active project folder/ do
|
2
|
+
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
|
6
|
+
ENV[env_var] = value
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /"(.*)" folder is deleted/ do |folder|
|
10
|
+
in_project_folder { FileUtils.rm_rf folder }
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
|
14
|
+
@stdout = StringIO.new
|
15
|
+
in_project_folder do
|
16
|
+
if Object.const_defined?("APP_ROOT")
|
17
|
+
APP_ROOT.replace(FileUtils.pwd)
|
18
|
+
else
|
19
|
+
APP_ROOT = FileUtils.pwd
|
20
|
+
end
|
21
|
+
run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
|
22
|
+
end
|
23
|
+
File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
|
24
|
+
@stdout.rewind
|
25
|
+
f << @stdout.read
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
30
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
31
|
+
in_project_folder do
|
32
|
+
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
37
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
38
|
+
in_project_folder do
|
39
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
44
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
45
|
+
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
46
|
+
in_project_folder do
|
47
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
When /^I invoke task "rake (.*)"/ do |task|
|
52
|
+
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
53
|
+
in_project_folder do
|
54
|
+
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Then /^folder "(.*)" (is|is not) created/ do |folder, is|
|
59
|
+
in_project_folder do
|
60
|
+
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
Then /^file "(.*)" (is|is not) created/ do |file, is|
|
65
|
+
in_project_folder do
|
66
|
+
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
Then /^file with name matching "(.*)" is created/ do |pattern|
|
71
|
+
in_project_folder do
|
72
|
+
Dir[pattern].should_not be_empty
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
|
77
|
+
in_project_folder do
|
78
|
+
actual_output = File.read(file)
|
79
|
+
(does == 'does') ?
|
80
|
+
actual_output.should(match(/#{regex}/)) :
|
81
|
+
actual_output.should_not(match(/#{regex}/))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
|
86
|
+
File.exists?(gem_file).should be_true
|
87
|
+
File.exists?(project_file).should be_true
|
88
|
+
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
89
|
+
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
90
|
+
project_file_contents.should == gem_file_contents
|
91
|
+
end
|
92
|
+
|
93
|
+
Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
|
94
|
+
actual_output = File.read(@stdout)
|
95
|
+
does_invoke == "does" ?
|
96
|
+
actual_output.should(match(/dependency\s+#{generator}/)) :
|
97
|
+
actual_output.should_not(match(/dependency\s+#{generator}/))
|
98
|
+
end
|
99
|
+
|
100
|
+
Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
|
101
|
+
actual_output = File.read(@stdout)
|
102
|
+
actual_output.should match(/#{opt1}/)
|
103
|
+
actual_output.should match(/#{opt2}/)
|
104
|
+
end
|
105
|
+
|
106
|
+
Then /^I should see "([^\"]*)"$/ do |text|
|
107
|
+
actual_output = File.read(@stdout)
|
108
|
+
actual_output.should contain(text)
|
109
|
+
end
|
110
|
+
|
111
|
+
Then /^I should see$/ do |text|
|
112
|
+
actual_output = File.read(@stdout)
|
113
|
+
actual_output.should contain(text)
|
114
|
+
end
|
115
|
+
|
116
|
+
Then /^I should not see$/ do |text|
|
117
|
+
actual_output = File.read(@stdout)
|
118
|
+
actual_output.should_not contain(text)
|
119
|
+
end
|
120
|
+
|
121
|
+
Then /^I should see exactly$/ do |text|
|
122
|
+
actual_output = File.read(@stdout)
|
123
|
+
actual_output.should == text
|
124
|
+
end
|
125
|
+
|
126
|
+
Then /^I should see all (\d+) tests pass/ do |expected_test_count|
|
127
|
+
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
128
|
+
actual_output = File.read(@stdout)
|
129
|
+
actual_output.should match(expected)
|
130
|
+
end
|
131
|
+
|
132
|
+
Then /^I should see all (\d+) examples pass/ do |expected_test_count|
|
133
|
+
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
134
|
+
actual_output = File.read(@stdout)
|
135
|
+
actual_output.should match(expected)
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
|
139
|
+
in_project_folder do
|
140
|
+
yaml = eval yaml
|
141
|
+
YAML.load(File.read(file)).should == yaml
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
Then /^Rakefile can display tasks successfully/ do
|
146
|
+
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
147
|
+
in_project_folder do
|
148
|
+
system "rake -T > #{@stdout} 2> #{@stdout}"
|
149
|
+
end
|
150
|
+
actual_output = File.read(@stdout)
|
151
|
+
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
152
|
+
end
|
153
|
+
|
154
|
+
Then /^task "rake (.*)" is executed successfully/ do |task|
|
155
|
+
@stdout.should_not be_nil
|
156
|
+
actual_output = File.read(@stdout)
|
157
|
+
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
158
|
+
actual_output.should_not match(/Error/i)
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
|
162
|
+
in_project_folder do
|
163
|
+
gem_file = Dir["pkg/*.gem"].first
|
164
|
+
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
165
|
+
spec_value = gem_spec.send(key.to_sym)
|
166
|
+
spec_value.to_s.should match(/#{regex}/)
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Given /^I expect to create DNSimple::Record with attributes:$/ do |table|
|
2
|
+
record = table.rows_hash
|
3
|
+
p [record.delete("domain"), record.delete("name") || "",
|
4
|
+
record.delete("record_type") || "A", record.delete("content"), record]
|
5
|
+
# DNSimple::Record.create(record.delete("domain"), record.delete("name") || "",
|
6
|
+
# record.delete("record_type") || "A", record.delete("content"), record)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Given /^I have setup my engineyard email\/password for API access$/ do
|
2
|
+
ENV['EYRC'] = File.join(@home_path, ".eyrc")
|
3
|
+
token = { ENV['CLOUD_URL'] => {
|
4
|
+
"api_token" => "f81a1706ddaeb148cfb6235ddecfc1cf"} }
|
5
|
+
File.open(ENV['EYRC'], "w"){|f| YAML.dump(token, f) }
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I have "two accounts, two apps, two environments, ambiguous" in AppCloud$/ do
|
9
|
+
api_scenario "two accounts, two apps, two environments, ambiguous"
|
10
|
+
end
|
11
|
+
|
12
|
+
# has a known public IP in its hostname ec2-174-129-7-113.compute-1.amazonaws.com
|
13
|
+
When /^I have "two apps" in AppCloud$/ do
|
14
|
+
api_scenario "two apps"
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module CommonHelpers
|
2
|
+
def in_tmp_folder(&block)
|
3
|
+
FileUtils.chdir(@tmp_root, &block)
|
4
|
+
end
|
5
|
+
|
6
|
+
def in_project_folder(&block)
|
7
|
+
project_folder = @active_project_folder || @tmp_root
|
8
|
+
FileUtils.chdir(project_folder, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def in_home_folder(&block)
|
12
|
+
FileUtils.chdir(@home_path, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def force_local_lib_override(project_name = @project_name)
|
16
|
+
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
17
|
+
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
18
|
+
f << "$:.unshift('#{@lib_path}')\n"
|
19
|
+
f << rakefile
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup_active_project_folder project_name
|
24
|
+
@active_project_folder = File.join(@tmp_root, project_name)
|
25
|
+
@project_name = project_name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
World(CommonHelpers)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
engineyard_loaded_path = $:.select { |path| path =~ %r|gems/engineyard-\d+| }.first
|
2
|
+
EY_ROOT = engineyard_loaded_path.gsub(%r|/\w+$|,'')
|
3
|
+
|
4
|
+
# helper to be stubbed out from engineyard spec_helper.rb
|
5
|
+
def shared_examples_for(title)
|
6
|
+
end
|
7
|
+
|
8
|
+
support = Dir[File.join(EY_ROOT,'/spec/support/*.rb')]
|
9
|
+
support.each{|helper| require helper }
|
10
|
+
World(Spec::Helpers)
|
11
|
+
|
12
|
+
require "fakeweb"
|
13
|
+
|
14
|
+
Before do
|
15
|
+
ENV["NO_SSH"] = "true"
|
16
|
+
ENV['CLOUD_URL'] = EY.fake_awsm
|
17
|
+
FakeWeb.allow_net_connect = true
|
18
|
+
end
|
19
|
+
|
20
|
+
After do
|
21
|
+
ENV.delete('CLOUD_URL')
|
22
|
+
ENV.delete('EYRC')
|
23
|
+
ENV.delete('NO_SSH')
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../lib'))
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'engineyard-dnsimple'
|
4
|
+
|
5
|
+
path = ENV['PATH']
|
6
|
+
|
7
|
+
Before do
|
8
|
+
@tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
9
|
+
@active_project_folder = @tmp_root
|
10
|
+
@home_path = File.expand_path(File.join(@tmp_root, "home"))
|
11
|
+
@lib_path = File.expand_path(File.dirname(__FILE__) + "/../../lib")
|
12
|
+
@fixtures_path = File.expand_path(File.dirname(__FILE__) + "/../../fixtures")
|
13
|
+
FileUtils.rm_rf @tmp_root
|
14
|
+
FileUtils.mkdir_p @home_path
|
15
|
+
ENV['HOME'] = @home_path
|
16
|
+
fixture_bin_path = File.expand_path('../../../fixtures/bin', __FILE__)
|
17
|
+
ENV['PATH'] = fixture_bin_path + ":" + path
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Matchers
|
2
|
+
def contain(expected)
|
3
|
+
simple_matcher("contain #{expected.inspect}") do |given, matcher|
|
4
|
+
matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}"
|
5
|
+
matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}"
|
6
|
+
given.index expected
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
World(Matchers)
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "engineyard"
|
2
|
+
require "engineyard/thor"
|
3
|
+
require "engineyard/cli"
|
4
|
+
require "engineyard/cli/ui"
|
5
|
+
require "engineyard/error"
|
6
|
+
require "dnsimple"
|
7
|
+
require "dnsimple/cli"
|
8
|
+
|
9
|
+
module EngineYard
|
10
|
+
module DNSimple
|
11
|
+
class CLI < Thor
|
12
|
+
include EY::UtilityMethods
|
13
|
+
# include Thor::Actions
|
14
|
+
|
15
|
+
def self.start(*)
|
16
|
+
Thor::Base.shell = EY::CLI::UI
|
17
|
+
EY.ui = EY::CLI::UI.new
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
desc "assign domain", "Assign domain (domain) to your AppCloud environment"
|
23
|
+
method_option :verbose, :aliases => ["-V"], :desc => "Display more output"
|
24
|
+
method_option :environment, :aliases => ["-e"], :desc => "Environment in which to deploy this application", :type => :string
|
25
|
+
method_option :account, :aliases => ["-c"], :desc => "Name of the account you want to deploy in"
|
26
|
+
def assign(domain)
|
27
|
+
say "Fetching environment information..."; $stdout.flush
|
28
|
+
|
29
|
+
environment = fetch_environment(options[:environment], options[:account])
|
30
|
+
unless environment.instances.first
|
31
|
+
error "Environment #{account_name}/#{env_name} has no booted instances."
|
32
|
+
end
|
33
|
+
public_hostname = environment.instances.first.public_hostname
|
34
|
+
status = environment.instances.first.status
|
35
|
+
unless public_hostname =~ /ec2-(\d+)-(\d+)-(\d+)-(\d+)/
|
36
|
+
error "Cannot determine public IP from current hostname #{public_hostname}"
|
37
|
+
end
|
38
|
+
|
39
|
+
account_name, env_name = environment.account.name, environment.name
|
40
|
+
public_ip = "#{$1}.#{$2}.#{$3}.#{$4}"
|
41
|
+
|
42
|
+
say "Found environment #{env_name} on account #{account_name} with IP #{public_ip}"
|
43
|
+
say "Assigning "; say "#{domain} ", :green; say "--> "; say "#{public_ip} ", :green; say "(#{account_name}/#{env_name})"
|
44
|
+
$stdout.flush
|
45
|
+
|
46
|
+
::DNSimple::Client.load_credentials_if_necessary
|
47
|
+
|
48
|
+
::DNSimple::Commands::CreateRecord.new.execute([domain, "", "A", public_ip, ""]) # A record for .mydomain.com
|
49
|
+
|
50
|
+
say "Complete!", :green
|
51
|
+
|
52
|
+
::DNSimple::Commands::ListRecords.new.execute([domain])
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "version", "show version information"
|
56
|
+
def version
|
57
|
+
require 'engineyard-jenkins/version'
|
58
|
+
shell.say Engineyard::Jenkins::VERSION
|
59
|
+
end
|
60
|
+
|
61
|
+
map "-v" => :version, "--version" => :version, "-h" => :help, "--help" => :help
|
62
|
+
|
63
|
+
private
|
64
|
+
def say(msg, color = nil)
|
65
|
+
color ? shell.say(msg, color) : shell.say(msg)
|
66
|
+
end
|
67
|
+
|
68
|
+
def display(text)
|
69
|
+
shell.say text
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
def error(text)
|
74
|
+
shell.say "ERROR: #{text}", :red
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
def watch_page_while(host, port, path)
|
79
|
+
waiting = true
|
80
|
+
while waiting
|
81
|
+
begin
|
82
|
+
Net::HTTP.start(host, port) do |http|
|
83
|
+
req = http.get(path)
|
84
|
+
waiting = yield req
|
85
|
+
end
|
86
|
+
sleep 1; print '.'; $stdout.flush
|
87
|
+
rescue SocketError => e
|
88
|
+
sleep 1; print 'x'; $stdout.flush
|
89
|
+
rescue Exception => e
|
90
|
+
puts e.message
|
91
|
+
sleep 1; print '.'; $stdout.flush
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,273 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: engineyard-dnsimple
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dr Nic Williams
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-22 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thor
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: engineyard
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: dnsimple-ruby
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 59
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
- 9
|
75
|
+
- 0
|
76
|
+
version: 0.9.0
|
77
|
+
type: :development
|
78
|
+
version_requirements: *id004
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: cucumber
|
81
|
+
prerelease: false
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 31
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
- 10
|
91
|
+
version: "0.10"
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id005
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
prerelease: false
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 9
|
103
|
+
segments:
|
104
|
+
- 2
|
105
|
+
- 5
|
106
|
+
version: "2.5"
|
107
|
+
type: :development
|
108
|
+
version_requirements: *id006
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: json
|
111
|
+
prerelease: false
|
112
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 7
|
118
|
+
segments:
|
119
|
+
- 1
|
120
|
+
- 4
|
121
|
+
- 0
|
122
|
+
version: 1.4.0
|
123
|
+
type: :development
|
124
|
+
version_requirements: *id007
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: awesome_print
|
127
|
+
prerelease: false
|
128
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
type: :development
|
138
|
+
version_requirements: *id008
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: realweb
|
141
|
+
prerelease: false
|
142
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ~>
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
hash: 23
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
- 1
|
151
|
+
- 6
|
152
|
+
version: 0.1.6
|
153
|
+
type: :development
|
154
|
+
version_requirements: *id009
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: open4
|
157
|
+
prerelease: false
|
158
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 3
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
version: "0"
|
167
|
+
type: :development
|
168
|
+
version_requirements: *id010
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: sinatra
|
171
|
+
prerelease: false
|
172
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
hash: 3
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
version: "0"
|
181
|
+
type: :development
|
182
|
+
version_requirements: *id011
|
183
|
+
- !ruby/object:Gem::Dependency
|
184
|
+
name: fakeweb
|
185
|
+
prerelease: false
|
186
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ~>
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
hash: 27
|
192
|
+
segments:
|
193
|
+
- 1
|
194
|
+
- 3
|
195
|
+
- 0
|
196
|
+
version: 1.3.0
|
197
|
+
type: :development
|
198
|
+
version_requirements: *id012
|
199
|
+
description: Easily configure your DNS with Engine Yard AppCloud via DNSimple.
|
200
|
+
email:
|
201
|
+
- drnicwilliams@gmail.com
|
202
|
+
executables:
|
203
|
+
- ey-dnsimple
|
204
|
+
extensions: []
|
205
|
+
|
206
|
+
extra_rdoc_files: []
|
207
|
+
|
208
|
+
files:
|
209
|
+
- .gitignore
|
210
|
+
- .rspec
|
211
|
+
- .travis.yml
|
212
|
+
- ChangeLog.md
|
213
|
+
- Gemfile
|
214
|
+
- README.md
|
215
|
+
- Rakefile
|
216
|
+
- bin/ey-dnsimple
|
217
|
+
- engineyard-dnsimple.gemspec
|
218
|
+
- features/assign_dns_to_environment.feature
|
219
|
+
- features/step_definitions/common_steps.rb
|
220
|
+
- features/step_definitions/dnsimple_steps.rb
|
221
|
+
- features/step_definitions/ey_api_steps.rb
|
222
|
+
- features/support/common.rb
|
223
|
+
- features/support/engineyard.rb
|
224
|
+
- features/support/env.rb
|
225
|
+
- features/support/matchers.rb
|
226
|
+
- lib/engineyard-dnsimple.rb
|
227
|
+
- lib/engineyard-dnsimple/cli.rb
|
228
|
+
- lib/engineyard-dnsimple/version.rb
|
229
|
+
- spec/spec_helper.rb
|
230
|
+
has_rdoc: true
|
231
|
+
homepage: ""
|
232
|
+
licenses: []
|
233
|
+
|
234
|
+
post_install_message:
|
235
|
+
rdoc_options: []
|
236
|
+
|
237
|
+
require_paths:
|
238
|
+
- lib
|
239
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
240
|
+
none: false
|
241
|
+
requirements:
|
242
|
+
- - ">="
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
hash: 3
|
245
|
+
segments:
|
246
|
+
- 0
|
247
|
+
version: "0"
|
248
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
hash: 3
|
254
|
+
segments:
|
255
|
+
- 0
|
256
|
+
version: "0"
|
257
|
+
requirements: []
|
258
|
+
|
259
|
+
rubyforge_project: engineyard-dnsimple
|
260
|
+
rubygems_version: 1.6.2
|
261
|
+
signing_key:
|
262
|
+
specification_version: 3
|
263
|
+
summary: Configure your Engine Yard AppCloud environment and your DNSimple domain.
|
264
|
+
test_files:
|
265
|
+
- features/assign_dns_to_environment.feature
|
266
|
+
- features/step_definitions/common_steps.rb
|
267
|
+
- features/step_definitions/dnsimple_steps.rb
|
268
|
+
- features/step_definitions/ey_api_steps.rb
|
269
|
+
- features/support/common.rb
|
270
|
+
- features/support/engineyard.rb
|
271
|
+
- features/support/env.rb
|
272
|
+
- features/support/matchers.rb
|
273
|
+
- spec/spec_helper.rb
|