rake_circle_ci 0.8.0.pre.2 → 0.8.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/rake_circle_ci/client.rb +41 -8
- data/lib/rake_circle_ci/tasks.rb +1 -0
- data/lib/rake_circle_ci/tasks/checkout_keys.rb +9 -0
- data/lib/rake_circle_ci/tasks/checkout_keys/destroy.rb +32 -0
- data/lib/rake_circle_ci/tasks/checkout_keys/provision.rb +39 -0
- data/lib/rake_circle_ci/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1595ba13c3817f5913099d8a144da9e4353ca4eb822d3de130c44580be21c41
|
4
|
+
data.tar.gz: 41d4eafae97184eb8ba25ba0a64974e5461b69ee1277e5db900f3935d388a2bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d3c27ddbe3896dd379cfe06d514bdc4cbab4123513e3ca45f4490eca4979cd92a371dbcca6b0fda7f47629b538352e03c273810a95aad18de96ffc2c2aaa419
|
7
|
+
data.tar.gz: 23aa7b246d16daebb9578c6cf11cace268c1a57acf71f7b0bacd4541c282a33d96a49ead98fe60ad2167aad06010f7d7e28f53acb544d4f5811b593968664da8
|
data/Gemfile.lock
CHANGED
@@ -41,13 +41,8 @@ module RakeCircleCI
|
|
41
41
|
|
42
42
|
def find_ssh_keys
|
43
43
|
response = assert_successful(Excon.get(settings_url, headers: headers))
|
44
|
-
body = JSON.parse(response.body)
|
45
|
-
ssh_keys = body[
|
46
|
-
{
|
47
|
-
fingerprint: ssh_key["fingerprint"],
|
48
|
-
hostname: ssh_key["hostname"]
|
49
|
-
}
|
50
|
-
end
|
44
|
+
body = JSON.parse(response.body, symbolize_names: true)
|
45
|
+
ssh_keys = body[:ssh_keys]
|
51
46
|
|
52
47
|
ssh_keys
|
53
48
|
end
|
@@ -84,6 +79,36 @@ module RakeCircleCI
|
|
84
79
|
end
|
85
80
|
end
|
86
81
|
|
82
|
+
def find_checkout_keys
|
83
|
+
response = assert_successful(
|
84
|
+
Excon.get(checkout_keys_url, headers: headers))
|
85
|
+
checkout_keys = JSON.parse(response.body, symbolize_names: true)
|
86
|
+
|
87
|
+
checkout_keys
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_checkout_key(type)
|
91
|
+
type_strings = {
|
92
|
+
deploy_key: 'deploy-key',
|
93
|
+
github_user_key: 'github-user-key'
|
94
|
+
}
|
95
|
+
body = JSON.dump(type: type_strings[type.to_sym] || type.to_s)
|
96
|
+
assert_successful(
|
97
|
+
Excon.post(checkout_keys_url, body: body, headers: headers))
|
98
|
+
end
|
99
|
+
|
100
|
+
def delete_checkout_key(fingerprint)
|
101
|
+
assert_successful(
|
102
|
+
Excon.delete(checkout_key_url(fingerprint), headers: headers))
|
103
|
+
end
|
104
|
+
|
105
|
+
def delete_checkout_keys
|
106
|
+
checkout_keys = find_checkout_keys
|
107
|
+
checkout_keys.each do |checkout_key|
|
108
|
+
delete_checkout_key(checkout_key[:fingerprint])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
87
112
|
private
|
88
113
|
|
89
114
|
def headers
|
@@ -127,5 +152,13 @@ module RakeCircleCI
|
|
127
152
|
"#{@base_url}/v1.1/project/#{@project_slug}/ssh-key?" +
|
128
153
|
"circle-token=#{@api_token}"
|
129
154
|
end
|
155
|
+
|
156
|
+
def checkout_keys_url
|
157
|
+
"#{@base_url}/v1.1/project/#{@project_slug}/checkout-key"
|
158
|
+
end
|
159
|
+
|
160
|
+
def checkout_key_url(fingerprint)
|
161
|
+
"#{@base_url}/v1.1/project/#{@project_slug}/checkout-key/#{fingerprint}"
|
162
|
+
end
|
130
163
|
end
|
131
|
-
end
|
164
|
+
end
|
data/lib/rake_circle_ci/tasks.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rake_factory'
|
2
|
+
|
3
|
+
require_relative '../../client'
|
4
|
+
|
5
|
+
module RakeCircleCI
|
6
|
+
module Tasks
|
7
|
+
module CheckoutKeys
|
8
|
+
class Destroy < RakeFactory::Task
|
9
|
+
default_name :destroy
|
10
|
+
default_description RakeFactory::DynamicValue.new { |t|
|
11
|
+
"Destroy checkout keys in the #{t.project_slug} project"
|
12
|
+
}
|
13
|
+
|
14
|
+
parameter :project_slug, required: true
|
15
|
+
parameter :api_token, required: true
|
16
|
+
parameter :base_url, default: 'https://circleci.com/api'
|
17
|
+
|
18
|
+
action do |t|
|
19
|
+
client = Client.new(
|
20
|
+
base_url: t.base_url,
|
21
|
+
api_token: t.api_token,
|
22
|
+
project_slug: t.project_slug)
|
23
|
+
|
24
|
+
print "Destroying all checkout keys in the '#{t.project_slug}' " +
|
25
|
+
"project... "
|
26
|
+
client.delete_checkout_keys
|
27
|
+
puts "Done."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rake_factory'
|
2
|
+
|
3
|
+
require_relative '../../client'
|
4
|
+
|
5
|
+
module RakeCircleCI
|
6
|
+
module Tasks
|
7
|
+
module CheckoutKeys
|
8
|
+
class Provision < RakeFactory::Task
|
9
|
+
default_name :provision
|
10
|
+
default_description RakeFactory::DynamicValue.new { |t|
|
11
|
+
"Provision checkout keys on the #{t.project_slug} project"
|
12
|
+
}
|
13
|
+
|
14
|
+
parameter :project_slug, required: true
|
15
|
+
parameter :api_token, required: true
|
16
|
+
parameter :base_url, default: 'https://circleci.com/api'
|
17
|
+
parameter :checkout_keys, default: []
|
18
|
+
|
19
|
+
action do |t|
|
20
|
+
client = Client.new(
|
21
|
+
base_url: t.base_url,
|
22
|
+
api_token: t.api_token,
|
23
|
+
project_slug: t.project_slug)
|
24
|
+
|
25
|
+
puts "Provisioning all checkout keys to the '#{t.project_slug}' " +
|
26
|
+
"project... "
|
27
|
+
|
28
|
+
t.checkout_keys.each do |checkout_key|
|
29
|
+
type = checkout_key[:type]
|
30
|
+
|
31
|
+
print "Adding checkout key of type: '#{type}'..."
|
32
|
+
client.create_checkout_key(type)
|
33
|
+
puts "Done."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake_circle_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0.pre.
|
4
|
+
version: 0.8.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake_factory
|
@@ -242,6 +242,9 @@ files:
|
|
242
242
|
- lib/rake_circle_ci/task_sets/project.rb
|
243
243
|
- lib/rake_circle_ci/task_sets/ssh_keys.rb
|
244
244
|
- lib/rake_circle_ci/tasks.rb
|
245
|
+
- lib/rake_circle_ci/tasks/checkout_keys.rb
|
246
|
+
- lib/rake_circle_ci/tasks/checkout_keys/destroy.rb
|
247
|
+
- lib/rake_circle_ci/tasks/checkout_keys/provision.rb
|
245
248
|
- lib/rake_circle_ci/tasks/environment_variables.rb
|
246
249
|
- lib/rake_circle_ci/tasks/environment_variables/destroy.rb
|
247
250
|
- lib/rake_circle_ci/tasks/environment_variables/ensure.rb
|