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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTlmNzM3YjU0YzFkYjVmYTNjOWZmNWZiMmIzNjgxNDZiYzNmOGM1MQ==
4
+ NjhkOTM5MjIwOGJkNDc5ZTViY2NlZjY1ODg2YjU1OTQ0YjU2NmIxYg==
5
5
  data.tar.gz: !binary |-
6
- MjZhOTk4NmYwYzQ0NTYwODcyYTNlMzIxZmI0NTViMDRhMTRlOTJkOA==
6
+ Yjc1N2EyMjI4OTFlYzE2NWQzOTg1NTE0OWM0Y2I2ZDE2NDg1NTI1OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzIwNmZiNjI1NmYzMTc3NmU3ODIyYTQxNDY2MTY4YmQ4MjY3MGRmYmQzNjcz
10
- YjRlNDM4NDEwNTdkYTY3ZWUwNzQ4ZmQ3ZDg2ZjQ4OTdhYjU3NzQyMzhiOGMy
11
- NDhiYTlmZWE4NmYzMDFiZjRjODVmZjYyMDIwYWQ0MjJlZDBjOGI=
9
+ NGRjMmJiOGI5ZDBmOTYyMjBiNTAwN2IxMmI3NjhlY2IwOWNmNTk0MWEwOTFm
10
+ N2I5OTYyOGYxOGNiYTFkNmI0ODAzOGYxOWUxMjhlOTMwNjZkN2RiNjNmYjIw
11
+ MzgwM2NmMzZlOTRlY2ZlZjk1NzRkODJjMjNiNTY1ZmVmY2QxYWM=
12
12
  data.tar.gz: !binary |-
13
- MmZiZTBiYjFjZTg0NTMzZTM3NWQyZWYyMWFhNDZlOGZkZDdkZmU5OWJiODY3
14
- MTI0ZDI5OTY4NGQwZDcxYjU4ZTQ4ODVmMzlkZDMwYWJiNjhlYTM1MzAwNjYy
15
- NjdmZjcxOGMzNmI0OGY1OGY4Y2IxZjA3NjMzYzcyNzUzYjUzMDQ=
13
+ YzVhOWZmYjM1YTU2YjhkMmI3YmZhODZiOTc4ZGMwY2M0YjAxNGE5YWZkYTg0
14
+ ZDkzMTI5ZTkwNjE3YTBhN2I2OWIzN2MyYmNkZDY1MmFjNDJiMDA1M2ViODdm
15
+ YTUxMmZkZTRiMzIyMTNiNjAwY2Q5NDZiZGM3ZTI3MDhmNDQ5Mjk=
data/Gemfile CHANGED
@@ -2,3 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in aptly_cli.gemspec
4
4
  gemspec
5
+
6
+ gem "keyring", require: false, platform: :ruby_20
7
+
8
+ group :test do
9
+ gem "rubocop", require: false
10
+ gem "simplecov", require: false
11
+ end
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 configuration file above will be used
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
- aptly-cli --help
57
-
58
- file_delete Deletes all files in upload directory and directory itself. Or delete just a file
59
- file_list List all directories that contain uploaded files
60
- file_upload Parameter --directory is upload directory name. Directory would be created if it doesn’t exist.
61
- graph Download a graph of repository layout. Current options are "svg" and "png"
62
- help Display global or [command] help documentation
63
- publish_drop Delete published repository, clean up files in published directory.
64
- publish_list List published repositories.
65
- publish_repo Publish local repository or snapshot under specified prefix. Storage might be passed in prefix as well, e.g. s3:packages/. To supply empty prefix, just remove last part (POST /api/publish/:prefix/<:repos>or<:snapshots>
66
- publish_update Update published repository. If local repository has been published, published repository would be updated to match local repository contents. If snapshots have been been published, it is possible to switch each component to new snapshot
67
- repo_create Create a new repository, requires --name
68
- repo_delete Delete a local repository, requires --name
69
- repo_edit Edit a local repository metadata, requires --name
70
- repo_list Show list of currently available local repositories
71
- repo_package_query List all packages in local repository or perform search on repository contents and return result., requires --name
72
- repo_show Returns basic information about local repository
73
- repo_upload Import packages from files (uploaded using File Upload API) to the local repository. If directory specified, aptly would discover package files automatically.Adding same package to local repository is not an error. By default aptly would try to remove every successfully processed file and directory :dir (if it becomes empty after import).
74
- snapshot_create Create snapshot of current local repository :name contents as new snapshot with name :snapname
75
- snapshot_delete Delete snapshot. Snapshot can’t be deleted if it is published. aptly would refuse to delete snapshot if it has been used as source to create other snapshots, but that could be overridden with force parameter
76
- snapshot_diff Calculate difference between two snapshots --name (left) and --withsnapshot (right).
77
- snapshot_list Return list of all snapshots created in the system
78
- snapshot_search List all packages in snapshot or perform search on snapshot contents and return result
79
- snapshot_show Get information about snapshot by name
80
- snapshot_update Update snapshot’s description or name
81
- version Display aptly server
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"
@@ -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('--username USERNAME', 'User name') do |username|
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
@@ -1,3 +1,3 @@
1
1
  module AptlyCli
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.1'.freeze
3
3
  end
@@ -1,55 +1,71 @@
1
- class AptlyCommand
2
- def initialize(config, options = nil)
3
- @config = config
4
- options ||= Options.new
1
+ module AptlyCli
2
+ class AptlyCommand
3
+ include HTTMultiParty
5
4
 
6
- if options.server
7
- @config[:server] = options.server
8
- end
5
+ attr_accessor :config
9
6
 
10
- if options.username
11
- @config[:username] = options.username
12
- end
7
+ def initialize(config, options = nil)
8
+ @config = config
9
+ options ||= Options.new
13
10
 
14
- if options.password
15
- @config[:password] = options.password
16
- end
11
+ if options.respond_to?(:server) && options.server
12
+ @config[:server] = options.server
13
+ end
17
14
 
18
- if options.debug
19
- @config[:debug] = options.debug
20
- end
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
- @config.each do |k, v|
23
- if v == '${PROMPT}'
24
- @config[k.to_sym] = ask("Enter a value for #{k}:")
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
- keyring = Keyring.new
31
- value = keyring.get_password(@config[:server], @config[:username])
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
- unless value
34
- # Prompt for password...
35
- value = password("Enter a value for #{k}:")
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
- # ... and store in keyring
38
- keyring.set_password(@config[:server], @config[:username], value)
39
- end
44
+ unless value
45
+ # Prompt for password...
46
+ value = password("Enter a value for #{k}:")
40
47
 
41
- @config[k.to_sym] = value
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
- base_uri = "#{@config[:proto]}://#{@config[:server]}:#{@config[:port]}/api"
46
- self.class.base_uri base_uri
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
- if @config[:username]
49
- if @config[:password]
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
@@ -6,7 +6,6 @@ require 'httmultiparty'
6
6
  module AptlyCli
7
7
  # Uploading file into Aptly
8
8
  class AptlyFile < AptlyCommand
9
- include HTTMultiParty
10
9
  attr_accessor :file_uri, :package, :local_file_path
11
10
 
12
11
  def file_dir
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.0
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-19 00:00:00.000000000 Z
11
+ date: 2016-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler