package_cloud 0.0.3 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7137e29274423947660c706e21c9202f53ba02c046928cde787ed48ec06c714c
4
+ data.tar.gz: faecdd0f26599ff1c6eab2b1a17a31176f7cc281f6104adef446ff3a41f67065
5
+ SHA512:
6
+ metadata.gz: 3b21cf56b65cad88473a522d0863075c6aa7787945fca30475b919c711bacb58894d4df31a4cd42431a523e6492562b238457439e4cfc9fb628360f2e940d2d5
7
+ data.tar.gz: d420d301d173518bfb21b02aa9e422b79e3c4e34c1a9503b7ba0df4e008c7781fc67f4e79bb7ae8b53e8faf5aaaf8318644f65ade21ad76801f0534789d40c07
data/README.md CHANGED
@@ -1,29 +1,519 @@
1
- # PackageCloud
1
+ # packagecloud CLI
2
2
 
3
- TODO: Write a gem description
3
+ Greetings! Welcome to the [packagecloud](https://packagecloud.io) command line
4
+ client, `package_cloud`.
4
5
 
5
- ## Installation
6
+ ## Requirements
7
+
8
+ Only Ruby 2.6 and greater is supported, please use version 0.2.45 for Ruby 1.9 support.
9
+
10
+ ## Overview
6
11
 
7
- Add this line to your application's Gemfile:
12
+ The `package_cloud` command line client allows you to easily:
8
13
 
9
- gem 'package_cloud'
14
+ * Create Node.js, Debian, RPM, RubyGem, Python, and Maven package repositories
15
+ on [packagecloud](https://packagecloud.io).
16
+ * Upload Node.js, Debian, RPM, RubyGem, Python, and Java JAR/WAR/AAR packages
17
+ to your repositories.
18
+ * [Delete packages](https://packagecloud.io/docs#yank_pkg).
19
+ * [Promote packages](https://packagecloud.io/docs#promote_pkg) between
20
+ repositories.
21
+ * Upload a package signing GPG key.
22
+ * Create and delete [master and read
23
+ tokens](https://packagecloud.io/docs#token_auth) to control repository
24
+ access.
10
25
 
11
- And then execute:
26
+ This tool is intended to be used on the command line either manually or in an
27
+ automated environment (like a build or CI process). See more examples on how
28
+ to use the command-line interface by visiting the
29
+ [CLI page](https://packagecloud.io/l/cli).
30
+
31
+ ## Installation
12
32
 
13
- $ bundle
33
+ Simply run:
14
34
 
15
- Or install it yourself as:
35
+ gem install package_cloud
16
36
 
17
- $ gem install package_cloud
37
+ to install the command line client.
38
+
39
+ You can now run `package_cloud` from the command line to see the help message
40
+ displayed.
18
41
 
19
42
  ## Usage
20
43
 
21
- TODO: Write usage instructions here
44
+ ### Getting help
45
+
46
+ You can run `package_cloud help` to get general help information about the
47
+ supported commands.
48
+
49
+ You can also get help information for specific commands by running
50
+ `package_cloud help [command]`. For example, to get help on pushing a package
51
+ you can run: `package_cloud help push`.
52
+
53
+ Additional documentation is also available on our [documentation
54
+ page](https://packagecloud.io/docs).
55
+
56
+ You can interact with our system programmatically as well by using our
57
+ [API](https://packagecloud.io/docs/api).
58
+
59
+ ### Creating a repository
60
+
61
+ You can create a package repository named 'example' on
62
+ [packagecloud](https://packagecloud.io) by running:
63
+
64
+ ```
65
+ package_cloud repository create example
66
+ ```
67
+
68
+ ### Environment variables
69
+
70
+ There are two environment variables that you can use with package_cloud CLI
71
+ that will override the settings found in `~/.packagecloud`:
72
+
73
+ 1. `PACKAGECLOUD_TOKEN`: This environment variable can be set to your API
74
+ token (available [here](https://packagecloud.io/api_token)). If set, the
75
+ CLI *will not* read the `~/.packagecloud` configuration file to get the API
76
+ token.
77
+
78
+ 2. If and only if the `PACKAGECLOUD_TOKEN` variable is set, you may also set
79
+ `PACKAGECLOUD_URL`. This environment should only be used by
80
+ packagecloud:enterprise customers. It allows you to set the URL of the
81
+ packagecloud installation. Customers using our hosted, cloud based product
82
+ should not set this variable; it is defaulted to `http://packagecloud.io`
83
+ automatically.
84
+
85
+ ### Pushing a package
86
+
87
+ You can upload Debian, RPM, RubyGem, Python, or Java packages to any
88
+ repository you've created by using the `push` command.
89
+
90
+ Most package types require specifying a `distribution/version` pair when
91
+ uploading. See the examples that follow for more information.
92
+
93
+ Please note that packages will be available for download via the packagecloud
94
+ web UI
95
+ immediately after they are uploaded, but they will not necessarily be
96
+ available for installation via a package manager immediately. This is because
97
+ our system regenerates the repository metadata needed by package managers as a
98
+ background job on our system. Jobs are added to a queue and processed.
99
+ Processing time depends on the number of packages in your repository and the
100
+ number of reindex jobs in front of yours.
101
+
102
+ The following examples will show an example user name of `example-user` and a
103
+ repository
104
+ name of `example-repository`.
105
+
106
+ After the examples below, there will be an additional section documenting
107
+ important optional parameters you can specify when pushing packages.
108
+
109
+ #### Uploading a Debian package
110
+
111
+ You can upload a Debian package found at the path `/tmp/example.deb` for
112
+ Ubuntu Xenial by running:
113
+
114
+ ```
115
+ package_cloud push example-user/example-repository/ubuntu/xenial /tmp/example.deb
116
+ ```
117
+
118
+ This command will upload `/tmp/example.deb` to the `example-repository`
119
+ repository owned by `example-user` as an Ubuntu Xenial package.
120
+
121
+ We also support Debian source packages (DSCs). You can upload a
122
+ `/tmp/example.dsc` for Ubuntu Xenial by running:
123
+
124
+ ```
125
+ package_cloud push example-user/example-repository/ubuntu/xenial /tmp/example.dsc
126
+ ```
127
+
128
+ Note that all files associated with the DSC (like source tarballs, patches,
129
+ etc) must reside in the same directory as the DSC itself.
130
+
131
+ You can specify other Ubuntu or Debian versions. Consult the [full list of
132
+ combinations](https://packagecloud.io/docs#os_distro_version) to find the one
133
+ you need.
134
+
135
+ #### Uploading an RPM package
136
+
137
+ You can upload an RPM package found at the path `/tmp/example.rpm` for CentOS
138
+ 6 by running:
139
+
140
+ ```
141
+ package_cloud push example-user/example-repository/el/6 /tmp/example.rpm
142
+ ```
143
+
144
+ This command will upload `/tmp/example.rpm` to the `example-repository`
145
+ repository owned by `example-user` as a CentOS 6 package.
146
+
147
+ You can specify other CentOS, Fedora, Oracle, Scientific Linux, or SUSE versions.
148
+ Consult the
149
+ [full list of combinations](https://packagecloud.io/docs#os_distro_version)
150
+ to find the one you need.
151
+
152
+ #### Uploading a RubyGem package
153
+
154
+ You can upload a RubyGem package found at the path `/tmp/example.gem` by
155
+ running:
156
+
157
+ ```
158
+ package_cloud push example-user/example-repository /tmp/example.gem
159
+ ```
160
+
161
+ This command will upload `/tmp/example.gem` to the `example-repository`
162
+ repository owned by `example-user` as a RubyGem package.
163
+
164
+ Note that unlike all other package types, RubyGems do not require any
165
+ additional specification on upload.
166
+
167
+ #### Uploading a arbitrary file
168
+
169
+ NOTE:
170
+
171
+ Currently supported files:
172
+
173
+ * .asc (armored ascii signature file)
174
+
175
+ You can upload a Anyfile package found at the path `/tmp/example.asc` by
176
+ running:
177
+
178
+ ```
179
+ package_cloud push example-user/example-repository/anyfile /tmp/example.asc
180
+ ```
181
+
182
+ This command will upload `/tmp/example.asc` to the `example-repository`
183
+ repository owned by `example-user` as an Anyfile package.
184
+
185
+ #### Uploading a Python package
186
+
187
+ You can upload a Python package found at the path `/tmp/example.whl` by
188
+ running:
189
+
190
+ ```
191
+ package_cloud push example-user/example-repository/python /tmp/example.whl
192
+ ```
193
+
194
+ This command will upload `/tmp/example.whl` to the `example-repository`
195
+ repository owned by `example-user` as a Python package.
196
+
197
+ We also support Python eggs and source distributions. Note that recent
198
+ versions of pip no longer support installing Python eggs and will fail to find
199
+ eggs in PyPI repositories.
200
+
201
+ If you'd like to upload a Python egg despite this, you can do so by running:
202
+
203
+ ```
204
+ package_cloud push example-user/example-repository/python /tmp/example.egg
205
+ ```
206
+
207
+ #### Uploading a Java JAR, WAR, or AAR package
208
+
209
+ You can upload a Java JAR package found at the path `/tmp/example.jar` by
210
+ running:
211
+
212
+ ```
213
+ package_cloud push example-user/example-repository/java/maven2 /tmp/example.jar
214
+ ```
215
+
216
+ WAR files can be uploaded the same way.
217
+
218
+ It is important to note that in some cases (for example: 'fat JARs', or JARs
219
+ without `pom.xml` files, etc) our system will not be able to automatically
220
+ detect
221
+ the [Maven coordinates](https://maven.apache.org/pom.html#Maven_Coordinates).
222
+ In these cases you will receive an error, and you should specify the
223
+ coordinates manually on the command line:
224
+
225
+ ```
226
+ package_cloud push example-user/example-repository/java/maven2 /tmp/example.jar --coordinates=com.mygroup:packagename:1.0.2
227
+ ```
228
+
229
+ #### Uploading a Node.js package
230
+
231
+ To upload a Node.js package located at `/tmp/test-1.0.0.tgz` to a packagecloud
232
+ NPM registry called `example-user/example-repository`:
233
+
234
+ ```
235
+ package_cloud push example-user/example-repository/node /tmp/example-1.0.tgz
236
+ ```
237
+
238
+ #### Additional options
239
+
240
+ There are a few additional options you can use to fine tune package upload for
241
+ more advanced use cases:
242
+
243
+ * `--skip-file-ext-validation` - The CLI will attempt to verify the package's
244
+ file extension. In some cases, this may be unwanted (for example, when
245
+ uploading a randomly generated file name). You can ask the CLI to avoid
246
+ checking the file extension by specifying this flag.
247
+ * `--yes` - When uploading multiple packages the CLI will prompt the user to
248
+ verify their request by typing 'y'. You can skip the prompt by passing this
249
+ flag.
250
+ * `--skip-errors` - Sometimes a mass upload of a directory full of packages
251
+ may fail or be canceled by the user. If you want to re-upload all files
252
+ without having to manually remove files you have already uploaded, you can
253
+ use this flag to skip the duplicate file errors and force the CLI to
254
+ continue uploading packages.
255
+ * `--coordinates` - This flag is used for Java JARs or WARs which do not have
256
+ an internal `pom.xml` specifying the Maven coordinates. You can specify your
257
+ own Maven coordinates for this file using this flag:
258
+ `--coordinates=com.mygroup:packagename:1.0.2`.
259
+ * `--config` - This flag is used to specify a custom configuration file path
260
+ for the CLI. This file specifies the website URL and your API token. This is
261
+ default to `~/.packagecloud`.
262
+ * `--url` - This flag is sued to specify a custom URL as the packagecloud
263
+ server. This option is used by packagecloud:enterprise customers to point to
264
+ their installation.
265
+ * `--verbose` - This flag is used to generate additional debug information for
266
+ push operations and is very useful if submitting a bug report to
267
+ packagecloud :)
268
+
269
+ ### Deleting a package
270
+
271
+ You can remove a package by using the `yank` command. You will need to specify
272
+ the full filename of the package and the distribution / version pair (except
273
+ for RubyGems).
274
+
275
+ Removing a package will
276
+ make the package immediately inaccessable from the packagecloud web UI, but it
277
+ may take a few moments for the package to be removed from the repository
278
+ metadata because removals trigger a reindex of the repository.
279
+
280
+ #### Deleting a Debian package
281
+
282
+ You can delete a Debian package named `example_1.0.1-1_amd64.deb` that was
283
+ uploaded for Ubuntu Xenial from the repository `example-repository` owned by
284
+ the user `example-user` by running the following command:
285
+
286
+ ```
287
+ package_cloud yank example-user/example-repository/ubuntu/xenial example_1.0.1-1_amd64.deb
288
+ ```
289
+
290
+ This will delete the package and trigger a reindex of the repository's
291
+ metadata.
292
+
293
+ #### Deleting an RPM package
294
+
295
+ You can delete an RPM package named `example-1.0-1.x86_64.rpm` that was
296
+ uploaded for CentOS 6 from the repository `example-repository` owned by
297
+ the user `example-user` by running the following command:
298
+
299
+ ```
300
+ package_cloud yank example-user/example-repository/el/6 example-1.0-1.x86_64.rpm
301
+ ```
302
+
303
+ This will delete the package and trigger a reindex of the repository's
304
+ metadata.
305
+
306
+ #### Deleting a RubyGem package
307
+
308
+ You can delete a RubyGem package named `example-1.0.gem` from the
309
+ repository `example-repository` owned by the user `example-user`
310
+ by running the following command:
311
+
312
+ ```
313
+ package_cloud yank example-user/example-repository example-1.0.gem
314
+ ```
315
+
316
+ This will delete the package and trigger a reindex of the repository's
317
+ metadata.
318
+
319
+ #### Deleting a Python package
320
+
321
+ You can delete a Python package named `example-1.0.1.whl` from the repository
322
+ `example-repository` owned by the user `example-user` by running the following
323
+ command:
324
+
325
+ ```
326
+ package_cloud yank example-user/example-repository/python example-1.0.1.whl
327
+ ```
328
+
329
+ This will delete the package and trigger a reindex of the repository's metadata.
330
+ Python eggs and sdists can be deleted in a similar manner.
331
+
332
+ #### Deleting a Java package
333
+
334
+ You can delete a Java package named `example-1.0.3.jar` with the group
335
+ `com.groupid` from the repository
336
+ `example-repository` owned by the user `example-user` by running the following
337
+ command:
338
+
339
+ ```
340
+ package_cloud yank example-user/example-repository/java com.groupid/example-1.0.3.jar
341
+ ```
342
+
343
+ This will delete the package and trigger a reindex of the repository's
344
+ metadata. WARs can be deleted in a similar manner.
345
+
346
+ #### Deleting a Node.js package
347
+
348
+ You can delete a Node.js package named `example-1.0.tgz` from the NPM registry
349
+ `example-repository` owned by the user `example-user` by running the following
350
+ command:
351
+
352
+ ```
353
+ package_cloud yank example-user/example-repository/node example-1.0.tgz
354
+ ```
355
+
356
+ If the package has a scope, you can delete it by passing the scope like so:
357
+
358
+ ```
359
+ package_cloud yank example-user/example-repository/node @scoped-user/example-1.0.tgz
360
+ ```
361
+
362
+ This will delete the package and trigger a reindex of the registry's
363
+ metadata.
364
+
365
+ Note that deleting Node.js packages can have unexpected side effects when
366
+ mixed with
367
+ [NPM distribution tags](https://docs.npmjs.com/getting-started/using-tags). Read
368
+ more about how [promoting on packagecloud can affect dist tags
369
+ here.](https://packagecloud.io/docs/#node_promote)
370
+
371
+ ### GPG Keys
372
+
373
+ Some package managers use [GPG keys](https://packagecloud.io/docs#gpg)
374
+ to verify that a package was created by the author and not an impersonator.
375
+
376
+ If you sign your packages with a GPG key before you upload them to
377
+ packagecloud, your package will still be signed when the user downloads it.
378
+
379
+ In these cases, especially with YUM repositories, it is useful to upload the
380
+ public GPG key that can verify the package you signed. When a user installs
381
+ your repository, the associated GPG key will be installed on their system and
382
+ used for verifying the package.
383
+
384
+ The follow sections will illustrate how to upload, list, and delete GPG keys.
385
+
386
+ #### Uploading a package signing GPG key
387
+
388
+ To upload a GPG key located on
389
+ your system at `/tmp/gpg.key` for the repository `example-repository` owned by
390
+ the user `example-user`, you can run the following command:
391
+
392
+ ```
393
+ package_cloud gpg_key create example-user/example-repository /tmp/gpg.key
394
+ ```
395
+
396
+ Note that if you attempt to upload a private key to packagecloud, we will
397
+ extract only the public key component. The private key will then be discarded.
398
+ We do not store or persist private keys at all.
399
+
400
+ #### Listing GPG keys associated with a repository
401
+
402
+ You can list the GPG keys associated with the repository `example-repository`
403
+ owned by user `example-user` by running the following command:
404
+
405
+ ```
406
+ package_cloud gpg_key list example-user/example-repository
407
+ ```
408
+
409
+ The key name specified in the output of this command is the key name you should
410
+ specify when deleting the key.
411
+
412
+ #### Deleting GPG keys associated with a repository
413
+
414
+ You can delete the GPG key named
415
+ `example-user-example-repository-56D06.pub.gpg` associated with the repository
416
+ named `example-repository` and owned by the user `example-user` by running the
417
+ following command:
418
+
419
+ ```
420
+ package_cloud gpg_key destroy example-user/example-repository example-user-example-repository-56D06.pub.gpg
421
+ ```
422
+
423
+ You can get the key name for a key you'd like to delete by using the GPG key
424
+ list command above.
425
+
426
+ ### Promoting packages between repositories
427
+
428
+ Package promotion is a feature which can be used to easily move packages
429
+ between repositories. This is useful for moving a package from a private
430
+ staging repository to a public production ready repository during a software
431
+ release workflow.
432
+
433
+ To move a package named `example_1.0-1_amd64.deb` from the user
434
+ `example-user`'s repository named `repo1` over to the same users repository
435
+ named `repo2`, you would issue the following command:
436
+
437
+ ```
438
+ package_cloud promote example-user/repo1/ubuntu/xenial example_1.0-1_amd64.deb example-user/repo2
439
+ ```
440
+
441
+ If the package has a scope (Node.js packages), you can promote it by including
442
+ the scope like so:
443
+
444
+ ```
445
+ package_cloud promote example-user/repo1/node @scoped-user/example-1.0.tgz example-user/repo2
446
+ ```
447
+
448
+ If the package has a group (Java packages), you can promote it by
449
+ including the group like so:
450
+
451
+ ```
452
+ package_cloud promote example-user/repo1/java com.groupid/jake-2.3.jar example-user/repo2
453
+ ```
454
+
455
+ After the package is moved, a reindex will be triggered for both `repo1`
456
+ and `repo2`.
457
+
458
+ Note that promoting Node.js packages can have unexpected side effects when
459
+ mixed with
460
+ [NPM distribution tags](https://docs.npmjs.com/getting-started/using-tags).
461
+ Read more about how [promoting on packagecloud can affect dist tags
462
+ here](https://packagecloud.io/docs/#node_promote).
463
+
464
+ ### Creating, deleting, and listing master and read tokens
465
+
466
+ The [token authentication](https://packagecloud.io/docs/#token_auth) system
467
+ used for repositories allows fine grained access control of repositories.
468
+
469
+ Master tokens can be used just for creating additional read tokens. Master
470
+ tokens themselves do not provide read access to a repository. Deleting
471
+ a master token automatically deletes all associated read tokens.
472
+
473
+ A typical use case for our token system would be a SaaS service distributing
474
+ a monitoring agent who wants to control download access to their repository.
475
+
476
+ A master token can be created per customer that signs up and read tokens
477
+ associated with the generated master token can be assigned per system. Then,
478
+ the read tokens can be deleted one at a time (to disable access on a
479
+ per-machine basis) or completely by deleting the associated master token.
480
+
481
+ #### Creating master tokens
482
+
483
+ Following from the example explained in the previous section,
484
+ you can create a master token name "Example-Token" for the repository
485
+ `example-repository` owned by the user `example-user` by running the following
486
+ command:
487
+
488
+ ```
489
+ package_cloud master_token create example-user/example-repository Example-Token
490
+ ```
491
+
492
+ #### Listing master tokens
493
+
494
+ You can list all master tokens associated with the repository
495
+ `example-repository` owned by the user `example-user` by running the following
496
+ command:
497
+
498
+ ```
499
+ package_cloud master_token list example-user/example-repository
500
+ ```
501
+
502
+ #### Deleting master tokens
503
+
504
+ You can delete the token named `Example-Token` associated with the
505
+ repository `example-repository` owned by the user `example-user` by running
506
+ the following command:
507
+
508
+ ```
509
+ package_cloud master_token destroy example-user/example-repository Example-Token
510
+ ```
511
+
512
+ This will also automatically delete all read tokens associated with this
513
+ master token, thereby revoking read access to the repository with those
514
+ tokens.
22
515
 
23
- ## Contributing
516
+ ## Still need help?
24
517
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
518
+ Feel free to reach out to
519
+ [support@packagecloud.io](mailto:support@packagecloud.io) with questions.
data/bin/package_cloud CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "package_cloud"
3
3
 
4
- PackageCloud::CLI.start(ARGV)
4
+ PackageCloud::CLI::Entry.start(ARGV)
@@ -5,7 +5,8 @@ module PackageCloud
5
5
  module Auth
6
6
  class << self
7
7
  def get_token(url)
8
- JSON.parse(RestClient.get("#{url}/token.json"))["token"]
8
+ url = PackageCloud::Util.compute_url(url, "/api/v1/token.json")
9
+ JSON.parse(RestClient.get(url))["token"]
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,51 @@
1
+ module PackageCloud
2
+ module CLI
3
+ class Distro < Base
4
+ desc "list package_type",
5
+ "list available distros and versions for package_type"
6
+ def list(package_type)
7
+ distros = nil
8
+ measurement = Benchmark.measure {
9
+ distros = client.distributions[package_type]
10
+ }
11
+ $logger.debug("distro list request timing: #{measurement}")
12
+ if distros
13
+ puts "Listing distributions for #{package_type}:"
14
+ distros.each do |distro|
15
+ next if (distro["index_name"] == "any" || distro["index_name"] == "rpm_any")
16
+ puts "\n #{parse_display_name(distro["display_name"])} (#{distro["index_name"]}):\n\n"
17
+ distro["versions"].each do |ver|
18
+ puts " #{parse_version_name(ver["display_name"])} (#{ver["index_name"]})"
19
+ end
20
+ end
21
+
22
+ puts "\nIf you don't see your distribution or version here, email us at support@packagecloud.io."
23
+ else
24
+ puts "No distributions exist for #{package_type}.".color(:red)
25
+ puts "That either means that we don't support #{package_type} or that it doesn't require a distribution/version."
26
+ exit(1)
27
+ end
28
+ end
29
+
30
+ private
31
+ def parse_display_name(name)
32
+ if name == "Enterprise Linux"
33
+ "#{name} - Amazon Linux | CentOS | RedHat"
34
+ else
35
+ name
36
+ end
37
+ end
38
+ def parse_version_name(name)
39
+ if name == 'Enterprise Linux 5.0'
40
+ "#{name} | CentOS 5"
41
+ elsif name == 'Enterprise Linux 6.0'
42
+ "#{name} | CentOS 6 | Amazon Linux"
43
+ elsif name == 'Enterprise Linux 7.0'
44
+ "#{name} | CentOS 7"
45
+ else
46
+ name
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end