dpl-connect 1.8.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.travis.yml +36 -0
- data/Gemfile +100 -0
- data/LICENSE +22 -0
- data/README.md +934 -0
- data/Rakefile +1 -0
- data/TESTING.md +29 -0
- data/bin/dpl +5 -0
- data/dpl.gemspec +32 -0
- data/lib/dpl/cli.rb +66 -0
- data/lib/dpl/error.rb +3 -0
- data/lib/dpl/provider.rb +264 -0
- data/lib/dpl/provider/anynines.rb +13 -0
- data/lib/dpl/provider/appfog.rb +21 -0
- data/lib/dpl/provider/atlas.rb +108 -0
- data/lib/dpl/provider/azure_webapps.rb +48 -0
- data/lib/dpl/provider/bintray.rb +509 -0
- data/lib/dpl/provider/bitballoon.rb +22 -0
- data/lib/dpl/provider/bluemix_cloud_foundry.rb +23 -0
- data/lib/dpl/provider/boxfuse.rb +57 -0
- data/lib/dpl/provider/catalyze.rb +49 -0
- data/lib/dpl/provider/chef_supermarket.rb +85 -0
- data/lib/dpl/provider/cloud66.rb +38 -0
- data/lib/dpl/provider/cloud_files.rb +38 -0
- data/lib/dpl/provider/cloud_foundry.rb +43 -0
- data/lib/dpl/provider/code_deploy.rb +123 -0
- data/lib/dpl/provider/deis.rb +119 -0
- data/lib/dpl/provider/divshot.rb +23 -0
- data/lib/dpl/provider/elastic_beanstalk.rb +195 -0
- data/lib/dpl/provider/engine_yard.rb +90 -0
- data/lib/dpl/provider/firebase.rb +27 -0
- data/lib/dpl/provider/gae.rb +97 -0
- data/lib/dpl/provider/gcs.rb +59 -0
- data/lib/dpl/provider/hackage.rb +29 -0
- data/lib/dpl/provider/heroku.rb +18 -0
- data/lib/dpl/provider/heroku/api.rb +98 -0
- data/lib/dpl/provider/heroku/generic.rb +94 -0
- data/lib/dpl/provider/heroku/git.rb +28 -0
- data/lib/dpl/provider/lambda.rb +236 -0
- data/lib/dpl/provider/launchpad.rb +48 -0
- data/lib/dpl/provider/modulus.rb +23 -0
- data/lib/dpl/provider/npm.rb +64 -0
- data/lib/dpl/provider/openshift.rb +59 -0
- data/lib/dpl/provider/ops_works.rb +132 -0
- data/lib/dpl/provider/packagecloud.rb +144 -0
- data/lib/dpl/provider/pages.rb +79 -0
- data/lib/dpl/provider/puppet_forge.rb +43 -0
- data/lib/dpl/provider/pypi.rb +111 -0
- data/lib/dpl/provider/releases.rb +139 -0
- data/lib/dpl/provider/rubygems.rb +51 -0
- data/lib/dpl/provider/s3.rb +123 -0
- data/lib/dpl/provider/scalingo.rb +97 -0
- data/lib/dpl/provider/script.rb +29 -0
- data/lib/dpl/provider/surge.rb +33 -0
- data/lib/dpl/provider/testfairy.rb +190 -0
- data/lib/dpl/provider/transifex.rb +45 -0
- data/lib/dpl/version.rb +3 -0
- data/notes/engine_yard.md +1 -0
- data/notes/heroku.md +3 -0
- data/spec/cli_spec.rb +36 -0
- data/spec/provider/anynines_spec.rb +20 -0
- data/spec/provider/appfog_spec.rb +35 -0
- data/spec/provider/atlas_spec.rb +99 -0
- data/spec/provider/azure_webapps_spec.rb +95 -0
- data/spec/provider/bintray_spec.rb +259 -0
- data/spec/provider/bitballoon_spec.rb +32 -0
- data/spec/provider/bluemixcloudfoundry_spec.rb +23 -0
- data/spec/provider/boxfuse_spec.rb +16 -0
- data/spec/provider/catalyze_spec.rb +39 -0
- data/spec/provider/chef_supermarket_spec.rb +51 -0
- data/spec/provider/cloud66_spec.rb +44 -0
- data/spec/provider/cloud_files_spec.rb +88 -0
- data/spec/provider/cloudfoundry_spec.rb +71 -0
- data/spec/provider/code_deploy_spec.rb +360 -0
- data/spec/provider/deis_spec.rb +116 -0
- data/spec/provider/divshot_spec.rb +28 -0
- data/spec/provider/elastic_beanstalk_spec.rb +209 -0
- data/spec/provider/firebase_spec.rb +40 -0
- data/spec/provider/gae_spec.rb +26 -0
- data/spec/provider/gcs_spec.rb +115 -0
- data/spec/provider/hackage_spec.rb +47 -0
- data/spec/provider/heroku_spec.rb +357 -0
- data/spec/provider/lambda_spec.rb +432 -0
- data/spec/provider/launchpad_spec.rb +33 -0
- data/spec/provider/modulus_spec.rb +29 -0
- data/spec/provider/npm_spec.rb +95 -0
- data/spec/provider/openshift_spec.rb +91 -0
- data/spec/provider/ops_works_spec.rb +127 -0
- data/spec/provider/packagecloud_spec.rb +56 -0
- data/spec/provider/puppet_forge_spec.rb +60 -0
- data/spec/provider/pypi_spec.rb +103 -0
- data/spec/provider/releases_spec.rb +303 -0
- data/spec/provider/rubygems_spec.rb +106 -0
- data/spec/provider/s3_spec.rb +174 -0
- data/spec/provider/scalingo_spec.rb +64 -0
- data/spec/provider/script_spec.rb +26 -0
- data/spec/provider/surge_spec.rb +15 -0
- data/spec/provider/testfairy_spec.rb +86 -0
- data/spec/provider/transifex_spec.rb +110 -0
- data/spec/provider_spec.rb +210 -0
- data/spec/spec_helper.rb +20 -0
- metadata +279 -0
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
task(:default) { ruby '-S rspec' }
|
data/TESTING.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Testing `dpl` in the context of Travis CI builds
|
2
|
+
|
3
|
+
It is possible to test new deployment provider or new functionality
|
4
|
+
of dpl when it is used from the Travis CI build script.
|
5
|
+
|
6
|
+
To do so, add the following to your `.travis.yml`:
|
7
|
+
|
8
|
+
```yaml
|
9
|
+
deploy:
|
10
|
+
provider: X
|
11
|
+
edge:
|
12
|
+
source: myown/dpl
|
13
|
+
branch: foo
|
14
|
+
on:
|
15
|
+
branch: TEST_BRANCH # or all_branches: true
|
16
|
+
⋮ # rest of provider X configuration
|
17
|
+
```
|
18
|
+
|
19
|
+
This builds the `dpl` gem on the VM
|
20
|
+
from `https://github.com/myown/dpl`, the `foo` branch.
|
21
|
+
Then it installs the locally built gem,
|
22
|
+
and uses that to deploy.
|
23
|
+
|
24
|
+
Notice that this is not a merge commit, so it is important
|
25
|
+
that when you are testing your PR, the branch `foo` is up-to-date
|
26
|
+
with https://github.com/travis-ci/dpl/tree/master/.
|
27
|
+
|
28
|
+
When opening a PR, be sure to run at least one deployment with the new configuration,
|
29
|
+
and provide a link to the build in the PR.
|
data/bin/dpl
ADDED
data/dpl.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "dpl/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "dpl-connect"
|
6
|
+
s.version = DPL::VERSION
|
7
|
+
s.author = "Konstantin Haase"
|
8
|
+
s.email = "konstantin.mailinglists@googlemail.com"
|
9
|
+
s.homepage = "https://github.com/travis-ci/dpl"
|
10
|
+
s.summary = %q{deploy tool}
|
11
|
+
s.description = %q{deploy tool abstraction for clients}
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.required_ruby_version = '>= 1.9.3'
|
18
|
+
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.0.0'
|
20
|
+
s.add_development_dependency 'rspec-its'
|
21
|
+
s.add_development_dependency 'rake'
|
22
|
+
s.add_development_dependency 'json', '1.8.3'
|
23
|
+
s.add_development_dependency 'tins', '~> 1.6.0', '>= 1.6.0'
|
24
|
+
s.add_development_dependency 'coveralls'
|
25
|
+
|
26
|
+
# prereleases from Travis CI
|
27
|
+
if ENV['CI']
|
28
|
+
digits = s.version.to_s.split '.'
|
29
|
+
digits[-1] = digits[-1].to_s.succ
|
30
|
+
s.version = digits.join('.') + ".travis.#{ENV['TRAVIS_JOB_NUMBER']}"
|
31
|
+
end
|
32
|
+
end
|
data/lib/dpl/cli.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'dpl/error'
|
2
|
+
require 'dpl/provider'
|
3
|
+
|
4
|
+
module DPL
|
5
|
+
class CLI
|
6
|
+
def self.run(*args)
|
7
|
+
new(args).run
|
8
|
+
end
|
9
|
+
|
10
|
+
OPTION_PATTERN = /\A--([a-z][a-z_\-]*)(?:=(.+))?\z/
|
11
|
+
attr_accessor :options, :fold_count
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
options = {}
|
15
|
+
args.flatten.each do |arg|
|
16
|
+
next options.update(arg) if arg.is_a? Hash
|
17
|
+
die("invalid option %p" % arg) unless match = OPTION_PATTERN.match(arg)
|
18
|
+
key = match[1].tr('-', '_').to_sym
|
19
|
+
if options.include? key
|
20
|
+
options[key] = Array(options[key]) << match[2]
|
21
|
+
else
|
22
|
+
options[key] = match[2] || true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
self.fold_count = 0
|
27
|
+
self.options = default_options.merge(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
provider = Provider.new(self, options)
|
32
|
+
provider.deploy
|
33
|
+
rescue Error => error
|
34
|
+
options[:debug] ? raise(error) : die(error.message)
|
35
|
+
end
|
36
|
+
|
37
|
+
def fold(message)
|
38
|
+
self.fold_count += 1
|
39
|
+
print "travis_fold:start:dpl.#{fold_count}\r" if options[:fold]
|
40
|
+
puts "\e[33m#{message}\e[0m"
|
41
|
+
yield
|
42
|
+
ensure
|
43
|
+
print "\ntravis_fold:end:dpl.#{fold_count}\r" if options[:fold]
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_options
|
47
|
+
{
|
48
|
+
:app => File.basename(Dir.pwd),
|
49
|
+
:key_name => %x[hostname].strip
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def shell(command)
|
54
|
+
system(command)
|
55
|
+
end
|
56
|
+
|
57
|
+
def die(message)
|
58
|
+
$stderr.puts(message)
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def env
|
63
|
+
ENV
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/dpl/error.rb
ADDED
data/lib/dpl/provider.rb
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
require 'dpl/error'
|
2
|
+
require 'dpl/version'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module DPL
|
6
|
+
class Provider
|
7
|
+
include FileUtils
|
8
|
+
|
9
|
+
autoload :Anynines, 'dpl/provider/anynines'
|
10
|
+
autoload :Appfog, 'dpl/provider/appfog'
|
11
|
+
autoload :Atlas, 'dpl/provider/atlas'
|
12
|
+
autoload :AzureWebApps, 'dpl/provider/azure_webapps'
|
13
|
+
autoload :Bintray, 'dpl/provider/bintray'
|
14
|
+
autoload :BitBalloon, 'dpl/provider/bitballoon'
|
15
|
+
autoload :BluemixCloudFoundry, 'dpl/provider/bluemix_cloud_foundry'
|
16
|
+
autoload :Boxfuse, 'dpl/provider/boxfuse'
|
17
|
+
autoload :Catalyze, 'dpl/provider/catalyze'
|
18
|
+
autoload :ChefSupermarket, 'dpl/provider/chef_supermarket'
|
19
|
+
autoload :Cloud66, 'dpl/provider/cloud66'
|
20
|
+
autoload :CloudFiles, 'dpl/provider/cloud_files'
|
21
|
+
autoload :CloudFoundry, 'dpl/provider/cloud_foundry'
|
22
|
+
autoload :CodeDeploy, 'dpl/provider/code_deploy'
|
23
|
+
autoload :Deis, 'dpl/provider/deis'
|
24
|
+
autoload :Divshot, 'dpl/provider/divshot'
|
25
|
+
autoload :ElasticBeanstalk, 'dpl/provider/elastic_beanstalk'
|
26
|
+
autoload :EngineYard, 'dpl/provider/engine_yard'
|
27
|
+
autoload :Firebase, 'dpl/provider/firebase'
|
28
|
+
autoload :GAE, 'dpl/provider/gae'
|
29
|
+
autoload :GCS, 'dpl/provider/gcs'
|
30
|
+
autoload :Hackage, 'dpl/provider/hackage'
|
31
|
+
autoload :Heroku, 'dpl/provider/heroku'
|
32
|
+
autoload :Lambda, 'dpl/provider/lambda'
|
33
|
+
autoload :Launchpad, 'dpl/provider/launchpad'
|
34
|
+
autoload :Modulus, 'dpl/provider/modulus'
|
35
|
+
autoload :Nodejitsu, 'dpl/provider/nodejitsu'
|
36
|
+
autoload :NPM, 'dpl/provider/npm'
|
37
|
+
autoload :Openshift, 'dpl/provider/openshift'
|
38
|
+
autoload :OpsWorks, 'dpl/provider/ops_works'
|
39
|
+
autoload :Packagecloud, 'dpl/provider/packagecloud'
|
40
|
+
autoload :Pages, 'dpl/provider/pages'
|
41
|
+
autoload :PuppetForge, 'dpl/provider/puppet_forge'
|
42
|
+
autoload :PyPI, 'dpl/provider/pypi'
|
43
|
+
autoload :Releases, 'dpl/provider/releases'
|
44
|
+
autoload :RubyGems, 'dpl/provider/rubygems'
|
45
|
+
autoload :S3, 'dpl/provider/s3'
|
46
|
+
autoload :Scalingo, 'dpl/provider/scalingo'
|
47
|
+
autoload :Script, 'dpl/provider/script'
|
48
|
+
autoload :Surge, 'dpl/provider/surge'
|
49
|
+
autoload :TestFairy, 'dpl/provider/testfairy'
|
50
|
+
autoload :Transifex, 'dpl/provider/transifex'
|
51
|
+
|
52
|
+
|
53
|
+
def self.new(context, options)
|
54
|
+
return super if self < Provider
|
55
|
+
|
56
|
+
context.fold("Installing deploy dependencies") do
|
57
|
+
name = super.option(:provider).to_s.downcase.gsub(/[^a-z0-9]/, '')
|
58
|
+
raise Error, 'could not find provider %p' % options[:provider] unless name = constants.detect { |c| c.to_s.downcase == name }
|
59
|
+
provider = const_get(name).new(context, options)
|
60
|
+
provider.install_deploy_dependencies if provider.respond_to?(:install_deploy_dependencies)
|
61
|
+
provider
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.experimental(name)
|
66
|
+
puts "", "!!! #{name} support is experimental !!!", ""
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.deprecated(*lines)
|
70
|
+
puts ''
|
71
|
+
lines.each do |line|
|
72
|
+
puts "\e[31;1m#{line}\e[0m"
|
73
|
+
end
|
74
|
+
puts ''
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.requires(name, options = {})
|
78
|
+
version = options[:version] || '> 0'
|
79
|
+
load = options[:load] || name
|
80
|
+
gem(name, version)
|
81
|
+
rescue LoadError
|
82
|
+
context.shell("gem install %s -v %p --no-ri --no-rdoc #{'--pre' if options[:pre]}" % [name, version], retry: true)
|
83
|
+
Gem.clear_paths
|
84
|
+
ensure
|
85
|
+
require load
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.context
|
89
|
+
self
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.shell(command, options = {})
|
93
|
+
system(command)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.apt_get(name, command = name)
|
97
|
+
context.shell("sudo apt-get -qq install #{name}", retry: true) if `which #{command}`.chop.empty?
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.pip(name, command = name, version = nil)
|
101
|
+
if version
|
102
|
+
puts "pip install --user #{name}==#{version}"
|
103
|
+
context.shell("pip uninstall --user -y #{name}") unless `which #{command}`.chop.empty?
|
104
|
+
context.shell("pip install --user #{name}==#{version}", retry: true)
|
105
|
+
else
|
106
|
+
puts "pip install --user #{name}"
|
107
|
+
context.shell("pip install --user #{name}", retry: true) if `which #{command}`.chop.empty?
|
108
|
+
end
|
109
|
+
context.shell("export PATH=$PATH:$HOME/.local/bin")
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.npm_g(name, command = name)
|
113
|
+
context.shell("npm install -g #{name}", retry: true) if `which #{command}`.chop.empty?
|
114
|
+
end
|
115
|
+
|
116
|
+
attr_reader :context, :options
|
117
|
+
|
118
|
+
def initialize(context, options)
|
119
|
+
@context, @options = context, options
|
120
|
+
context.env['GIT_HTTP_USER_AGENT'] = user_agent(git: `git --version`[/[\d\.]+/])
|
121
|
+
end
|
122
|
+
|
123
|
+
def user_agent(*strings)
|
124
|
+
strings.unshift "dpl/#{DPL::VERSION}"
|
125
|
+
strings.unshift "travis/0.1.0" if context.env['TRAVIS']
|
126
|
+
strings = strings.flat_map { |e| Hash === e ? e.map { |k,v| "#{k}/#{v}" } : e }
|
127
|
+
strings.join(" ").gsub(/\s+/, " ").strip
|
128
|
+
end
|
129
|
+
|
130
|
+
def option(name, *alternatives)
|
131
|
+
options.fetch(name) do
|
132
|
+
alternatives.any? ? option(*alternatives) : raise(Error, "missing #{name}")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def deploy
|
137
|
+
setup_git_credentials
|
138
|
+
rm_rf ".dpl"
|
139
|
+
mkdir_p ".dpl"
|
140
|
+
|
141
|
+
context.fold("Preparing deploy") do
|
142
|
+
check_auth
|
143
|
+
check_app
|
144
|
+
|
145
|
+
if needs_key?
|
146
|
+
create_key(".dpl/id_rsa")
|
147
|
+
setup_key(".dpl/id_rsa.pub")
|
148
|
+
setup_git_ssh(".dpl/git-ssh", ".dpl/id_rsa")
|
149
|
+
end
|
150
|
+
|
151
|
+
cleanup
|
152
|
+
end
|
153
|
+
|
154
|
+
context.fold("Deploying application") { push_app }
|
155
|
+
|
156
|
+
Array(options[:run]).each do |command|
|
157
|
+
if command == 'restart'
|
158
|
+
context.fold("Restarting application") { restart }
|
159
|
+
else
|
160
|
+
context.fold("Running %p" % command) { run(command) }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
ensure
|
164
|
+
if needs_key?
|
165
|
+
remove_key rescue nil
|
166
|
+
end
|
167
|
+
uncleanup
|
168
|
+
end
|
169
|
+
|
170
|
+
def sha
|
171
|
+
@sha ||= context.env['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
|
172
|
+
end
|
173
|
+
|
174
|
+
def commit_msg
|
175
|
+
@commit_msg ||= %x{git log #{sha} -n 1 --pretty=%B}.strip
|
176
|
+
end
|
177
|
+
|
178
|
+
def cleanup
|
179
|
+
return if options[:skip_cleanup]
|
180
|
+
context.shell "mv .dpl ~/dpl"
|
181
|
+
log "Cleaning up git repository with `git stash --all`. " \
|
182
|
+
"If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. " \
|
183
|
+
"See https://docs.travis-ci.com/user/deployment/#Uploading-Files."
|
184
|
+
context.shell "git stash --all"
|
185
|
+
context.shell "mv ~/dpl .dpl"
|
186
|
+
end
|
187
|
+
|
188
|
+
def uncleanup
|
189
|
+
return if options[:skip_cleanup]
|
190
|
+
context.shell "git stash pop"
|
191
|
+
end
|
192
|
+
|
193
|
+
def needs_key?
|
194
|
+
true
|
195
|
+
end
|
196
|
+
|
197
|
+
def check_app
|
198
|
+
end
|
199
|
+
|
200
|
+
def create_key(file)
|
201
|
+
context.shell "ssh-keygen -t rsa -N \"\" -C #{option(:key_name)} -f #{file}"
|
202
|
+
end
|
203
|
+
|
204
|
+
def setup_git_credentials
|
205
|
+
context.shell "git config user.email >/dev/null 2>/dev/null || git config user.email `whoami`@localhost"
|
206
|
+
context.shell "git config user.name >/dev/null 2>/dev/null || git config user.name `whoami`@localhost"
|
207
|
+
end
|
208
|
+
|
209
|
+
def setup_git_ssh(path, key_path)
|
210
|
+
key_path = File.expand_path(key_path)
|
211
|
+
path = File.expand_path(path)
|
212
|
+
|
213
|
+
File.open(path, 'w') do |file|
|
214
|
+
file.write "#!/bin/sh\n"
|
215
|
+
file.write "exec ssh -o StrictHostKeychecking=no -o CheckHostIP=no -o UserKnownHostsFile=/dev/null -i #{key_path} -- \"$@\"\n"
|
216
|
+
end
|
217
|
+
|
218
|
+
chmod(0740, path)
|
219
|
+
context.env['GIT_SSH'] = path
|
220
|
+
end
|
221
|
+
|
222
|
+
def detect_encoding?
|
223
|
+
options[:detect_encoding]
|
224
|
+
end
|
225
|
+
|
226
|
+
def default_text_charset?
|
227
|
+
options[:default_text_charset]
|
228
|
+
end
|
229
|
+
|
230
|
+
def default_text_charset
|
231
|
+
options[:default_text_charset].downcase
|
232
|
+
end
|
233
|
+
|
234
|
+
def encoding_for(path)
|
235
|
+
file_cmd_output = `file '#{path}'`
|
236
|
+
case file_cmd_output
|
237
|
+
when /gzip compressed/
|
238
|
+
'gzip'
|
239
|
+
when /compress'd/
|
240
|
+
'compress'
|
241
|
+
when /text/
|
242
|
+
'text'
|
243
|
+
when /data/
|
244
|
+
# Shrugs?
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def log(message)
|
249
|
+
$stderr.puts(message)
|
250
|
+
end
|
251
|
+
|
252
|
+
def warn(message)
|
253
|
+
log "\e[31;1m#{message}\e[0m"
|
254
|
+
end
|
255
|
+
|
256
|
+
def run(command)
|
257
|
+
error "running commands not supported"
|
258
|
+
end
|
259
|
+
|
260
|
+
def error(message)
|
261
|
+
raise Error, message
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module DPL
|
2
|
+
class Provider
|
3
|
+
class Anynines < CloudFoundry
|
4
|
+
|
5
|
+
def check_auth
|
6
|
+
initial_go_tools_install
|
7
|
+
context.shell "./cf api https://api.aws.ie.a9s.eu"
|
8
|
+
context.shell "./cf login -u #{option(:username)} -p #{option(:password)} -o #{option(:organization)} -s #{option(:space)}"
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DPL
|
2
|
+
class Provider
|
3
|
+
class Appfog < Provider
|
4
|
+
requires 'json_pure', :version => '< 2.0', :load => 'json/pure'
|
5
|
+
requires 'af', :load => 'vmc'
|
6
|
+
|
7
|
+
def check_auth
|
8
|
+
context.shell "af login --email=#{option(:email)} --password=#{option(:password)}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def needs_key?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def push_app
|
16
|
+
context.shell "af update #{options[:app] || File.basename(Dir.getwd)}"
|
17
|
+
context.shell "af logout"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module DPL
|
2
|
+
class Provider
|
3
|
+
class Atlas < Provider
|
4
|
+
GIMME_URL = 'https://raw.githubusercontent.com/meatballhat/gimme/master/gimme'
|
5
|
+
ATLAS_UPLOAD_CLI_GO_REMOTE = 'github.com/hashicorp/atlas-upload-cli'
|
6
|
+
ATLAS_UPLOAD_BOOL_ARGS = %w(vcs debug).map(&:to_sym).freeze
|
7
|
+
ATLAS_UPLOAD_KV_ARGS = %w(address).map(&:to_sym).freeze
|
8
|
+
ATLAS_UPLOAD_KV_MULTI_ARGS = %w(exclude include metadata).map(&:to_sym).freeze
|
9
|
+
ATLAS_UPLOAD_INSTALL_SCRIPT = <<-EOF.gsub(/^ {8}/, '').strip
|
10
|
+
if ! command -v atlas-upload &>/dev/null ; then
|
11
|
+
mkdir -p $HOME/bin $HOME/gopath/src
|
12
|
+
export PATH="$HOME/bin:$PATH"
|
13
|
+
|
14
|
+
if ! command -v gimme &>/dev/null ; then
|
15
|
+
curl -sL -o $HOME/bin/gimme #{GIMME_URL}
|
16
|
+
chmod +x $HOME/bin/gimme
|
17
|
+
fi
|
18
|
+
|
19
|
+
if [ -z $GOPATH ]; then
|
20
|
+
export GOPATH="$HOME/gopath"
|
21
|
+
else
|
22
|
+
export GOPATH="$HOME/gopath:$GOPATH"
|
23
|
+
fi
|
24
|
+
eval "$(gimme 1.6)" &> /dev/null
|
25
|
+
|
26
|
+
go get #{ATLAS_UPLOAD_CLI_GO_REMOTE}
|
27
|
+
cp $HOME/gopath/bin/atlas-upload-cli $HOME/bin/atlas-upload
|
28
|
+
fi
|
29
|
+
EOF
|
30
|
+
|
31
|
+
experimental 'Atlas'
|
32
|
+
|
33
|
+
def deploy
|
34
|
+
assert_app_present!
|
35
|
+
install_atlas_upload
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_auth
|
40
|
+
ENV['ATLAS_TOKEN'] = options[:token] if options[:token]
|
41
|
+
error 'Missing ATLAS_TOKEN' unless ENV['ATLAS_TOKEN']
|
42
|
+
end
|
43
|
+
|
44
|
+
def needs_key?
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def push_app
|
49
|
+
unless options[:paths]
|
50
|
+
here = Dir.pwd
|
51
|
+
warn "No paths specified. Using #{here.inspect}."
|
52
|
+
options[:paths] = here
|
53
|
+
end
|
54
|
+
|
55
|
+
Array(options[:paths]).each do |path|
|
56
|
+
context.shell "atlas-upload #{atlas_upload_args} #{atlas_app} #{path}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def install_atlas_upload
|
63
|
+
without_git_http_user_agent do
|
64
|
+
context.shell ATLAS_UPLOAD_INSTALL_SCRIPT
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def assert_app_present!
|
69
|
+
error 'Missing Atlas app name' unless options.key?(:app)
|
70
|
+
end
|
71
|
+
|
72
|
+
def atlas_upload_args
|
73
|
+
return options[:args] if options.key?(:args)
|
74
|
+
return @atlas_upload_args if @atlas_upload_args
|
75
|
+
|
76
|
+
args = []
|
77
|
+
|
78
|
+
ATLAS_UPLOAD_BOOL_ARGS.each do |arg|
|
79
|
+
args << "-#{arg}" if options.key?(arg)
|
80
|
+
end
|
81
|
+
|
82
|
+
ATLAS_UPLOAD_KV_ARGS.each do |arg|
|
83
|
+
args << ["-#{arg}", options[arg].inspect].join('=') if options.key?(arg)
|
84
|
+
end
|
85
|
+
|
86
|
+
ATLAS_UPLOAD_KV_MULTI_ARGS.each do |arg|
|
87
|
+
next unless options.key?(arg)
|
88
|
+
Array(options[arg]).each do |arg_entry|
|
89
|
+
args << ["-#{arg}", arg_entry.inspect].join('=')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
@atlas_upload_args = args.join(' ')
|
94
|
+
end
|
95
|
+
|
96
|
+
def atlas_app
|
97
|
+
@atlas_app ||= options.fetch(:app).to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
def without_git_http_user_agent(&block)
|
101
|
+
git_http_user_agent = ENV.delete("GIT_HTTP_USER_AGENT")
|
102
|
+
yield
|
103
|
+
ENV["GIT_HTTP_USER_AGENT"] = git_http_user_agent
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|