vmware-archive / vcd-cli

Command Line Interface for VMware vCloud Director
https://vmware.github.io/vcd-cli
Other
165 stars 105 forks source link

Feature: Make use of VCD_* environement variables from vcd terraform provider #504

Open jpbuecken opened 4 years ago

jpbuecken commented 4 years ago

It would be great if the vcdcli and the vcd terraform provider consolidate a little. In particular it would be great if we can make use of the same environement variables.

Example: Both, the vcd terraform provider and vcdcli make use of the VDC_PASSWORD variable. ([1], [2]).

I would like to suggest the following: VCD_URL=https://my-vcd/api If VCD_URL is set, we can omit url in vcd login url org user vcd login org user = vcd login $VCD_URL org user Be aware that VCD_URL requires the "http" or "https" and "/api" part.

VCD_SYS_ORG=System If VCD_SYS_ORG is set,we can omit org in vcd login url org user vcd login url user = vcd login url $VCD_SYS_ORG user

VCD_ORG=my-org If VCD_ORG and VCD_SYS_ORG is set then vcd login will be done as VCD_SYS_ORG, but the org in VCD_ORG will be used. vcd login url user = vcd login url $VCD_SYS_ORG user && vcd org use $VCD_ORG If VCD_ORG is set and VCD_SYS_ORG is not set, then VCD_ORG should be used to login vcd login url user = vcd login url $VCD_ORG user

VCD_USER=provideradmin If VCD_USER is set, we can omit user in vcd login url org user vcd login url org = vcd login url org $VCD_USER

VCD_VDC=my-org-vdc If VCD_VDC is set, it will switch in this VDC after login: vcd login url org user = vcd login url org user && vcd vdc use $VCD_VDC or in combination with VCD_SYS_ORG and VCD_ORG above: vcd login url user = vcd login url $VCD_SYS_ORG user && vcd org use $VCD_ORG && vcd vdc use $VCD_VDC

To explain the advantage: If you are working with terraform, you have those information in your environement. Now you need to lookup something with cli. With that above I can do

vcd login

without further information and I will be logged in in the same account I'm working in with terraform

vcd login
provideradmin logged in, org: 'my-org', vdc: 'my-org-vdc'

[1] http://vmware.github.io/vcd-cli/vcd_login.html [2] https://www.terraform.io/docs/providers/vcd/index.html