package_cloud 0.2.42 → 0.2.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/package_cloud.rb +1 -0
- data/lib/package_cloud/cli.rb +16 -0
- data/lib/package_cloud/cli/entry.rb +3 -0
- data/lib/package_cloud/cli/gpg_key.rb +76 -0
- data/lib/package_cloud/cli/master_token.rb +0 -16
- data/lib/package_cloud/gpg_key.rb +13 -0
- data/lib/package_cloud/repository.rb +30 -0
- data/lib/package_cloud/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd8d70baa95dc0392b7628081e7ada402add8d1b
|
4
|
+
data.tar.gz: b11a15ec9e89258aa65014ba8d0b8d4618080aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daa87bc509eec63173f9f0b416cff5fba27219fda4a8be4aba9fcfb6b10803266ce0514c8b548ad4451ce649f22c7b16d9f370431a9b8328683e641c6d0efca0
|
7
|
+
data.tar.gz: 57ff22ab7445689ecb7d41b3759b8ab1b020dbd6ffcf7baac9e2e577084a1b5baddba8873b4c9ac62fa51af316b221146dcb53d3710ce6cd43d2fb7fec489a81
|
data/lib/package_cloud.rb
CHANGED
data/lib/package_cloud/cli.rb
CHANGED
@@ -9,6 +9,7 @@ module PackageCloud
|
|
9
9
|
autoload :MasterToken, "package_cloud/cli/master_token"
|
10
10
|
autoload :ReadToken, "package_cloud/cli/read_token"
|
11
11
|
autoload :Repository, "package_cloud/cli/repository"
|
12
|
+
autoload :GpgKey, "package_cloud/cli/gpg_key"
|
12
13
|
|
13
14
|
class Base < Thor
|
14
15
|
class_option "config"
|
@@ -16,6 +17,21 @@ module PackageCloud
|
|
16
17
|
class_option "verbose"
|
17
18
|
|
18
19
|
private
|
20
|
+
def get_valid(prompt)
|
21
|
+
selection = ""
|
22
|
+
times = 0
|
23
|
+
until yield(selection)
|
24
|
+
if times > 0
|
25
|
+
puts "#{selection} is not a valid selection."
|
26
|
+
end
|
27
|
+
print "#{prompt}: "
|
28
|
+
selection = ::Kernel.gets.chomp
|
29
|
+
times += 1
|
30
|
+
end
|
31
|
+
|
32
|
+
selection
|
33
|
+
end
|
34
|
+
|
19
35
|
def config
|
20
36
|
$logger = ::Logger.new(STDOUT)
|
21
37
|
$verbose = !!options[:verbose]
|
@@ -13,6 +13,9 @@ module PackageCloud
|
|
13
13
|
desc "read_token SUBCMD ...ARGS", "manage read tokens"
|
14
14
|
subcommand "read_token", ReadToken
|
15
15
|
|
16
|
+
desc "gpg_key SUBCMD ...ARGS", "manage GPG keys"
|
17
|
+
subcommand "gpg_key", GpgKey
|
18
|
+
|
16
19
|
desc "promote user/repo[/distro/version] package_name user/destination_repo",
|
17
20
|
"promotes a package from user/repo [in dist/version] to user/destination_repo [also in dist/version]"
|
18
21
|
def promote(source_repo_desc, package_name, dest_repo_desc)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module PackageCloud
|
2
|
+
module CLI
|
3
|
+
class GpgKey < Base
|
4
|
+
desc "list user/repository",
|
5
|
+
"list all GPG keys for specified repository"
|
6
|
+
def list(repo_name)
|
7
|
+
print "Looking for repository at #{repo_name}... "
|
8
|
+
repo = client.repository(repo_name)
|
9
|
+
print "success!\n"
|
10
|
+
|
11
|
+
keys = repo.gpg_keys
|
12
|
+
puts "GPG Keys for #{repo_name}:\n"
|
13
|
+
|
14
|
+
keys.each_with_index do |key, i|
|
15
|
+
if key.keytype == "package"
|
16
|
+
keytype = "Package signing key"
|
17
|
+
else
|
18
|
+
keytype = "Repository signing key"
|
19
|
+
end
|
20
|
+
|
21
|
+
puts "Key name: #{key.name}"
|
22
|
+
puts "Key type: #{keytype}"
|
23
|
+
puts "Key fingerprint: #{key.fingerprint}"
|
24
|
+
puts "GPG key url: #{key.download_url}"
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "create user/repository /path/to/gpg-key",
|
30
|
+
"create a package signing GPG key using the specified file"
|
31
|
+
def create(repo_name, file_path)
|
32
|
+
print "Looking for repository at #{repo_name}... "
|
33
|
+
repo = client.repository(repo_name)
|
34
|
+
print "success!\n"
|
35
|
+
repo.create_gpg_key(file_path)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "destroy user/repository keyname",
|
39
|
+
"destroy specified package signing GPG key"
|
40
|
+
def destroy(repo_name, keyname)
|
41
|
+
ARGV.clear
|
42
|
+
print "Looking for repository at #{repo_name}... "
|
43
|
+
repo = client.repository(repo_name)
|
44
|
+
print "success!\n"
|
45
|
+
|
46
|
+
key = repo.gpg_keys.detect do |key|
|
47
|
+
key.name == keyname
|
48
|
+
end
|
49
|
+
|
50
|
+
if key
|
51
|
+
msg = "\nAre you sure you want to delete the GPG key #{keyname}? (y/n)"
|
52
|
+
answer = get_valid(msg) do |s|
|
53
|
+
s == "y" || s == "n"
|
54
|
+
end
|
55
|
+
|
56
|
+
if answer == "y"
|
57
|
+
print "Attempting to destroy GPG key named #{keyname}... "
|
58
|
+
begin
|
59
|
+
key.destroy
|
60
|
+
rescue RestClient::ResourceNotFound =>e
|
61
|
+
print "\nError, could not find key: #{keyname}. No GPG keys deleted.\n".color(:red)
|
62
|
+
print "Please note that you cannot delete repository signing keys.\n"
|
63
|
+
exit(1)
|
64
|
+
else
|
65
|
+
print "success!\n".color(:green)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
puts "Aborting...".color(:red)
|
69
|
+
end
|
70
|
+
else
|
71
|
+
puts "Wasn't able to find a GPG key name: #{keyname}".color(:red)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -70,22 +70,6 @@ module PackageCloud
|
|
70
70
|
exit(1)
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
74
|
-
private
|
75
|
-
def get_valid(prompt)
|
76
|
-
selection = ""
|
77
|
-
times = 0
|
78
|
-
until yield(selection)
|
79
|
-
if times > 0
|
80
|
-
puts "#{selection} is not a valid selection."
|
81
|
-
end
|
82
|
-
print "#{prompt}: "
|
83
|
-
selection = ::Kernel.gets.chomp
|
84
|
-
times += 1
|
85
|
-
end
|
86
|
-
|
87
|
-
selection
|
88
|
-
end
|
89
73
|
end
|
90
74
|
end
|
91
75
|
end
|
@@ -77,6 +77,36 @@ module PackageCloud
|
|
77
77
|
file
|
78
78
|
end
|
79
79
|
|
80
|
+
def create_gpg_key(file_path)
|
81
|
+
file_data = File.new(file_path, 'rb')
|
82
|
+
base_url = @config.base_url
|
83
|
+
url = PackageCloud::Util.compute_url(@config.base_url, paths["gpg_keys"])
|
84
|
+
params = { keydata: file_data }
|
85
|
+
|
86
|
+
print "Attempting to upload key file #{file_path}... "
|
87
|
+
|
88
|
+
begin
|
89
|
+
RestClient::Request.execute(:method => 'post',
|
90
|
+
:url => url,
|
91
|
+
:timeout => -1,
|
92
|
+
:payload => { :gpg_key => params })
|
93
|
+
rescue RestClient::UnprocessableEntity => e
|
94
|
+
print "error: ".color(:red)
|
95
|
+
json = JSON.parse(e.response)
|
96
|
+
puts json["error"]
|
97
|
+
puts ""
|
98
|
+
exit(1)
|
99
|
+
end
|
100
|
+
|
101
|
+
print "success!\n".color(:green)
|
102
|
+
end
|
103
|
+
|
104
|
+
def gpg_keys
|
105
|
+
url = PackageCloud::Util.compute_url(@config.base_url, paths["gpg_keys"])
|
106
|
+
attrs = JSON.parse(RestClient.get(url))
|
107
|
+
attrs["gpg_keys"].map { |a| GpgKey.new(a, @config) }
|
108
|
+
end
|
109
|
+
|
80
110
|
def master_tokens
|
81
111
|
url = PackageCloud::Util.compute_url(@config.base_url, paths["master_tokens"])
|
82
112
|
attrs = JSON.parse(RestClient.get(url))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: package_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Damato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -127,11 +127,13 @@ files:
|
|
127
127
|
- lib/package_cloud/cli.rb
|
128
128
|
- lib/package_cloud/cli/distro.rb
|
129
129
|
- lib/package_cloud/cli/entry.rb
|
130
|
+
- lib/package_cloud/cli/gpg_key.rb
|
130
131
|
- lib/package_cloud/cli/master_token.rb
|
131
132
|
- lib/package_cloud/cli/read_token.rb
|
132
133
|
- lib/package_cloud/cli/repository.rb
|
133
134
|
- lib/package_cloud/client.rb
|
134
135
|
- lib/package_cloud/config_file.rb
|
136
|
+
- lib/package_cloud/gpg_key.rb
|
135
137
|
- lib/package_cloud/master_token.rb
|
136
138
|
- lib/package_cloud/object.rb
|
137
139
|
- lib/package_cloud/read_token.rb
|
@@ -160,9 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
162
|
version: '0'
|
161
163
|
requirements: []
|
162
164
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.4.4
|
164
166
|
signing_key:
|
165
167
|
specification_version: 4
|
166
168
|
summary: https://packagecloud.io
|
167
169
|
test_files: []
|
168
|
-
has_rdoc:
|