pivotal-cf / pivnet-cli

CLI to interact with Tanzu Network API V2 interface.
Apache License 2.0
34 stars 27 forks source link

Ability to download buildpacks #17

Closed DonBower closed 6 years ago

DonBower commented 6 years ago

I would like to be able to list all the versions of all the buildpacks, and then be able to select specific buildpacks and download them.

cf-gitbot commented 6 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/154563979

The labels on this github issue will be updated when the story is started.

kartiklunkad26 commented 6 years ago

Hi Dan, We would love to understand your scenario better! Could you give us an example of how you'd like to use it?

mhottinger1 commented 6 years ago

Hi @kartiklunkad26,

I have the same question:

$ ./pivnet-darwin-amd64-0.0.50 product -p buildpacks
+----+------------+--------------------+
| ID |    SLUG    |        NAME        |
+----+------------+--------------------+
| 69 | buildpacks | Buildpacks for PCF |
+----+------------+--------------------+
$ ./pivnet-darwin-amd64-0.0.50 releases -p buildpacks | grep "Java Buildpack 4.11"
| 84771 | Java Buildpack 4.11        | This release focuses on        | 2018-04-18T13:03:15.148Z |
$ ./pivnet-darwin-amd64-0.0.50 download-product-files -p buidldpacks -r "Java Buildpack" -i 84771
Pivnet error: could not find product with 'id' or 'slug'=buidldpacks
$ ./pivnet-darwin-amd64-0.0.50 download-product-files -p buidldpacks -r 84771
Must provide either globs or product file IDs

I want to use the CLI to download Java Buildpack 4.11. How does one accomplish that?

robdimsdale commented 6 years ago

@mhottinger1 in the snippet you just posted you have a typo in -p buildpacks. Do you get the same issue when you fix that typo?

mhottinger1 commented 6 years ago

@robdimsdale, nice catch thank you --

Here's my latest attempt:

$ ./pivnet-darwin-amd64-0.0.50 download-product-files -p buildpacks -r "Java Buildpack 4.11" -i 84771
No product files found for ids: [84771] or globs: []
robdimsdale commented 6 years ago

@mhottinger1 I think the issue is that 84771 is the ID of the release, not the product file.

2018-04-13 10:26:23 ~ → pivnet product-files -p buildpacks -r 'Java Buildpack 4.11'
+--------+--------------------------+--------------+-----------------------------------------------------------+
|   ID   |           NAME           | FILE VERSION |                      AWS OBJECT KEY                       |
+--------+--------------------------+--------------+-----------------------------------------------------------+
| 121586 | Java Buildpack           |         4.11 | product-files/buildpacks/java-buildpack-v4.11.zip         |
| 121585 | Java Buildpack (offline) |         4.11 | product-files/buildpacks/java-buildpack-offline-v4.11.zip |
+--------+--------------------------+--------------+-----------------------------------------------------------+

When I try with the product file ID I get the following:

2018-04-13 10:26:23 ~ → pivnet download-product-files -p buildpacks -r 'Java Buildpack 4.11' -i '121586'
2018/04/27 14:01:02 Downloading 'java-buildpack-v4.11.zip' to 'java-buildpack-v4.11.zip'
robdimsdale commented 6 years ago

Also, you could use globs instead, e.g.:

2018-04-13 10:26:23 ~ → pivnet download-product-files -p buildpacks -r 'Java Buildpack 4.11' -g '*offline*.zip'
2018/04/27 14:03:26 Downloading 'java-buildpack-offline-v4.11.zip' to 'java-buildpack-offline-v4.11.zip'

This type of thing would be relatively easy to script and iterate over multiple buildpacks - answering the origina question from @DonBower, too.

mhottinger1 commented 6 years ago

Good stuff @robdimsdale! From a UX perspective it wasn't clear to me how to use the -g flag while the other flags were relatively easy to figure out. Being able to specify a basic glob regex makes it easier in that there's no need to find the product file identifier.

On a side note, I noticed that Java uses an offline glob pattern some of the others I checked including NodeJS, Ruby, and Staticfile all use cached glob pattern. Just something for others to be aware of.