escobar 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -3
- data/README.md +0 -2
- data/lib/escobar/github/client.rb +12 -15
- data/lib/escobar/heroku/app.rb +5 -0
- data/lib/escobar/heroku/client.rb +17 -0
- data/lib/escobar/heroku/pipeline.rb +2 -2
- data/lib/escobar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4504457f5bf33b345fdb8250cff7d246a07c1102
|
4
|
+
data.tar.gz: 8780426f0b46903792a101954476e1781c9128f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afd9fbe836337dcdd8eaee118bb8e246a500ca1b65bd3a92acafd85b4a217383ec3426b9b744ea67bf9aaf70ec9b4cedb9b6c91c8be1987fc1883fdb67e432d8
|
7
|
+
data.tar.gz: 953d97c4041b6669c3caa9fb485e2c93a83b7db63a37f0e6daef3bf0a72e2278874072fd3d704b06e15759e50ffadae59c79472d84b9ee012c212b8a1df1e2e2
|
data/.rubocop.yml
CHANGED
@@ -74,6 +74,9 @@ MethodLength:
|
|
74
74
|
Max: 25
|
75
75
|
Severity: error
|
76
76
|
|
77
|
+
FrozenStringLiteralComment:
|
78
|
+
Enabled: false # Adding comment to all files...
|
79
|
+
|
77
80
|
Alias:
|
78
81
|
Enabled: false # We have no guidance on alias vs alias_method
|
79
82
|
|
@@ -87,6 +90,7 @@ Metrics/AbcSize:
|
|
87
90
|
Max: 16
|
88
91
|
|
89
92
|
AllCops:
|
93
|
+
TargetRubyVersion: 2.3
|
90
94
|
# Include gemspec and Rakefile
|
91
95
|
Include:
|
92
96
|
- '**/*.gemspec'
|
@@ -103,7 +107,9 @@ AllCops:
|
|
103
107
|
- 'script/**/*'
|
104
108
|
- 'config/**/*'
|
105
109
|
- 'vendor/**/*'
|
106
|
-
|
107
|
-
|
110
|
+
# By default, the rails cops are not run. Override in project or home
|
111
|
+
# directory .rubocop.yml files, or by giving the -R/--rails option.
|
108
112
|
Rails:
|
109
|
-
Enabled:
|
113
|
+
Enabled: true
|
114
|
+
Rails/Delegate:
|
115
|
+
Enabled: false # delegate isn't available outside of rails?
|
data/README.md
CHANGED
@@ -18,8 +18,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
18
18
|
|
19
19
|
Bug reports and pull requests are welcome on GitHub at https://github.com/atmos/escobar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
20
20
|
|
21
|
-
|
22
21
|
## License
|
23
22
|
|
24
23
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
25
|
-
|
@@ -26,28 +26,25 @@ module Escobar
|
|
26
26
|
response && response.headers && response.headers["Location"]
|
27
27
|
end
|
28
28
|
|
29
|
+
def not_found
|
30
|
+
raise RepoNotFound, "Unable to access #{name_with_owner}"
|
31
|
+
end
|
32
|
+
|
29
33
|
def required_contexts
|
30
34
|
path = "/repos/#{name_with_owner}/branches/#{default_branch}"
|
31
35
|
response = http_method(:get, path)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
else
|
40
|
-
raise RepoNotFound, "Unable to access #{name_with_owner}"
|
41
|
-
end
|
36
|
+
|
37
|
+
not_found unless response.status == 200
|
38
|
+
|
39
|
+
repo = JSON.parse(response.body)
|
40
|
+
return [] unless repo["protection"] && repo["protection"]["enabled"]
|
41
|
+
repo["protection"]["required_status_checks"]["contexts"]
|
42
42
|
end
|
43
43
|
|
44
44
|
def default_branch
|
45
45
|
response = http_method(:get, "/repos/#{name_with_owner}")
|
46
|
-
|
47
|
-
|
48
|
-
else
|
49
|
-
raise RepoNotFound, "Unable to access #{name_with_owner}"
|
50
|
-
end
|
46
|
+
not_found unless response.status == 200
|
47
|
+
JSON.parse(response.body)["default_branch"]
|
51
48
|
end
|
52
49
|
|
53
50
|
def create_deployment(options)
|
data/lib/escobar/heroku/app.rb
CHANGED
@@ -19,6 +19,11 @@ module Escobar
|
|
19
19
|
def dashboard_url
|
20
20
|
"https://dashboard.heroku.com/apps/#{name}"
|
21
21
|
end
|
22
|
+
|
23
|
+
# Accepts either google authenticator or yubikey second_factor formatting
|
24
|
+
def preauth(second_factor)
|
25
|
+
!client.heroku.put("/apps/#{id}/pre-authorizations", second_factor).any?
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -61,6 +61,23 @@ module Escobar
|
|
61
61
|
response && response.body
|
62
62
|
end
|
63
63
|
|
64
|
+
def put(path, second_factor = nil)
|
65
|
+
response = client.put do |request|
|
66
|
+
request.url path
|
67
|
+
request.headers["Accept"] = heroku_accept_header(3)
|
68
|
+
request.headers["Accept-Encoding"] = ""
|
69
|
+
request.headers["Content-Type"] = "application/json"
|
70
|
+
request.headers["Authorization"] = "Bearer #{token}"
|
71
|
+
if second_factor
|
72
|
+
request.headers["Heroku-Two-Factor-Code"] = second_factor
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
JSON.parse(response.body)
|
77
|
+
rescue StandardError
|
78
|
+
response && response.body
|
79
|
+
end
|
80
|
+
|
64
81
|
private
|
65
82
|
|
66
83
|
def heroku_accept_header(version)
|
@@ -97,7 +97,7 @@ module Escobar
|
|
97
97
|
when "two_factor"
|
98
98
|
description = "A second factor is required. Use your configured authenticator app or yubikey."
|
99
99
|
create_github_deployment_status(github_deployment["url"], nil, "failure", description)
|
100
|
-
|
100
|
+
{ error: build["message"] }
|
101
101
|
when Escobar::Heroku::BuildRequestSuccess
|
102
102
|
target_url = "https://dashboard.heroku.com/apps/#{app.name}/activity/builds/#{build['id']}"
|
103
103
|
|
@@ -112,7 +112,7 @@ module Escobar
|
|
112
112
|
deployment_url: github_deployment["url"]
|
113
113
|
}
|
114
114
|
else
|
115
|
-
|
115
|
+
{ error: "Unable to create heroku build for #{name}" }
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
data/lib/escobar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escobar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Donohoe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|