dpl-scalingo 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/dpl-scalingo.gemspec +3 -0
- data/lib/dpl/provider/scalingo.rb +97 -0
- data/spec/provider/scalingo_spec.rb +64 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ddcfe48a04165cde9fb6210cccddee27cf76e9d
|
4
|
+
data.tar.gz: b9e5b1a8fbd85fbe68320a19f308663b28da4ea3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7cff518804e3da40bf96a07f6c080370c5817e6e32ab7449044559253ec4b35cf277e634d767e613a279e422230173e952e92792e5e1f3c57920af1c9b40aff5
|
7
|
+
data.tar.gz: 817da04afe8110fe5f8a6f04d8c87a591f0990c2f9b71e07b2d061a5a85b347c16ab3cad6076e4e44ae8579ca9e6e6396d66d836d75d50c02042e27d5ca34a61
|
@@ -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
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dpl-scalingo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Haase
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dpl
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-its
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json_pure
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tins
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: highline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: deploy tool abstraction for clients
|
126
|
+
email: konstantin.mailinglists@googlemail.com
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
131
|
+
- dpl-scalingo.gemspec
|
132
|
+
- lib/dpl/provider/scalingo.rb
|
133
|
+
- spec/provider/scalingo_spec.rb
|
134
|
+
homepage: https://github.com/travis-ci/dpl
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.2'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.6.13
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: deploy tool
|
158
|
+
test_files:
|
159
|
+
- spec/provider/scalingo_spec.rb
|