aptly_cli 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +7 -0
- data/README.md +128 -32
- data/Rakefile +7 -0
- data/bin/aptly-cli +12 -5
- data/lib/aptly_cli/version.rb +1 -1
- data/lib/aptly_command.rb +55 -39
- data/lib/aptly_file.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjhkOTM5MjIwOGJkNDc5ZTViY2NlZjY1ODg2YjU1OTQ0YjU2NmIxYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yjc1N2EyMjI4OTFlYzE2NWQzOTg1NTE0OWM0Y2I2ZDE2NDg1NTI1OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGRjMmJiOGI5ZDBmOTYyMjBiNTAwN2IxMmI3NjhlY2IwOWNmNTk0MWEwOTFm
|
10
|
+
N2I5OTYyOGYxOGNiYTFkNmI0ODAzOGYxOWUxMjhlOTMwNjZkN2RiNjNmYjIw
|
11
|
+
MzgwM2NmMzZlOTRlY2ZlZjk1NzRkODJjMjNiNTY1ZmVmY2QxYWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzVhOWZmYjM1YTU2YjhkMmI3YmZhODZiOTc4ZGMwY2M0YjAxNGE5YWZkYTg0
|
14
|
+
ZDkzMTI5ZTkwNjE3YTBhN2I2OWIzN2MyYmNkZDY1MmFjNDJiMDA1M2ViODdm
|
15
|
+
YTUxMmZkZTRiMzIyMTNiNjAwY2Q5NDZiZGM3ZTI3MDhmNDQ5Mjk=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -12,9 +12,9 @@ A command line interface to execute [Aptly](http://aptly.info) commands againts
|
|
12
12
|
### Install Gem:
|
13
13
|
|
14
14
|
$ gem install aptly_cli
|
15
|
-
|
16
|
-
or...
|
17
|
-
|
15
|
+
|
16
|
+
or...
|
17
|
+
|
18
18
|
### Install and run aptly-cli from Docker:
|
19
19
|
|
20
20
|
# Optional: If you don't pull explicitly, `docker run` will do it for you
|
@@ -47,42 +47,138 @@ If you use Basic Authentication to protect your API, add username and password:
|
|
47
47
|
:password: api-password
|
48
48
|
```
|
49
49
|
|
50
|
+
The username and password can also be configured for prompt entry using
|
51
|
+
the following in `aptly-cli.conf`:
|
52
|
+
|
53
|
+
```yaml
|
54
|
+
:username: ${PROMPT}
|
55
|
+
:password: ${PROMPT_PASSWORD}
|
56
|
+
```
|
57
|
+
|
58
|
+
The tool will prompt for the specified values, where `${PROMPT}` results
|
59
|
+
in a regular prompt and `${PROMPT_PASSWORD}` results in a password
|
60
|
+
prompt where the input is replaced by asterisks, e.g.:
|
61
|
+
|
62
|
+
$ aptly-cli version
|
63
|
+
Enter a value for username:
|
64
|
+
zane
|
65
|
+
Enter a value for password:
|
66
|
+
********
|
67
|
+
|
68
|
+
Another possibility for storing passwords is `${KEYRING}`. To use this feature,
|
69
|
+
you must have the [`keyring` gem](https://github.com/jheiss/keyring) installed
|
70
|
+
and also have a system that is set up to use one of the backends that the
|
71
|
+
`keyring` gem supports, such as Mac OS X Keychain or GNOME 2 Keyring (Note:
|
72
|
+
Only Mac OS X Keychain has been tested thus far):
|
73
|
+
|
74
|
+
$ gem install keyring
|
75
|
+
|
76
|
+
Then you can put something like this in `aptly-cli.conf`:
|
77
|
+
|
78
|
+
```yaml
|
79
|
+
:username: zane
|
80
|
+
:password: ${KEYRING}
|
81
|
+
```
|
82
|
+
|
83
|
+
The first time you run an `aptly-cli` command, you will be prompted to enter a
|
84
|
+
password.
|
85
|
+
|
86
|
+
$ aptly-cli version
|
87
|
+
Enter a value for password:
|
88
|
+
***************
|
89
|
+
|
90
|
+
The entered password will be stored in your keyring so that future uses of
|
91
|
+
`aptly-cli` can get the password from your keyring:
|
92
|
+
|
93
|
+
$ aptly-cli version
|
94
|
+
{"Version"=>"0.9.7"}
|
95
|
+
|
50
96
|
Also make sure that your config file isn't world readable (```chmod o-rw /etc/aptly-cli.conf```)
|
51
97
|
|
52
|
-
If a configuration file is not found the defaults in the example
|
98
|
+
If a configuration file is not found, the defaults in the example
|
99
|
+
configuration file above will be used.
|
53
100
|
|
54
101
|
## Usage - available aptly-cli commands
|
55
102
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
103
|
+
The `--config` (`-c`) option allows specifying an alternative config file, e.g.:
|
104
|
+
|
105
|
+
$ aptly-cli -c ~/.config/aptly-cli/aptly-cli.conf repo_list
|
106
|
+
|
107
|
+
The `--server`, `--username`, and `--password` options allow specifying
|
108
|
+
those things on the command-line and not even requiring a config file.
|
109
|
+
|
110
|
+
$ aptly-cli --server 10.3.0.46 --username marca --password '${PROMPT_PASSWORD}' repo_list
|
111
|
+
|
112
|
+
Note that you can use `${PROMPT}`, `${PROMPT_PASSWORD}`, and `${KEYRING}` in
|
113
|
+
the values of these options, just as you can in a config file. Note that you
|
114
|
+
might have to quote them to prevent the shell from trying to expand them.
|
115
|
+
|
116
|
+
$ aptly-cli --help
|
117
|
+
NAME:
|
118
|
+
|
119
|
+
aptly-cli
|
120
|
+
|
121
|
+
DESCRIPTION:
|
122
|
+
|
123
|
+
Aptly repository API client
|
124
|
+
|
125
|
+
COMMANDS:
|
126
|
+
|
127
|
+
file_delete File delete
|
128
|
+
file_list List all directories
|
129
|
+
file_upload File upload
|
130
|
+
graph Download an svg or png graph of repository layout
|
131
|
+
help Display global or [command] help documentation
|
132
|
+
publish_drop Delete published repository
|
133
|
+
publish_list List published repositories
|
134
|
+
publish_repo Publish local repository or snapshot under specified prefix
|
135
|
+
publish_update Update published repository
|
136
|
+
repo_create Create a new repository, requires --name
|
137
|
+
repo_delete Delete a local repository, requires --name
|
138
|
+
repo_edit Edit a local repository metadata, requires --name
|
139
|
+
repo_list Show list of currently available local repositories
|
140
|
+
repo_package_query List all packages or search on repo contents, requires --name
|
141
|
+
repo_show Returns basic information about local repository
|
142
|
+
repo_upload Import packages from files
|
143
|
+
snapshot_create Create snapshot, require --name
|
144
|
+
snapshot_delete Delete snapshot, require --name
|
145
|
+
snapshot_diff Calculate difference between two snapshots
|
146
|
+
snapshot_list Return list of all snapshots created in the system
|
147
|
+
snapshot_search List all packages in snapshot or perform search
|
148
|
+
snapshot_show Get information about snapshot by name
|
149
|
+
snapshot_update Update snapshot’s description or name
|
150
|
+
version Display aptly server version
|
151
|
+
|
152
|
+
GLOBAL OPTIONS:
|
153
|
+
|
154
|
+
-c, --config FILE
|
155
|
+
Path to YAML config file
|
156
|
+
|
157
|
+
-s, --server SERVER
|
158
|
+
Host name or IP address
|
159
|
+
|
160
|
+
--username USERNAME
|
161
|
+
User name
|
162
|
+
|
163
|
+
--password PASSWORD
|
164
|
+
Password
|
165
|
+
|
166
|
+
--debug
|
167
|
+
Enable debug output
|
168
|
+
|
169
|
+
-h, --help
|
170
|
+
Display help documentation
|
171
|
+
|
172
|
+
-v, --version
|
173
|
+
Display version information
|
174
|
+
|
175
|
+
-t, --trace
|
176
|
+
Display backtrace when an error occurs
|
177
|
+
|
178
|
+
|
83
179
|
### To see more options for each command
|
84
180
|
|
85
|
-
aptly-cli <command> --help
|
181
|
+
$ aptly-cli <command> --help
|
86
182
|
|
87
183
|
|
88
184
|
## Development
|
data/Rakefile
CHANGED
@@ -2,6 +2,13 @@ require "bundler/gem_tasks"
|
|
2
2
|
|
3
3
|
require "rake/testtask"
|
4
4
|
|
5
|
+
begin
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
RuboCop::RakeTask.new
|
8
|
+
rescue LoadError
|
9
|
+
puts 'Install "rubocop" to enable rubocop Rake task.'
|
10
|
+
end
|
11
|
+
|
5
12
|
Rake::TestTask.new do |t|
|
6
13
|
t.libs << "lib"
|
7
14
|
t.libs << "test"
|
data/bin/aptly-cli
CHANGED
@@ -5,11 +5,12 @@ require 'rubygems'
|
|
5
5
|
require 'commander/import'
|
6
6
|
require 'aptly_cli'
|
7
7
|
|
8
|
-
program :version, AptlyCli::VERSION
|
9
|
-
program :description, 'Aptly repository API client'
|
8
|
+
program :version, AptlyCli::VERSION
|
9
|
+
program :description, 'Aptly repository API client (https://github.com/sepulworld/aptly_cli)'
|
10
10
|
|
11
11
|
$config_file = '/etc/aptly-cli.conf'
|
12
12
|
$server = nil
|
13
|
+
$port = nil
|
13
14
|
$username = nil
|
14
15
|
$password = nil
|
15
16
|
$debug = false
|
@@ -18,13 +19,16 @@ global_option('-c', '--config FILE', 'Path to YAML config file') do |config_file
|
|
18
19
|
$config_file = config_file
|
19
20
|
end
|
20
21
|
|
21
|
-
global_option('-s', '--server SERVER', 'Host name or IP address') do |server|
|
22
|
+
global_option('-s', '--server SERVER', 'Host name or IP address of Aptly API server') do |server|
|
22
23
|
$server = server
|
23
24
|
end
|
24
|
-
global_option('--
|
25
|
+
global_option('-p', '--port PORT', 'Port of Aptly API server') do |port|
|
26
|
+
$port = port
|
27
|
+
end
|
28
|
+
global_option('--username USERNAME', 'User name or \'${PROMPT}\'') do |username|
|
25
29
|
$username = username
|
26
30
|
end
|
27
|
-
global_option('--password PASSWORD', 'Password') do |password|
|
31
|
+
global_option('--password PASSWORD', 'Password or \'${PROMPT_PASSWORD}\' or \'${KEYRING}\'') do |password|
|
28
32
|
$password = password
|
29
33
|
end
|
30
34
|
global_option('--debug', 'Enable debug output') do
|
@@ -35,6 +39,9 @@ def handle_global_options(options)
|
|
35
39
|
if $server
|
36
40
|
options.server = $server
|
37
41
|
end
|
42
|
+
if $port
|
43
|
+
options.port = $port
|
44
|
+
end
|
38
45
|
if $username
|
39
46
|
options.username = $username
|
40
47
|
end
|
data/lib/aptly_cli/version.rb
CHANGED
data/lib/aptly_command.rb
CHANGED
@@ -1,55 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
options ||= Options.new
|
1
|
+
module AptlyCli
|
2
|
+
class AptlyCommand
|
3
|
+
include HTTMultiParty
|
5
4
|
|
6
|
-
|
7
|
-
@config[:server] = options.server
|
8
|
-
end
|
5
|
+
attr_accessor :config
|
9
6
|
|
10
|
-
|
11
|
-
@config
|
12
|
-
|
7
|
+
def initialize(config, options = nil)
|
8
|
+
@config = config
|
9
|
+
options ||= Options.new
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
if options.respond_to?(:server) && options.server
|
12
|
+
@config[:server] = options.server
|
13
|
+
end
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
if options.respond_to?(:port) && options.port
|
16
|
+
@config[:port] = options.port
|
17
|
+
end
|
18
|
+
|
19
|
+
if options.respond_to?(:username) && options.username
|
20
|
+
@config[:username] = options.username
|
21
|
+
end
|
22
|
+
|
23
|
+
if options.respond_to?(:password) && options.password
|
24
|
+
@config[:password] = options.password
|
25
|
+
end
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
elsif v == '${PROMPT_PASSWORD}'
|
26
|
-
@config[k.to_sym] = password("Enter a value for #{k}:")
|
27
|
-
elsif v == '${KEYRING}'
|
28
|
-
require 'keyring'
|
27
|
+
if options.respond_to?(:debug) && options.debug
|
28
|
+
@config[:debug] = options.debug
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
@config.each do |k, v|
|
32
|
+
if v == '${PROMPT}'
|
33
|
+
@config[k.to_sym] = ask("Enter a value for #{k}:")
|
34
|
+
elsif v == '${PROMPT_PASSWORD}'
|
35
|
+
@config[k.to_sym] = password("Enter a value for #{k}:")
|
36
|
+
elsif v == '${KEYRING}'
|
37
|
+
require 'keyring'
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
keyring = Keyring.new
|
40
|
+
keychain_item_name = 'Aptly API server at ' + \
|
41
|
+
@config[:server] + ':' + @config[:port].to_s
|
42
|
+
value = keyring.get_password(keychain_item_name, @config[:username])
|
36
43
|
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
unless value
|
45
|
+
# Prompt for password...
|
46
|
+
value = password("Enter a value for #{k}:")
|
40
47
|
|
41
|
-
|
48
|
+
# ... and store in keyring
|
49
|
+
keyring.set_password(keychain_item_name, @config[:username], value)
|
50
|
+
end
|
51
|
+
|
52
|
+
@config[k.to_sym] = value
|
53
|
+
end
|
42
54
|
end
|
43
|
-
end
|
44
55
|
|
45
|
-
|
46
|
-
|
56
|
+
base_uri = "#{@config[:proto]}://#{@config[:server]}:#{@config[:port]}" \
|
57
|
+
'/api'
|
58
|
+
self.class.base_uri base_uri
|
59
|
+
|
60
|
+
if @config[:username]
|
61
|
+
if @config[:password]
|
62
|
+
self.class.basic_auth @config[:username].to_s, @config[:password].to_s
|
63
|
+
end
|
64
|
+
end
|
47
65
|
|
48
|
-
|
49
|
-
|
50
|
-
self.class.basic_auth @config[:username].to_s, @config[:password].to_s
|
66
|
+
if respond_to?(:debug_output)
|
67
|
+
debug_output $stdout if @config[:debug] == true
|
51
68
|
end
|
52
69
|
end
|
53
|
-
debug_output $stdout if @config[:debug] == true
|
54
70
|
end
|
55
71
|
end
|
data/lib/aptly_file.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptly_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|