Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 610abb0

Browse files
committed
update sdk to support more products
fix doc errors update tests add manifest example and know issues to readme
1 parent e4e1492 commit 610abb0

9 files changed

Lines changed: 42 additions & 11 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v2
2424

2525
- name: Run Golang Tests
26-
run: go test -v ./...
26+
run: go test -v ./... | go test -v ./...
2727

2828
- name: Setup BATS
2929
if: runner.os != 'windows'

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To make it available to all users `sudo mv vmd-<os>-<version> /usr/local/bin/vmd
1515
vmd download -p vmware_tools -s vmtools -v 11.* -f VMware-Tools-darwin-*.zip --accepteula
1616
1717
# Download files using a manifest file
18-
vmd download -m manifest.yml --accepteula
18+
vmd download -m <filename>.yml --accepteula
1919
2020
# List of available products
2121
vmd get products
@@ -32,8 +32,34 @@ To make it available to all users `sudo mv vmd-<os>-<version> /usr/local/bin/vmd
3232
# Display example manifest file
3333
vmd get manifestexample
3434
```
35+
Example manifest to use with `vmd download -m <filename>.yml`
36+
```
37+
---
38+
# This section will download the latest version of vmware_tools
39+
# Each glob pattern will download a single file each
40+
product: vmware_tools
41+
subproduct: vmtools
42+
version: "*"
43+
filename_globs:
44+
- "VMware-Tools-darwin-*.tar.gz"
45+
- "VMware-Tools-darwin-*.zip"
46+
---
47+
# This section will download the latest minor release from major version 10
48+
# The single glob pattern will download 2 files
49+
product: vmware_tools
50+
subproduct: vmtools
51+
version: "10.*"
52+
filename_globs:
53+
- "VMware-Tools-other-*"
54+
---
55+
```
56+
# Known Issues
57+
- When working in a shell if you add a * to the filename arguement of the download command and you are in a directory where a file matches the pattern, your shell will replace the * to pass in the full file name. This can be worked around by wrapping the file name in single quotes, or by defining the download in a manifest yaml.
58+
- Some products such as horizon will not return the latest version when only a glob is provided. This is because the product switched naming standards meaning it breaks the sort of the version.
59+
- Some product descriptions don't display fully. This is especially true for the horizon products as they are inconsistently named, meaning it's difficult to extract the version number without taking out part of the product name.
60+
3561
# Testing
36-
To run commands against source use `alias vmd="go run main.go`</br>
62+
To run commands against source use `alias vmd="go run main.go"`</br>
3763
Run go tests `go test ./...`</br>
3864
Run BATS tests `bats test/bats`
3965

api/subproducts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
func ListSubProducts(slug string) (data [][]string, err error) {
11-
var subProducts []sdk.SubProduct
11+
var subProducts []sdk.SubProductDetails
1212
subProducts, err = basicClient.GetSubProductsSlice(slug)
1313
if err != nil {return}
1414
for _, v := range subProducts {

cmd/docs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ const (
1818
vmd get manifestexample`
1919

2020
downloadUsage = ` # Download the latest version of release 11 with a file matching the pattern
21-
vmd download -p vmware_tools -s vmtools -v 11.* -f VMware-Tools-darwin-*.zip --accepteula
21+
# If using a * in the filename value, make sure to wrap the text in single quotes on linux/macos
22+
vmd download -p vmware_tools -s vmtools -v 11.* -f 'VMware-Tools-darwin-*.zip' --accepteula
2223
2324
# Download files using a manifest file
25+
# Show an example manifest using 'vmd get manifestexample'
2426
vmd download -m manifest.yml --accepteula`
2527
)
2628

cmd/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func init() {
109109
downloadCmd.Flags().StringVarP(&slug, "product", "p", "", "Product code")
110110
downloadCmd.Flags().StringVarP(&subProduct, "subproduct", "s", "", "Sub Product code")
111111
downloadCmd.Flags().StringVarP(&version, "version", "v", "", "Version string. Can contain a glob.")
112-
downloadCmd.Flags().StringVarP(&fileName, "filename", "f", "", "Filename string. Can contain one or more globs.")
112+
downloadCmd.Flags().StringVarP(&fileName, "filename", "f", "", "Filename string. Can contain one or more globs. When using * wrap the text in single quotes.")
113113
downloadCmd.Flags().StringVarP(&manifestFile, "manifest", "m", "", "Filename of the manifest containing details of what to download")
114114
downloadCmd.Flags().StringVarP(&outputDir, "output", "o", "", "Directory to download files to")
115115
downloadCmd.Flags().BoolVarP(&acceptEula, "accepteula", "a", false, "Filename string")

cmd/products.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var productsCmd = &cobra.Command{
3737
if err != nil {
3838
handleErrors(err)
3939
}
40-
headings := []string{"Product code", "Produce description"}
40+
headings := []string{"Product code", "Product description"}
4141
presenters.RenderTable(headings, products)
4242
},
4343
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/dustin/go-humanize v1.0.0
77
github.com/google/go-cmp v0.5.6 // indirect
88
github.com/kr/pretty v0.2.0 // indirect
9-
github.com/laidbackware/vmware-download-sdk v0.0.0-20211004152325-e1b7eb16c537
9+
github.com/laidbackware/vmware-download-sdk v0.0.0-20211103135845-0c774de1d62d
1010
github.com/olekukonko/tablewriter v0.0.5
1111
github.com/orirawlings/persistent-cookiejar v0.3.0
1212
github.com/spf13/cobra v1.2.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ github.com/laidbackware/vmware-download-sdk v0.0.0-20211003124744-407b61b8f026 h
235235
github.com/laidbackware/vmware-download-sdk v0.0.0-20211003124744-407b61b8f026/go.mod h1:oXUINbShbZy4/y7OMIjyhjMPYzvVFg5QvRq8Dck7s1U=
236236
github.com/laidbackware/vmware-download-sdk v0.0.0-20211004152325-e1b7eb16c537 h1:KidmypR1GRG/G+Hl9pUUtO9jj/UrL5edt/n2dmbXvtQ=
237237
github.com/laidbackware/vmware-download-sdk v0.0.0-20211004152325-e1b7eb16c537/go.mod h1:oXUINbShbZy4/y7OMIjyhjMPYzvVFg5QvRq8Dck7s1U=
238+
github.com/laidbackware/vmware-download-sdk v0.0.0-20211103135845-0c774de1d62d h1:R5Ya5p5lYg0ZdfN8mSLOuXa04WDRTjbX6A53+oSpehA=
239+
github.com/laidbackware/vmware-download-sdk v0.0.0-20211103135845-0c774de1d62d/go.mod h1:oXUINbShbZy4/y7OMIjyhjMPYzvVFg5QvRq8Dck7s1U=
238240
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
239241
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
240242
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=

test/bats/download.bats

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ setup() {
1010
}
1111

1212
teardown() {
13-
# rm -rf "${TEMP_DIR}"
13+
rm -rf "${TEMP_DIR}"
14+
rm $HOME/vmd-downloads/VMware-Tools-darwin-11.3.0-*.zip
1415
echo ""
1516
}
1617

1718
@test "download single file successfully to temp" {
1819
$VMD_CMD logout
1920
rm -f $TEMP_DIR/*
20-
local cmd="$VMD_CMD download -p vmware_tools -s vmtools -v 11.3.0 -f VMware-Tools-darwin-*.zip --accepteula -o $TEMP_DIR"
21+
local cmd="$VMD_CMD download -p vmware_horizon_clients -s cart+andrd_x8632 -v 2106 -f VMware-Horizon-Client-AndroidOS-x86-*-store.apk --accepteula -o $TEMP_DIR"
2122
echo $cmd
2223
run $cmd
2324
echo $output
@@ -26,7 +27,7 @@ teardown() {
2627
[[ "$output" == *"Download started to"* ]]
2728
[[ "$output" == *"Download finished"* ]]
2829
[ "$status" -eq 0 ]
29-
[ -f $TEMP_DIR/VMware-Tools-darwin-*.zip ]
30+
[ -f $TEMP_DIR/VMware-Horizon-Client-*.apk ]
3031
}
3132

3233
@test "download single file successfully to user vmd-downloads" {

0 commit comments

Comments
 (0)