Skip to content

Commit

Permalink
govc: validate library.deploy arguments
Browse files Browse the repository at this point in the history
- add example of using library.export to generate options.json

Fixes #2599
Fixes #2598
  • Loading branch information
dougm committed Oct 21, 2021
1 parent d99e995 commit cbad7ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion govc/library/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ func (cmd *deploy) Description() string {
Examples:
govc library.deploy /library_name/ovf_template vm_name
govc library.deploy /library_name/ovf_template -options deploy.json`
govc library.export /library_name/ovf_template/*.ovf # save local copy of .ovf
govc import.spec *.ovf > deploy.json # generate options from .ovf
# edit deploy.json as needed
govc library.deploy -options deploy.json /library_name/ovf_template`
}

func (cmd *deploy) Run(ctx context.Context, f *flag.FlagSet) error {
if f.NArg() > 2 {
return flag.ErrHelp
}
path := f.Arg(0)
name := f.Arg(1)

Expand Down
3 changes: 3 additions & 0 deletions govc/test/library.bats
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ load test_helper
}
EOF

run govc library.deploy "my-content/$TTYLINUX_NAME" -options "$BATS_TMPDIR/ttylinux.json"
assert_failure # see issue #2599

run govc library.deploy -options "$BATS_TMPDIR/ttylinux.json" "my-content/$TTYLINUX_NAME"
assert_success
rm "$BATS_TMPDIR/ttylinux.json"
Expand Down

0 comments on commit cbad7ca

Please sign in to comment.