dpl 1.8.8.travis.1179.4 → 1.8.8.travis.1183.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2U0NzVjOTM4MDE5ZjI4MDJlYTI1ODFiOGRhNjZmZTI3MjUyMWU3Yg==
4
+ OWIzYjEwOTdlYmQ3NzlhZWU1MTI5MjU4ZTIxYjIxMmIwNzJlMzc2OA==
5
5
  data.tar.gz: !binary |-
6
- NWZlNjYzMjQ2ZjdhODI3MjYxZjE2YWUyNTdlM2VhNDcyOTZhNmQ3Ng==
6
+ NDQyNGM5ZTQ4MmQwMmM1ZDQwZDUxYWZhMzk1M2RmMzhkYWYyMmUwMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTIxNWE5OWI2NTA5YmIzOGQ0YzRlMmJhYmQ2MmY5ZDMxN2Y2ZjQ0MTk5YTVm
10
- OWQ4NWMwMTNiYzllZTZlODA1ZGY0Zjc2Y2ViYWNhY2VlYmFkMjA5YmMyMGY5
11
- ZWVkNGFhOWVkNTA4NTg4NjlmMzY1NGE2ZjE3YzliMjIzMWRmZmE=
9
+ OWZkNTBhZWQzZTg5MGI3NmJjZmE4MDBjNzI1OWQ3YjM5YjYyMjM3N2NiM2Fm
10
+ ZDcyZWViNmViZjc2MDQxMjJlYTg1MTRjOTU0ZmM2YTcwMGJiYjNjMWNjMjVh
11
+ MmIwNjZjNTExYzI4NjIwNTQ2NzdlZDY2ZWU2NzJkNzI3MjMxMmU=
12
12
  data.tar.gz: !binary |-
13
- YTI2ZDMzYjY2OGMyNjY5OTRiYjA3ZDQwYTgyZjZjYjBlN2JkYTdmNDdjOWFl
14
- YTA5Njg2M2FhZWU4YjBlYzI4NjYzMjA0OTM3ODUzMWE0OWVkZTlhMzYwNGY4
15
- NDJjZmJmOGQ4NjYzNGViMTg3NjQwNzg3ZWQ3YTNiYWEyNDA3MGQ=
13
+ MzgyZTU5Y2UwZGQ0ZGU2MzhhNjA2MTE0NDIyYTQ3YjFmMzlhM2NlMDE2MWQ4
14
+ YWYxYTVmODNjMDVjMmJlNzlhNDU4MDdiNWNkZGQ1OWIwNGVjNDkzYTk2OWQw
15
+ NWNjZmQyZDViZTJmZmU2YzVhN2NiMzc3NzA5OTkyMWNiZTMwMjc=
data/README.md CHANGED
@@ -44,6 +44,7 @@ Dpl supports the following providers:
44
44
  * [Rackspace Cloud Files](#rackspace-cloud-files)
45
45
  * [RubyGems](#rubygems)
46
46
  * [S3](#s3)
47
+ * [Scalingo](#scalingo)
47
48
  * [Script](#script)
48
49
  * [TestFairy](#testfairy)
49
50
 
@@ -437,6 +438,7 @@ You first need to create an [Atlas account](https://atlas.hashicorp.com/account/
437
438
  #### Options:
438
439
 
439
440
  * **site**: Web App Name (if your app lives at myapp.azurewebsites.net, the name would be myapp).
441
+ * **slot**: Optional. Slot name if your app uses staging deployment. (e.g. if your slot lives at myapp-test.azurewebsites.net, the slot would be myapp-test).
440
442
  * **username**: Web App Deployment Username.
441
443
  * **password**: Web App Deployment Password.
442
444
  * **verbose**: If passed, Azure's deployment output will be printed. Warning: If you provide incorrect credentials, Git will print those in clear text. Correct authentication credentials will remain hidden.
@@ -444,12 +446,13 @@ You first need to create an [Atlas account](https://atlas.hashicorp.com/account/
444
446
  #### Environment variables:
445
447
 
446
448
  * **AZURE_WA_SITE** Web App Name. Used if the `site` option is omitted.
449
+ * **AZURE_WA_SLOT** Optional. Slot name if your app uses staging deployment. Used if the `slot` option is omitted.
447
450
  * **AZURE_WA_USERNAME**: Web App Deployment Username. Used if the `username` option is omitted.
448
451
  * **AZURE_WA_PASSWORD**: Web App Deployment Password. Used if the `password` option is omitted.
449
452
 
450
453
  #### Examples:
451
454
 
452
- dpl --provider=AzureWebApps --username=depluser --password=deplp@ss --site=dplsite --verbose
455
+ dpl --provider=AzureWebApps --username=depluser --password=deplp@ss --site=dplsite --slot=dplsite-test --verbose
453
456
 
454
457
  ### Divshot.io:
455
458
 
@@ -758,6 +761,34 @@ and your testers can start testing your app.
758
761
 
759
762
  dpl --provider=codedeploy --access-key-id=<aws access key> --secret_access_key=<aws secret access key> --application=<application name> --deployment_group=<deployment group> --revision_type=<s3/github> --commit_id=<commit ID> --repository=<repo name> --region=<AWS availability zone> --wait-until-deployed=<true>
760
763
 
764
+ ### Scalingo:
765
+
766
+ #### Options:
767
+ * **api_key**: scalingo API Key. Not necessary if username and password are used.
768
+ * **username**: scalingo username. Not necessary if api_key is used.
769
+ * **password**: scalingo password. Not necessary if api_key is used.
770
+ * **remote**: Remote url or git remote name of your git repository. By default remote name is "scalingo".
771
+ * **branch**: Branch of your git repository. By default branch name is "master".
772
+ * **app**: Only necessary if your repository does not contain the appropriate remote. Specifying the app will add a remote to your local repository: `git remote add <remote> git@scalingo.com:<app>.git`
773
+
774
+ #### Use:
775
+
776
+ You can connect to Scalingo using your username/password or your api key.
777
+ It needs [Scalingo CLI](http://cli.scalingo.com/) which will be [downloaded here](http://cli.scalingo.com/).
778
+ Then, it will push your project to Scalingo and deploy it automatically.
779
+
780
+ Note: You only need to connect once to Scalingo CLI, credentials are stored locally.
781
+
782
+ #### Examples:
783
+
784
+ dpl --provider=scalingo --api_key="aaAAbbBB0011223344"
785
+ dpl --provider=scalingo --username=<username> --password=<password>
786
+
787
+ dpl --provider=scalingo --api_key="aaAAbbBB0011223344" --remote="scalingo-staging"
788
+ dpl --provider=scalingo --api_key="aaAAbbBB0011223344" --remote="scalingo-staging" branch="master"
789
+
790
+ dpl --provider=scalingo
791
+
761
792
  ### Script:
762
793
 
763
794
  An elementary provider that executes a single command.
data/lib/dpl/provider.rb CHANGED
@@ -43,6 +43,7 @@ module DPL
43
43
  autoload :Releases, 'dpl/provider/releases'
44
44
  autoload :RubyGems, 'dpl/provider/rubygems'
45
45
  autoload :S3, 'dpl/provider/s3'
46
+ autoload :Scalingo, 'dpl/provider/scalingo'
46
47
  autoload :Script, 'dpl/provider/script'
47
48
  autoload :TestFairy, 'dpl/provider/testfairy'
48
49
  autoload :Transifex, 'dpl/provider/transifex'
@@ -5,12 +5,13 @@ module DPL
5
5
  {
6
6
  "username" => options[:username] || context.env['AZURE_WA_USERNAME'],
7
7
  "password" => options[:password] || context.env['AZURE_WA_PASSWORD'],
8
- "site" => options[:site] || context.env['AZURE_WA_SITE']
8
+ "site" => options[:site] || context.env['AZURE_WA_SITE'],
9
+ "slot" => options[:slot] || context.env['AZURE_WA_SLOT']
9
10
  }
10
11
  end
11
12
 
12
13
  def git_target
13
- "https://#{config['username']}:#{config['password']}@#{config['site']}.scm.azurewebsites.net:443/#{config['site']}.git"
14
+ "https://#{config['username']}:#{config['password']}@#{config['slot'] || config['site']}.scm.azurewebsites.net:443/#{config['site']}.git"
14
15
  end
15
16
 
16
17
  def needs_key?
@@ -27,7 +28,7 @@ module DPL
27
28
  end
28
29
 
29
30
  def push_app
30
- log "Deploying to Azure Web App '#{config['site']}'"
31
+ log "Deploying to Azure Web App '#{config['slot'] || config['site']}'"
31
32
 
32
33
  if !!options[:verbose]
33
34
  context.shell "git push --force --quiet #{git_target} master"
@@ -0,0 +1,97 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+ require 'date'
5
+
6
+ module DPL
7
+ class Provider
8
+ class Scalingo < Provider
9
+
10
+ def install_deploy_dependencies
11
+ unless context.shell "curl -OL https://cli-dl.scalingo.io/release/scalingo_latest_linux_amd64.tar.gz && tar -zxvf scalingo_latest_linux_amd64.tar.gz && mv scalingo_*_linux_amd64/scalingo . && rm scalingo_latest_linux_amd64.tar.gz && rm -r scalingo_*_linux_amd64"
12
+ error "Couldn't install Scalingo CLI."
13
+ end
14
+ end
15
+
16
+ def initialize(context, options)
17
+ super
18
+ @options = options
19
+ @remote = options[:remote] || "scalingo"
20
+ @branch = options[:branch] || "master"
21
+ end
22
+
23
+ def logged_in
24
+ context.shell "DISABLE_INTERACTIVE=true ./scalingo login 2> /dev/null > /dev/null"
25
+ end
26
+
27
+ def check_auth
28
+ if @options[:api_key]
29
+ unless context.shell "mkdir -p ~/.config/scalingo"
30
+ error "Couldn't create authentication file."
31
+ end
32
+ url = URI.parse('http://api.scalingo.com/v1/users/self')
33
+ http = Net::HTTP.new(url.host, url.port)
34
+ request = Net::HTTP::Get.new(url.request_uri)
35
+ request.basic_auth("", @options[:api_key])
36
+ request["Accept"] = "application/json"
37
+ request["Content-type"] = "application/json"
38
+ response = http.request(request)
39
+ data = {}
40
+ if File.exist?("#{Dir.home}/.config/scalingo/auth")
41
+ data = JSON.parse(File.read("#{Dir.home}/.config/scalingo/auth"))
42
+ end
43
+ begin
44
+ user = JSON.parse(response.body)
45
+ rescue
46
+ error "Invalid API token."
47
+ end
48
+ data["auth_config_data"] = {}
49
+ data["auth_config_data"]["api.scalingo.com"] = {}
50
+ data["auth_config_data"]["api.scalingo.com"]["id"] = user["user"]["id"]
51
+ data["auth_config_data"]["api.scalingo.com"]["last_name"] = user["user"]["last_name"]
52
+ data["auth_config_data"]["api.scalingo.com"]["username"] = user["user"]["username"]
53
+ data["auth_config_data"]["api.scalingo.com"]["email"] = user["user"]["email"]
54
+ data["auth_config_data"]["api.scalingo.com"]["first_name"] = user["user"]["first_name"]
55
+ data["auth_config_data"]["api.scalingo.com"]["auth_token"] = @options[:api_key]
56
+ data["last_update"] = DateTime.now
57
+ f = File.open("#{Dir.home}/.config/scalingo/auth", "w+") {
58
+ |f| f.write(data.to_json)
59
+ }
60
+ elsif @options[:username] && @options[:password]
61
+ context.shell "echo -e \"#{@options[:username]}\n#{@options[:password]}\" | timeout 2 ./scalingo login 2> /dev/null > /dev/null"
62
+ end
63
+ if !logged_in
64
+ error "Couldn't connect to Scalingo API."
65
+ end
66
+ end
67
+
68
+ def setup_key(file, type = nil)
69
+ if !logged_in
70
+ error "Couldn't connect to Scalingo API."
71
+ end
72
+ unless context.shell "./scalingo keys-add dpl_tmp_key #{file}"
73
+ error "Couldn't add ssh key."
74
+ end
75
+ end
76
+
77
+ def remove_key
78
+ if !logged_in
79
+ error "Couldn't connect to Scalingo API."
80
+ end
81
+ unless context.shell "./scalingo keys-remove dpl_tmp_key"
82
+ error "Couldn't remove ssh key."
83
+ end
84
+ end
85
+
86
+ def push_app
87
+ if @options[:app]
88
+ context.shell "git remote add #{@remote} git@scalingo.com:#{@options[:app]}.git 2> /dev/null > /dev/null"
89
+ end
90
+ unless context.shell "git push #{@remote} #{@branch} -f"
91
+ error "Couldn't push your app."
92
+ end
93
+ end
94
+
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/scalingo'
3
+
4
+ describe DPL::Provider::Scalingo do
5
+
6
+ subject :provider do
7
+ described_class.new(DummyContext.new, :username => 'travis', :password => 'secret', :remote => 'scalingo', :branch => 'master')
8
+ end
9
+
10
+ describe "#install_deploy_dependencies" do
11
+ example do
12
+ expect(provider.context).to receive(:shell).with(
13
+ 'curl -OL https://cli-dl.scalingo.io/release/scalingo_latest_linux_amd64.tar.gz && tar -zxvf scalingo_latest_linux_amd64.tar.gz && mv scalingo_*_linux_amd64/scalingo . && rm scalingo_latest_linux_amd64.tar.gz && rm -r scalingo_*_linux_amd64'
14
+ ).and_return(true)
15
+ provider.install_deploy_dependencies
16
+ end
17
+ end
18
+
19
+ describe "#check_auth" do
20
+ example do
21
+ expect(provider.context).to receive(:shell).with(
22
+ "echo -e \"travis\nsecret\" | timeout 2 ./scalingo login 2> /dev/null > /dev/null"
23
+ ).and_return(true)
24
+ expect(provider.context).to receive(:shell).with(
25
+ 'DISABLE_INTERACTIVE=true ./scalingo login 2> /dev/null > /dev/null'
26
+ ).and_return(true)
27
+ provider.check_auth
28
+ end
29
+ end
30
+
31
+ describe "#setup_key" do
32
+ example do
33
+ expect(provider.context).to receive(:shell).with(
34
+ './scalingo keys-add dpl_tmp_key key_file'
35
+ ).and_return(true)
36
+ expect(provider.context).to receive(:shell).with(
37
+ 'DISABLE_INTERACTIVE=true ./scalingo login 2> /dev/null > /dev/null'
38
+ ).and_return(true)
39
+ provider.setup_key('key_file')
40
+ end
41
+ end
42
+
43
+ describe "#remove_key" do
44
+ example do
45
+ expect(provider.context).to receive(:shell).with(
46
+ './scalingo keys-remove dpl_tmp_key'
47
+ ).and_return(true)
48
+ expect(provider.context).to receive(:shell).with(
49
+ 'DISABLE_INTERACTIVE=true ./scalingo login 2> /dev/null > /dev/null'
50
+ ).and_return(true)
51
+ provider.remove_key
52
+ end
53
+ end
54
+
55
+ describe "#push_app" do
56
+ example do
57
+ expect(provider.context).to receive(:shell).with(
58
+ 'git push scalingo master -f'
59
+ ).and_return(true)
60
+ provider.push_app
61
+ end
62
+ end
63
+
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.8.travis.1179.4
4
+ version: 1.8.8.travis.1183.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -158,6 +158,7 @@ files:
158
158
  - lib/dpl/provider/releases.rb
159
159
  - lib/dpl/provider/rubygems.rb
160
160
  - lib/dpl/provider/s3.rb
161
+ - lib/dpl/provider/scalingo.rb
161
162
  - lib/dpl/provider/script.rb
162
163
  - lib/dpl/provider/testfairy.rb
163
164
  - lib/dpl/provider/transifex.rb
@@ -202,6 +203,7 @@ files:
202
203
  - spec/provider/releases_spec.rb
203
204
  - spec/provider/rubygems_spec.rb
204
205
  - spec/provider/s3_spec.rb
206
+ - spec/provider/scalingo_spec.rb
205
207
  - spec/provider/script_spec.rb
206
208
  - spec/provider/testfairy_spec.rb
207
209
  - spec/provider/transifex_spec.rb