From 34ccdcd3aafbc33d21c12420a0af14ecb2f45de1 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Mon, 26 Aug 2024 13:57:35 -0400 Subject: [PATCH 1/5] fix: "device update --lock" should also unlock Signed-off-by: Marques Johansson --- docs/metal_device_update.md | 2 +- internal/devices/update.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/metal_device_update.md b/docs/metal_device_update.md index abb7ba3d..0d231f78 100644 --- a/docs/metal_device_update.md +++ b/docs/metal_device_update.md @@ -27,7 +27,7 @@ metal device update -i [-H ] [-d ] [--locked -H, --hostname string The new hostname of the device. -i, --id string The UUID of the device. -s, --ipxe-script-url string Add or update the URL of the iPXE script. - -l, --locked Locks or unlocks the device for future changes (). + -l, --locked bools Locks or unlocks the device for future changes (). (default []) -t, --tags strings Adds or updates the tags for the device --tags="tag1,tag2". -u, --userdata string Adds or updates the userdata for the device. --userdata-file string Path to a userdata file for device initialization. Can not be used with --userdata. diff --git a/internal/devices/update.go b/internal/devices/update.go index b53187c0..23331dd1 100644 --- a/internal/devices/update.go +++ b/internal/devices/update.go @@ -34,7 +34,6 @@ import ( func (c *Client) Update() *cobra.Command { var ( description string - locked bool userdata string userdataFile string hostname string @@ -80,8 +79,15 @@ func (c *Client) Update() *cobra.Command { deviceUpdate.Userdata = &userdata } - if locked { - deviceUpdate.Locked = &locked + if cmd.Flag("locked").Changed { + locked, err := cmd.Flags().GetBoolSlice("locked") + if err != nil { + return fmt.Errorf("could not parse locked value: %w", err) + } + if len(locked) > 1 { + return fmt.Errorf("parameter locked may only be set once") + } + deviceUpdate.Locked = &locked[0] } if len(tags) > 0 { @@ -123,12 +129,11 @@ func (c *Client) Update() *cobra.Command { updateDeviceCmd.Flags().StringVarP(&description, "description", "d", "", "Adds or updates the description for the device.") updateDeviceCmd.Flags().StringVarP(&userdata, "userdata", "u", "", "Adds or updates the userdata for the device.") updateDeviceCmd.Flags().StringVarP(&userdataFile, "userdata-file", "", "", "Path to a userdata file for device initialization. Can not be used with --userdata.") - updateDeviceCmd.Flags().BoolVarP(&locked, "locked", "l", false, "Locks or unlocks the device for future changes ().") + updateDeviceCmd.Flags().BoolSliceP("locked", "l", []bool{}, "Locks or unlocks the device for future changes ().") updateDeviceCmd.Flags().StringSliceVarP(&tags, "tags", "t", []string{}, `Adds or updates the tags for the device --tags="tag1,tag2".`) updateDeviceCmd.Flags().BoolVarP(&alwaysPXE, "always-pxe", "a", false, "Updates the always_pxe toggle for the device ().") updateDeviceCmd.Flags().StringVarP(&ipxescripturl, "ipxe-script-url", "s", "", "Add or update the URL of the iPXE script.") updateDeviceCmd.Flags().StringVarP(&customdata, "customdata", "c", "", "Adds or updates custom data to be included with your device's metadata.") _ = updateDeviceCmd.MarkFlagRequired("id") - return updateDeviceCmd } From bef38730286cb1a51cd5176863c11f0dc97074cd Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Mon, 26 Aug 2024 14:09:40 -0400 Subject: [PATCH 2/5] chore(device update): use Cobra to enforce exclusive fields and no addition args Signed-off-by: Marques Johansson --- internal/devices/update.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/devices/update.go b/internal/devices/update.go index 23331dd1..a99bf83f 100644 --- a/internal/devices/update.go +++ b/internal/devices/update.go @@ -63,10 +63,6 @@ func (c *Client) Update() *cobra.Command { deviceUpdate.Description = &description } - if userdata != "" && userdataFile != "" { - return fmt.Errorf("either userdata or userdata-file should be set") - } - if userdataFile != "" { userdataRaw, readErr := os.ReadFile(userdataFile) if readErr != nil { @@ -135,5 +131,7 @@ func (c *Client) Update() *cobra.Command { updateDeviceCmd.Flags().StringVarP(&ipxescripturl, "ipxe-script-url", "s", "", "Add or update the URL of the iPXE script.") updateDeviceCmd.Flags().StringVarP(&customdata, "customdata", "c", "", "Adds or updates custom data to be included with your device's metadata.") _ = updateDeviceCmd.MarkFlagRequired("id") + updateDeviceCmd.MarkFlagsMutuallyExclusive("userdata", "userdata-file") + updateDeviceCmd.Args = cobra.NoArgs return updateDeviceCmd } From 67dbcd03437dd16721863556ac7fdc419b0a8a42 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Mon, 26 Aug 2024 17:03:49 -0400 Subject: [PATCH 3/5] docs: revise device update --locked arg Signed-off-by: Marques Johansson --- docs/metal_device_update.md | 2 +- internal/devices/update.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/metal_device_update.md b/docs/metal_device_update.md index 0d231f78..2a289799 100644 --- a/docs/metal_device_update.md +++ b/docs/metal_device_update.md @@ -7,7 +7,7 @@ Updates a device. Updates the hostname of a device. Updates or adds a description, tags, userdata, custom data, and iPXE settings for an already provisioned device. Can also lock or unlock future changes to the device. ``` -metal device update -i [-H ] [-d ] [--locked ] [-t ] [-u | --userdata-file ] [-c ] [-s ] [--always-pxe=] [flags] +metal device update -i [-H ] [-d ] [--locked=] [-t ] [-u | --userdata-file ] [-c ] [-s ] [--always-pxe=] [flags] ``` ### Examples diff --git a/internal/devices/update.go b/internal/devices/update.go index a99bf83f..47be9555 100644 --- a/internal/devices/update.go +++ b/internal/devices/update.go @@ -45,7 +45,7 @@ func (c *Client) Update() *cobra.Command { ) // updateDeviceCmd represents the updateDevice command updateDeviceCmd := &cobra.Command{ - Use: `update -i [-H ] [-d ] [--locked ] [-t ] [-u | --userdata-file ] [-c ] [-s ] [--always-pxe=]`, + Use: `update -i [-H ] [-d ] [--locked=] [-t ] [-u | --userdata-file ] [-c ] [-s ] [--always-pxe=]`, Short: "Updates a device.", Long: "Updates the hostname of a device. Updates or adds a description, tags, userdata, custom data, and iPXE settings for an already provisioned device. Can also lock or unlock future changes to the device.", Example: ` # Updates the hostname of a device: From f304a91aae31ebfdfa72a6255179e5cb7d8783c7 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Mon, 26 Aug 2024 17:09:18 -0400 Subject: [PATCH 4/5] chore: refactor device update locked to simple bool Signed-off-by: Marques Johansson --- docs/metal_device_update.md | 2 +- internal/devices/update.go | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/metal_device_update.md b/docs/metal_device_update.md index 2a289799..58e034d4 100644 --- a/docs/metal_device_update.md +++ b/docs/metal_device_update.md @@ -27,7 +27,7 @@ metal device update -i [-H ] [-d ] [--locked= -H, --hostname string The new hostname of the device. -i, --id string The UUID of the device. -s, --ipxe-script-url string Add or update the URL of the iPXE script. - -l, --locked bools Locks or unlocks the device for future changes (). (default []) + -l, --locked Locks or unlocks the device for future changes (). -t, --tags strings Adds or updates the tags for the device --tags="tag1,tag2". -u, --userdata string Adds or updates the userdata for the device. --userdata-file string Path to a userdata file for device initialization. Can not be used with --userdata. diff --git a/internal/devices/update.go b/internal/devices/update.go index 47be9555..9125d832 100644 --- a/internal/devices/update.go +++ b/internal/devices/update.go @@ -76,14 +76,11 @@ func (c *Client) Update() *cobra.Command { } if cmd.Flag("locked").Changed { - locked, err := cmd.Flags().GetBoolSlice("locked") + locked, err := cmd.Flags().GetBool("locked") if err != nil { return fmt.Errorf("could not parse locked value: %w", err) } - if len(locked) > 1 { - return fmt.Errorf("parameter locked may only be set once") - } - deviceUpdate.Locked = &locked[0] + deviceUpdate.Locked = &locked } if len(tags) > 0 { @@ -125,7 +122,7 @@ func (c *Client) Update() *cobra.Command { updateDeviceCmd.Flags().StringVarP(&description, "description", "d", "", "Adds or updates the description for the device.") updateDeviceCmd.Flags().StringVarP(&userdata, "userdata", "u", "", "Adds or updates the userdata for the device.") updateDeviceCmd.Flags().StringVarP(&userdataFile, "userdata-file", "", "", "Path to a userdata file for device initialization. Can not be used with --userdata.") - updateDeviceCmd.Flags().BoolSliceP("locked", "l", []bool{}, "Locks or unlocks the device for future changes ().") + updateDeviceCmd.Flags().BoolP("locked", "l", false, "Locks or unlocks the device for future changes ().") updateDeviceCmd.Flags().StringSliceVarP(&tags, "tags", "t", []string{}, `Adds or updates the tags for the device --tags="tag1,tag2".`) updateDeviceCmd.Flags().BoolVarP(&alwaysPXE, "always-pxe", "a", false, "Updates the always_pxe toggle for the device ().") updateDeviceCmd.Flags().StringVarP(&ipxescripturl, "ipxe-script-url", "s", "", "Add or update the URL of the iPXE script.") From 08407f8c0712df082ddc2c1e4f68d546924deb29 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Mon, 26 Aug 2024 17:44:26 -0400 Subject: [PATCH 5/5] fix: error when unknown arguments are included as action parameters PR was made by manually walking the list of files in internal/ that did not specify Args and adding an Args definition. git grep -n -e NewCommand -e Cmd\ :\= $(git grep -L Args internal/) "docs", "emdocs", and "completion" were not included because they use Args and have an existing Args definition. Signed-off-by: Marques Johansson --- internal/capacity/capacity.go | 1 + internal/capacity/check.go | 2 +- internal/capacity/retrieve.go | 2 +- internal/cli/root.go | 2 +- internal/devices/create.go | 2 +- internal/devices/delete.go | 2 +- internal/devices/device.go | 2 +- internal/devices/reboot.go | 2 +- internal/devices/reinstall.go | 1 + internal/devices/retrieve.go | 2 +- internal/devices/start.go | 2 +- internal/devices/stop.go | 2 +- internal/env/env.go | 1 + internal/events/event.go | 1 + internal/events/retrieve.go | 2 +- internal/facilities/facility.go | 1 + internal/facilities/retrieve.go | 2 +- internal/gateway/create.go | 2 +- internal/gateway/createbgpneighbours.go | 2 +- internal/gateway/delete.go | 2 +- internal/gateway/deletebgpneighbours.go | 2 +- internal/gateway/gateway.go | 2 +- internal/gateway/getbgpneighbours.go | 2 +- internal/gateway/listbgpneighbours.go | 2 +- internal/gateway/retrieve.go | 2 +- internal/hardware/hardware.go | 1 + internal/hardware/move.go | 2 +- internal/hardware/retrieve.go | 2 +- internal/init/init.go | 1 + internal/interconnections/create.go | 12 ++++++------ internal/interconnections/delete.go | 2 +- internal/interconnections/interconnections.go | 1 + internal/interconnections/retrieve.go | 2 +- internal/interconnections/update.go | 2 +- internal/ips/assign.go | 2 +- internal/ips/available.go | 2 +- internal/ips/ip.go | 2 +- internal/ips/remove.go | 2 +- internal/ips/request.go | 2 +- internal/ips/retrieve.go | 2 +- internal/ips/unassign.go | 2 +- internal/metros/metro.go | 1 + internal/metros/retrieve.go | 2 +- internal/organizations/create.go | 2 +- internal/organizations/delete.go | 2 +- internal/organizations/organization.go | 2 +- internal/organizations/payment.go | 2 +- internal/organizations/retrieve.go | 2 +- internal/organizations/update.go | 2 +- internal/os/os.go | 1 + internal/plans/plan.go | 1 + internal/ports/convert.go | 1 + internal/ports/port.go | 1 + internal/ports/retrieve.go | 2 +- internal/ports/vlans.go | 2 +- internal/projects/bgpconfig.go | 1 + internal/projects/bgpenable.go | 1 + internal/projects/create.go | 2 +- internal/projects/delete.go | 2 +- internal/projects/project.go | 2 +- internal/projects/retrieve.go | 6 +++--- internal/projects/update.go | 2 +- internal/ssh/create.go | 2 +- internal/ssh/delete.go | 2 +- internal/ssh/retrieve.go | 1 + internal/ssh/ssh.go | 2 +- internal/ssh/update.go | 2 +- internal/twofa/disable2fa.go | 2 +- internal/twofa/enable2fa.go | 2 +- internal/twofa/receive.go | 2 +- internal/twofa/twofa.go | 2 +- internal/users/add.go | 2 +- internal/users/retrieve.go | 2 +- internal/users/user.go | 2 +- internal/virtualcircuit/create.go | 2 +- internal/virtualcircuit/delete.go | 2 +- internal/virtualcircuit/retrieve.go | 2 +- internal/virtualcircuit/update.go | 2 +- internal/virtualcircuit/virtualcircuit.go | 1 + internal/vlan/create.go | 2 +- internal/vlan/delete.go | 2 +- internal/vlan/retrieve.go | 2 +- internal/vlan/vlan.go | 2 +- internal/vrf/create.go | 1 + internal/vrf/createroute.go | 1 + internal/vrf/delete.go | 1 + internal/vrf/deleteroute.go | 2 +- internal/vrf/ips.go | 1 + internal/vrf/retrieve.go | 2 +- internal/vrf/retrieveroute.go | 1 + internal/vrf/updateroute.go | 1 + internal/vrf/vrf.go | 2 +- 92 files changed, 99 insertions(+), 76 deletions(-) diff --git a/internal/capacity/capacity.go b/internal/capacity/capacity.go index e8e241c6..f9a213f7 100644 --- a/internal/capacity/capacity.go +++ b/internal/capacity/capacity.go @@ -38,6 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Use: "capacity", Short: `Capacity operations: get, check`, Long: "Capacity operations. For more information on capacity in metros, visit https://deploy.equinix.com/developers/docs/metal/locations/metros/ For more information on capacity in facilities, visit https://deploy.equinix.com/developers/docs/metal/locations/facilities/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/capacity/check.go b/internal/capacity/check.go index 9caa9358..65f9713e 100644 --- a/internal/capacity/check.go +++ b/internal/capacity/check.go @@ -46,7 +46,7 @@ func (c *Client) Check() *cobra.Command { # Checks if Silicon Valley or Dallas has either 4 c3.medium.x86 or m3.large.x86 metal capacity check -m sv,da -P c3.medium.x86,m3.large.x86 -q 4`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { var locationField string var returnOut error diff --git a/internal/capacity/retrieve.go b/internal/capacity/retrieve.go index 72a90795..b6655214 100644 --- a/internal/capacity/retrieve.go +++ b/internal/capacity/retrieve.go @@ -49,7 +49,7 @@ func (c *Client) Retrieve() *cobra.Command { # Returns c3.large.arm and c3.medium.x86 capacity in the Silicon Valley, New York, and Dallas metros: metal capacity get --metros sv,ny,da -P c3.large.arm,c3.medium.x86`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { var err error var locationField string diff --git a/internal/cli/root.go b/internal/cli/root.go index a5d41e1e..c90cd41b 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -198,7 +198,7 @@ func (c *Client) NewCommand() *cobra.Command { Short: "Command line interface for Equinix Metal", Long: `Command line interface for Equinix Metal`, DisableAutoGenTag: true, - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { c.Config(cmd) }, diff --git a/internal/devices/create.go b/internal/devices/create.go index 798b5f6f..4449572c 100644 --- a/internal/devices/create.go +++ b/internal/devices/create.go @@ -64,7 +64,7 @@ func (c *Client) Create() *cobra.Command { # Provisions a c3.medium.x86 in Silicon Valley, running Rocky Linux, from a hardware reservation: metal device create -p $METAL_PROJECT_ID -P c3.medium.x86 -m sv -H test-rocky -O rocky_8 -r 47161704-1715-4b45-8549-fb3f4b2c32c7`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if userdata != "" && userdataFile != "" { return fmt.Errorf("either userdata or userdata-file should be set") diff --git a/internal/devices/delete.go b/internal/devices/delete.go index 35575f12..1f2ee731 100644 --- a/internal/devices/delete.go +++ b/internal/devices/delete.go @@ -33,7 +33,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes a VLAN, skipping confirmation: metal device delete -f -i 7ec86e23-8dcf-48ed-bd9b-c25c20958277`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/devices/device.go b/internal/devices/device.go index 07ceda19..81201893 100644 --- a/internal/devices/device.go +++ b/internal/devices/device.go @@ -39,7 +39,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"server", "servers", "devices"}, Short: "Device operations: create, get, update, delete, reinstall, start, stop, and reboot.", Long: "Device operations that control server provisioning, metadata, and basic operations.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/devices/reboot.go b/internal/devices/reboot.go index 5344745b..484754ce 100644 --- a/internal/devices/reboot.go +++ b/internal/devices/reboot.go @@ -37,7 +37,7 @@ func (c *Client) Reboot() *cobra.Command { Long: "Reboots the specified device.", Example: ` # Reboots the specified device: metal device reboot --id 26a9da5f-a0db-41f6-8467-827e144e59a7`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true DeviceAction := metal.NewDeviceActionInput("reboot") diff --git a/internal/devices/reinstall.go b/internal/devices/reinstall.go index b7171d70..2189fcc4 100644 --- a/internal/devices/reinstall.go +++ b/internal/devices/reinstall.go @@ -46,6 +46,7 @@ func (c *Client) Reinstall() *cobra.Command { # Reinstalls a device with Ubuntu 22.04 while preserving the data on non-OS disks: metal device reinstall -d 50382f72-02b7-4b40-ac8d-253713e1e174 -O ubuntu_22_04 --preserve-data`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { DeviceAction := metal.NewDeviceActionInput("reinstall") diff --git a/internal/devices/retrieve.go b/internal/devices/retrieve.go index f0d7a70a..72f8accc 100644 --- a/internal/devices/retrieve.go +++ b/internal/devices/retrieve.go @@ -43,7 +43,7 @@ func (c *Client) Retrieve() *cobra.Command { # Get a list of devices with the hostname foo and a default project configured: metal device get --filter hostname=foo`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { deviceID, _ := cmd.Flags().GetString("id") projectID, _ := cmd.Flags().GetString("project-id") diff --git a/internal/devices/start.go b/internal/devices/start.go index b39c57e0..050c0ecb 100644 --- a/internal/devices/start.go +++ b/internal/devices/start.go @@ -37,7 +37,7 @@ func (c *Client) Start() *cobra.Command { Long: "Starts or powers on a device that is currently stopped or powered off.", Example: ` # Starts the specified device: metal device start --id 26a9da5f-a0db-41f6-8467-827e144e59a7`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true DeviceAction := metal.NewDeviceActionInput("power_on") diff --git a/internal/devices/stop.go b/internal/devices/stop.go index 4ad87513..41814cc1 100644 --- a/internal/devices/stop.go +++ b/internal/devices/stop.go @@ -36,7 +36,7 @@ func (c *Client) Stop() *cobra.Command { Long: "Stops or powers off a device that is currently started or powered on.", Example: ` # Stops the specified device: metal device stop --id [device_UUID]`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true DeviceAction := metal.NewDeviceActionInput("power_off") diff --git a/internal/env/env.go b/internal/env/env.go index 1b8c922e..58d55d62 100644 --- a/internal/env/env.go +++ b/internal/env/env.go @@ -68,6 +68,7 @@ func (c *Client) NewCommand() *cobra.Command { metal env | source`, DisableFlagsInUseLine: true, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { var formatter func(token, orgID, projID, conPath string) map[string]string diff --git a/internal/events/event.go b/internal/events/event.go index 4af206ec..cd7e9d41 100644 --- a/internal/events/event.go +++ b/internal/events/event.go @@ -42,6 +42,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"events"}, Short: "Events operations: get.", Long: "Events information for organizations, projects, devices, and the current user.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/events/retrieve.go b/internal/events/retrieve.go index 5f0712c3..3009be6f 100644 --- a/internal/events/retrieve.go +++ b/internal/events/retrieve.go @@ -51,7 +51,7 @@ func (c *Client) Retrieve() *cobra.Command { # Retrieve all events of a device: metal event get -d ca614540-fbd4-4dbb-9689-457c6ccc8353`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true var events []metal.Event diff --git a/internal/facilities/facility.go b/internal/facilities/facility.go index a19d4116..b7de95a5 100644 --- a/internal/facilities/facility.go +++ b/internal/facilities/facility.go @@ -18,6 +18,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"facility"}, Short: "Facility operations: get.", Long: "Information about specific facilities. Facility-level operations have mostly been replaced by Metros, but remains for backwards-compatibility. Documentation about facilities is available at https://deploy.equinix.com/developers/docs/metal/locations/facilities/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/facilities/retrieve.go b/internal/facilities/retrieve.go index a1c449e5..aea4d491 100644 --- a/internal/facilities/retrieve.go +++ b/internal/facilities/retrieve.go @@ -18,7 +18,7 @@ func (c *Client) Retrieve() *cobra.Command { Long: "Retrieves a list of facilities available to the current user.", Example: ` # Lists facilities for current user: metal facilities get`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { var ( facilityList *metalv1.FacilityList diff --git a/internal/gateway/create.go b/internal/gateway/create.go index d7146426..cc1501bf 100644 --- a/internal/gateway/create.go +++ b/internal/gateway/create.go @@ -48,7 +48,7 @@ func (c *Client) Create() *cobra.Command { # Creates a Metal Gateway on the VLAN with a Private 10.x.x.x/28 subnet: metal gateway create -p $METAL_PROJECT_ID --virtual-network 77e6d57a-d7a4-4816-b451-cf9b043444e2 --private-subnet-size 16`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true includes := []string{"virtual_network", "ip_reservation"} diff --git a/internal/gateway/createbgpneighbours.go b/internal/gateway/createbgpneighbours.go index c7e0b071..accf852e 100644 --- a/internal/gateway/createbgpneighbours.go +++ b/internal/gateway/createbgpneighbours.go @@ -44,7 +44,7 @@ func (c *Client) CreateBgpNeighbors() *cobra.Command { metal gateways create-bgp-dynamic-neighbor --id "9c56fa1d-ec05-470b-a938-0e5dd6a1540c" --bgp-neighbor-range "10.70.43.226/29" --asn 65000 `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/gateway/delete.go b/internal/gateway/delete.go index 0fd5175f..34b07c6f 100644 --- a/internal/gateway/delete.go +++ b/internal/gateway/delete.go @@ -61,7 +61,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes a Gateway, skipping confirmation. metal gateway delete -f -i 77e6d57a-d7a4-4816-b451-cf9b043444e2`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/gateway/deletebgpneighbours.go b/internal/gateway/deletebgpneighbours.go index 27bb22c4..69d97a74 100644 --- a/internal/gateway/deletebgpneighbours.go +++ b/internal/gateway/deletebgpneighbours.go @@ -43,7 +43,7 @@ func (c *Client) DeleteBgpNeighbors() *cobra.Command { BGP Dynamic Neighbor deletion initiated. Please check 'metal gateway get-bgp-dynamic-neighbor -i 9c56fa1d-ec05-470b-a938-0e5dd6a1540c for status `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 28ae37c4..144e841c 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -40,7 +40,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"gateways", "metal-gateway", "metal-gateways"}, Short: "Metal Gateway operations: create, delete, and retrieve.", Long: "A Metal Gateway provides a single IPv4 address as a gateway for a subnet. For more information, visit https://deploy.equinix.com/developers/docs/metal/networking/metal-gateway/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/gateway/getbgpneighbours.go b/internal/gateway/getbgpneighbours.go index f3412b71..839a29e5 100644 --- a/internal/gateway/getbgpneighbours.go +++ b/internal/gateway/getbgpneighbours.go @@ -20,7 +20,7 @@ func (c *Client) GetBgpNeighbors() *cobra.Command { $ metal gateways get-bgp-dynamic-neighbor --id "9c56fa1d-ec05-470b-a938-0e5dd6a1540c" `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/gateway/listbgpneighbours.go b/internal/gateway/listbgpneighbours.go index 3dde36c7..cc2d5a7b 100644 --- a/internal/gateway/listbgpneighbours.go +++ b/internal/gateway/listbgpneighbours.go @@ -20,7 +20,7 @@ func (c *Client) ListBgpNeighbors() *cobra.Command { $ metal gateways list-bgp-dynamic-neighbor --id "9c56fa1d-ec05-470b-a938-0e5dd6a1540c" `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/gateway/retrieve.go b/internal/gateway/retrieve.go index 033d6530..eac53339 100644 --- a/internal/gateway/retrieve.go +++ b/internal/gateway/retrieve.go @@ -108,7 +108,7 @@ func (c *Client) Retrieve() *cobra.Command { Example: ` # Lists Metal Gateways for project 3b0795ba-ec9a-4a9e-83a7-043e7e11407c: metal gateways get -p 3b0795ba-ec9a-4a9e-83a7-043e7e11407c`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true includes := []string{"virtual_network", "ip_reservation", "vrf"} diff --git a/internal/hardware/hardware.go b/internal/hardware/hardware.go index 22bb9705..4962d08a 100644 --- a/internal/hardware/hardware.go +++ b/internal/hardware/hardware.go @@ -18,6 +18,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"hardware-reservations", "hardware"}, Short: "Hardware reservation operations: get, move.", Long: "Information and operations on Hardware Reservations. Provisioning specific devices from a reservation can be performed with the `metal device` command. Documentation is available on https://deploy.equinix.com/developers/docs/metal/deploy/reserved/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/hardware/move.go b/internal/hardware/move.go index ffc6d391..a3bc6813 100644 --- a/internal/hardware/move.go +++ b/internal/hardware/move.go @@ -17,7 +17,7 @@ func (c *Client) Move() *cobra.Command { Long: "Moves a hardware reservation to a specified project. Both the hardware reservation ID and the Project ID for the destination project are required.", Example: ` # Moves a hardware reservation to the specified Project: metal hardware-reservation move -i 8404b73c-d18f-4190-8c49-20bb17501f88 -p 278bca90-f6b2-4659-b1a4-1bdffa0d80b7`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true header := []string{"ID", "Facility", "Plan", "Created"} diff --git a/internal/hardware/retrieve.go b/internal/hardware/retrieve.go index 2a542e50..66dac25b 100644 --- a/internal/hardware/retrieve.go +++ b/internal/hardware/retrieve.go @@ -20,7 +20,7 @@ func (c *Client) Retrieve() *cobra.Command { # Retrieve the details of a specific hardware reservation: metal hardware-reservations get -i 8404b73c-d18f-4190-8c49-20bb17501f88`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { projectID, _ := cmd.Flags().GetString("project-id") hardwareReservationID, _ := cmd.Flags().GetString("id") diff --git a/internal/init/init.go b/internal/init/init.go index 89380a5c..ba56158c 100644 --- a/internal/init/init.go +++ b/internal/init/init.go @@ -70,6 +70,7 @@ func (c *Client) NewCommand() *cobra.Command { organization-id: 253e9cf1-5b3d-41f5-a4fa-839c130c8c1d`, DisableFlagsInUseLine: true, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true cmd.SilenceUsage = true diff --git a/internal/interconnections/create.go b/internal/interconnections/create.go index d3aa9fa9..acff88dd 100644 --- a/internal/interconnections/create.go +++ b/internal/interconnections/create.go @@ -33,7 +33,7 @@ func (c *Client) Create() *cobra.Command { var interconn *metal.Interconnection var err error - if err := validInputArgs(projectID, organizationID, connType, vlans, vrfs, svcTokenType); err != nil { + if err := validInputArgs(connType, vlans, vrfs, svcTokenType); err != nil { return err } @@ -96,6 +96,10 @@ func (c *Client) Create() *cobra.Command { _ = createInterconnectionsCmd.MarkFlagRequired("metro") _ = createInterconnectionsCmd.MarkFlagRequired("redundancy") _ = createInterconnectionsCmd.MarkFlagRequired("type") + + createInterconnectionsCmd.MarkFlagsOneRequired("organization-id", "project-id") + createInterconnectionsCmd.Args = cobra.NoArgs + return createInterconnectionsCmd } @@ -125,11 +129,7 @@ func (c *Client) handleCreate(projectID, organizationID string, return interconn, err } -func validInputArgs(projectID, organizationID, connType string, vlans []int32, vrfs []string, svcTokenType string) error { - if projectID == "" && organizationID == "" { - return errors.New("could you provide at least either of projectID OR organizationID") - } - +func validInputArgs(connType string, vlans []int32, vrfs []string, svcTokenType string) error { if (vlanFabricVcCreate(connType, vlans) || vrfsFabricVcCreate(connType, vrfs)) && svcTokenType == "" { return errors.New("flag 'service-token-type' is required for vlan or vrfs fabric VC create") } diff --git a/internal/interconnections/delete.go b/internal/interconnections/delete.go index 4b9cda1e..c7917010 100644 --- a/internal/interconnections/delete.go +++ b/internal/interconnections/delete.go @@ -21,7 +21,7 @@ func (c *Client) Delete() *cobra.Command { > ✔ Are you sure you want to delete device 7ec86e23-8dcf-48ed-bd9b-c25c20958277 [Y/n]: Y `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/interconnections/interconnections.go b/internal/interconnections/interconnections.go index 5f2a278b..e2a1ccaa 100644 --- a/internal/interconnections/interconnections.go +++ b/internal/interconnections/interconnections.go @@ -18,6 +18,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"conn"}, Short: "interconnections operations: create, get, update, delete", Long: "Get information on Metro locations. For more information on https://deploy.equinix.com/developers/docs/metal/interconnections.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/interconnections/retrieve.go b/internal/interconnections/retrieve.go index 08d2c8bc..e004786f 100644 --- a/internal/interconnections/retrieve.go +++ b/internal/interconnections/retrieve.go @@ -26,7 +26,7 @@ func (c *Client) Retrieve() *cobra.Command { # Retrieve all interconnection of a project: metal interconnections get -p 1867ee8f-6a11-470a-9505-952d6a324040 `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true var interConns []metal.Interconnection diff --git a/internal/interconnections/update.go b/internal/interconnections/update.go index 5edf3758..0f10e296 100644 --- a/internal/interconnections/update.go +++ b/internal/interconnections/update.go @@ -26,7 +26,7 @@ func (c *Client) Update() *cobra.Command { Long: "Updates a specified connection.", Example: ` # Updates a specified connection.: metal interconnections update --id 30c15082-a06e-4c43-bfc3-252616b46eba -n [] -d [] -r [<'redundant'|'primary'>]-m [] -e [] --tags="tag1,tag2"`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true intInput := metal.NewInterconnectionUpdateInput() diff --git a/internal/ips/assign.go b/internal/ips/assign.go index 4c52b540..0f7870fb 100644 --- a/internal/ips/assign.go +++ b/internal/ips/assign.go @@ -42,7 +42,7 @@ func (c *Client) Assign() *cobra.Command { Long: "Assigns an IP address and subnet to a specified device. Returns an assignment ID.", Example: ` # Assigns an IP address to a server: metal ip assign -d 060d1626-2481-475a-9789-c6f4bb927303 -a 198.51.100.3/31`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true IPAssignmentInput := metal.NewIPAssignmentInput(address) diff --git a/internal/ips/available.go b/internal/ips/available.go index 7fc91fba..b6e0d756 100644 --- a/internal/ips/available.go +++ b/internal/ips/available.go @@ -40,7 +40,7 @@ func (c *Client) Available() *cobra.Command { Long: "Lists available IP addresses in a specified reservation for the desired subnet size.", Example: ` # Lists available IP addresses in a reservation for a /31 subnet: metal ip available --reservation-id da1bb048-ea6e-4911-8ab9-b95635ca127a --cidr 31`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true Cidr := metal.FindIPAvailabilitiesCidrParameter(strconv.Itoa(cidr)) diff --git a/internal/ips/ip.go b/internal/ips/ip.go index da200123..c468f6c8 100644 --- a/internal/ips/ip.go +++ b/internal/ips/ip.go @@ -39,7 +39,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"ips", "ip-addresses", "ip-address"}, Short: "IP address, reservations, and assignment operations: assign, unassign, remove, available, request and get.", Long: "IP address and subnet operations, including requesting IPv4 and IPv6 addresses, assigning and removing IPs to servers, and getting information about subnets and their usage. For more information is available on https://deploy.equinix.com/developers/docs/metal/networking/ip-addresses/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/ips/remove.go b/internal/ips/remove.go index 05ff67ed..6720badd 100644 --- a/internal/ips/remove.go +++ b/internal/ips/remove.go @@ -36,7 +36,7 @@ func (c *Client) Remove() *cobra.Command { Long: "Removes an IP address reservation from a project. Any subnets and IP addresses in the reservation will no longer be able to be used by your devices.", Example: ` # Removes an IP address reservation: metal ip remove --id a9dfc9d5-ba1a-4d11-8cfc-6e30b9630876`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true _, err := c.IPService.DeleteIPAddress(context.Background(), reservationID).Execute() diff --git a/internal/ips/request.go b/internal/ips/request.go index 9f5d2a90..9fe575fa 100644 --- a/internal/ips/request.go +++ b/internal/ips/request.go @@ -37,7 +37,7 @@ func (c *Client) Request() *cobra.Command { metal ip request -p $METAL_PROJECT_ID -t public_ipv4 -q 4 -m da metal ip request -v df18fbd8-2919-4104-a042-5d42a05b8eed -t vrf --cidr 24 -n 172.89.1.0 --tags foo --tags bar --customdata '{"my":"goodness"}' --details "i don't think VRF users need this or will see it after submitting the request"`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { var ( req *metal.IPReservationRequestInput diff --git a/internal/ips/retrieve.go b/internal/ips/retrieve.go index 5ecd81a7..14f06b71 100644 --- a/internal/ips/retrieve.go +++ b/internal/ips/retrieve.go @@ -50,7 +50,7 @@ func (c *Client) Retrieve() *cobra.Command { # Gets the IP addresses from a reservation ID: metal ip get -r da1bb048-ea6e-4911-8ab9-b95635ca127a`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if assignmentID != "" && reservationID != "" { return fmt.Errorf("either assignment-id or reservation-id can be set") diff --git a/internal/ips/unassign.go b/internal/ips/unassign.go index 2783596d..d4c084bc 100644 --- a/internal/ips/unassign.go +++ b/internal/ips/unassign.go @@ -36,7 +36,7 @@ func (c *Client) Unassign() *cobra.Command { Long: "Unassigns an subnet and IP address assignment from a device by its assignment ID. ", Example: ` # Unassigns an IP address assignment: metal ip unassign --id abd8674b-96c4-4271-92f5-2eaf5944c86f`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true _, err := c.IPService.DeleteIPAddress(context.Background(), assignmentID).Execute() diff --git a/internal/metros/metro.go b/internal/metros/metro.go index 634a51e8..dc543ebf 100644 --- a/internal/metros/metro.go +++ b/internal/metros/metro.go @@ -38,6 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"metro"}, Short: "Metro operations: get.", Long: "Get information on Metro locations. For more information on https://deploy.equinix.com/developers/docs/metal/locations/metros/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/metros/retrieve.go b/internal/metros/retrieve.go index 2d6fdfce..d0067302 100644 --- a/internal/metros/retrieve.go +++ b/internal/metros/retrieve.go @@ -36,7 +36,7 @@ func (c *Client) Retrieve() *cobra.Command { Long: "Retrieves a list of metros available to the current user.", Example: ` # Lists metros available to the current user: metal metros get`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true metrosList, _, err := c.Service.FindMetros(context.Background()).Execute() diff --git a/internal/organizations/create.go b/internal/organizations/create.go index a9604d45..aaa63898 100644 --- a/internal/organizations/create.go +++ b/internal/organizations/create.go @@ -47,7 +47,7 @@ func (c *Client) Create() *cobra.Command { # Creates a new organization with name, website, and twitter: metal organization create -n test-org -w www.metal.equinix.com -t https://twitter.com/equinixmetal `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/organizations/delete.go b/internal/organizations/delete.go index 7a006200..ce732bd9 100644 --- a/internal/organizations/delete.go +++ b/internal/organizations/delete.go @@ -56,7 +56,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes an organization, skipping confirmation: metal organization delete -i 3bd5bf07-6094-48ad-bd03-d94e8712fdc8 -f`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/organizations/organization.go b/internal/organizations/organization.go index f73b21b5..b8905127 100644 --- a/internal/organizations/organization.go +++ b/internal/organizations/organization.go @@ -38,7 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"organizations", "org", "orgs"}, Short: "Organization operations: create, get, update, payment-methods, and delete.", Long: "Information and management of Organization-level settings. Documentation on organizations is in https://deploy.equinix.com/developers/docs/metal/identity-access-management/organizations/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/organizations/payment.go b/internal/organizations/payment.go index fc495201..f0660fcf 100644 --- a/internal/organizations/payment.go +++ b/internal/organizations/payment.go @@ -37,7 +37,7 @@ func (c *Client) PaymentMethods() *cobra.Command { Long: "Retrieves a list of payment methods for the specified organization if the current user is a member with the proper role.", Example: ` # Lists the payment methods for an organization: metal organization payment-methods --id 3bd5bf07-6094-48ad-bd03-d94e8712fdc8`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/organizations/retrieve.go b/internal/organizations/retrieve.go index 2a7b726f..1b76a0c9 100644 --- a/internal/organizations/retrieve.go +++ b/internal/organizations/retrieve.go @@ -40,7 +40,7 @@ func (c *Client) Retrieve() *cobra.Command { # Retrieves details of an organization: metal organization get -i 3bd5bf07-6094-48ad-bd03-d94e8712fdc8`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/organizations/update.go b/internal/organizations/update.go index 76efb604..df99527c 100644 --- a/internal/organizations/update.go +++ b/internal/organizations/update.go @@ -37,7 +37,7 @@ func (c *Client) Update() *cobra.Command { Long: "Updates the specified organization. You can update the name, website, Twitter, or logo.", Example: ` # Updates the name of an organization: metal organization update -i 3bd5bf07-6094-48ad-bd03-d94e8712fdc8 --name test-cluster02`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true req := metal.NewOrganizationInput() diff --git a/internal/os/os.go b/internal/os/os.go index 1945d629..40eed1eb 100644 --- a/internal/os/os.go +++ b/internal/os/os.go @@ -38,6 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"os"}, Short: "Operating system operations: get.", Long: "Information on available operating systems. For more information on which operating systems Equinix Metal offers, visit https://deploy.equinix.com/developers/docs/metal/operating-systems/supported/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/plans/plan.go b/internal/plans/plan.go index e77919b4..fa23d1bf 100644 --- a/internal/plans/plan.go +++ b/internal/plans/plan.go @@ -38,6 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"plans"}, Short: "Plan operations: get.", Long: "Information on server plans. For more information on the different Equinix Metal severs, visit https://deploy.equinix.com/developers/docs/metal/hardware/standard-servers/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/ports/convert.go b/internal/ports/convert.go index 838bcc05..1a5c62d9 100644 --- a/internal/ports/convert.go +++ b/internal/ports/convert.go @@ -60,6 +60,7 @@ func (c *Client) Convert() *cobra.Command { # Converts port to layer-3 bonded with public IPv4 and public IPv6: metal port convert -i 3bd5bf07-6094-48ad-bd03-d94e8712fdc8 -2=false -b -4 -6`, // TODO: can we add ip-reservation-id? + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/ports/port.go b/internal/ports/port.go index e1fbd196..3028959c 100644 --- a/internal/ports/port.go +++ b/internal/ports/port.go @@ -40,6 +40,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"ports"}, Short: "Port operations: get, convert, vlans.", Long: "Information and operations for converting ports between networking modes and managing VLAN assignments to ports. For more information on the different modes, ports, and VLANs, visit https://deploy.equinix.com/developers/docs/metal/layer2-networking/overview/.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/ports/retrieve.go b/internal/ports/retrieve.go index 248e0251..669d630a 100644 --- a/internal/ports/retrieve.go +++ b/internal/ports/retrieve.go @@ -38,7 +38,7 @@ func (c *Client) Retrieve() *cobra.Command { Long: "Retrieves the details of the specified port. Details of an port are only available to its members.", Example: ` # Retrieves details of a port: metal port get -i 3bd5bf07-6094-48ad-bd03-d94e8712fdc8`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true port, _, err := c.PortService.FindPortById(context.Background(), portID). diff --git a/internal/ports/vlans.go b/internal/ports/vlans.go index e2cf686e..50270e51 100644 --- a/internal/ports/vlans.go +++ b/internal/ports/vlans.go @@ -48,7 +48,7 @@ func (c *Client) Vlans() *cobra.Command { # Assigns VXLAN 1234 to the port and makes it the Native VLAN: metal port vlans -i 3bd5bf07-6094-48ad-bd03-d94e8712fdc8 --native=1234`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true req := metal.NewPortVlanAssignmentBatchCreateInput() diff --git a/internal/projects/bgpconfig.go b/internal/projects/bgpconfig.go index b6c14e32..51358242 100644 --- a/internal/projects/bgpconfig.go +++ b/internal/projects/bgpconfig.go @@ -21,6 +21,7 @@ func (c *Client) BGPConfig() *cobra.Command { Short: "Gets BGP Config for a project.", Long: `Gets BGP Config for a project.`, Example: ` metal project bgp-config --project-id 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 -d `, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return getBGPConfig(c, &flags) }, diff --git a/internal/projects/bgpenable.go b/internal/projects/bgpenable.go index d553153a..5171dc41 100644 --- a/internal/projects/bgpenable.go +++ b/internal/projects/bgpenable.go @@ -26,6 +26,7 @@ func (c *Client) BGPEnable() *cobra.Command { Short: "Enables BGP on a project.", Long: `Enables BGP on a project.`, Example: ` metal project bgp-enable --project-id 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 --deployment-type local --asn 65000`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return enableBGP(c, &config) }, diff --git a/internal/projects/create.go b/internal/projects/create.go index 54ff804e..1eeada35 100644 --- a/internal/projects/create.go +++ b/internal/projects/create.go @@ -45,7 +45,7 @@ func (c *Client) Create() *cobra.Command { # Creates a new project named dev-cluster03 in the specified organization with a payment method: metal project create -n dev-cluster03 -O 814b09ca-0d0c-4656-9de0-4ce65c6faf70 -m ab1fbdaa-8b25-4c3e-8360-e283852e3747`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true req := metal.NewProjectCreateFromRootInput(name) diff --git a/internal/projects/delete.go b/internal/projects/delete.go index fe85b8ad..95632591 100644 --- a/internal/projects/delete.go +++ b/internal/projects/delete.go @@ -54,7 +54,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes project 50693ba9-e4e4-4d8a-9eb2-4840b11e9375, skipping confirmation: metal project delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 -f`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/projects/project.go b/internal/projects/project.go index 99e63e8b..fd269484 100644 --- a/internal/projects/project.go +++ b/internal/projects/project.go @@ -40,7 +40,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"projects"}, Short: "Project operations: create, get, update, delete, and bgp-enable, bgp-config, bgp-sessions.", Long: "Information and management for Projects and Project-level BGP. Documentation on Projects is on https://deploy.equinix.com/developers/docs/metal/projects/creating-a-project/, and documentation on BGP is on https://deploy.equinix.com/developers/docs/metal/bgp/bgp-on-equinix-metal/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/projects/retrieve.go b/internal/projects/retrieve.go index 00f53d4c..aaf6cacf 100644 --- a/internal/projects/retrieve.go +++ b/internal/projects/retrieve.go @@ -47,9 +47,7 @@ func (c *Client) Retrieve() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true - if projectID != "" && projectName != "" { - return fmt.Errorf("Must specify only one of project-id and project name") - } + inc := c.Servicer.Includes(nil) exc := c.Servicer.Excludes(nil) @@ -104,5 +102,7 @@ func (c *Client) Retrieve() *cobra.Command { retrieveProjectCmd.Flags().StringVarP(&projectName, "project", "n", "", "The name of the project.") retrieveProjectCmd.Flags().StringVarP(&projectID, "id", "i", "", "The project's UUID, which can be specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.") + retrieveProjectCmd.MarkFlagsMutuallyExclusive("id", "project") + retrieveProjectCmd.Args = cobra.NoArgs return retrieveProjectCmd } diff --git a/internal/projects/update.go b/internal/projects/update.go index 3f5cbf88..b4573bc3 100644 --- a/internal/projects/update.go +++ b/internal/projects/update.go @@ -39,7 +39,7 @@ func (c *Client) Update() *cobra.Command { # Updates the specified project with a new payment method: metal project update -i $METAL_PROJECT_ID -m e2fcdf91-b6dc-4d6a-97ad-b26a14b66839`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true req := metal.NewProjectUpdateInput() diff --git a/internal/ssh/create.go b/internal/ssh/create.go index 9497ebd5..31c17030 100644 --- a/internal/ssh/create.go +++ b/internal/ssh/create.go @@ -40,7 +40,7 @@ func (c *Client) Create() *cobra.Command { Long: "Adds an SSH key for the current user's account. The key will then be added to the user's servers at provision time.", Example: ` # Adds a key labled "example-key" to the current user account. metal ssh-key create --key ssh-rsa AAAAB3N...user@domain.com --label example-key`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true sSHKeyCreateInput := &metal.SSHKeyCreateInput{ diff --git a/internal/ssh/delete.go b/internal/ssh/delete.go index c368dae7..051b440b 100644 --- a/internal/ssh/delete.go +++ b/internal/ssh/delete.go @@ -54,7 +54,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes an SSH key, skipping confirmation: metal ssh-key delete -i 5cb96463-88fd-4d68-94ba-2c9505ff265e -f`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/ssh/retrieve.go b/internal/ssh/retrieve.go index 6059dca2..4e0552cb 100644 --- a/internal/ssh/retrieve.go +++ b/internal/ssh/retrieve.go @@ -49,6 +49,7 @@ func (c *Client) Retrieve() *cobra.Command { # Retrieve all project SSH keys metal ssh-key get --project-ssh-keys --project-id [project_UUID]`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true if sshKeyID == "" { diff --git a/internal/ssh/ssh.go b/internal/ssh/ssh.go index fe3c3def..5a5ee9c5 100644 --- a/internal/ssh/ssh.go +++ b/internal/ssh/ssh.go @@ -38,7 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{`ssh-keys`}, Short: "SSH key operations: create, get, update, and delete.", Long: "SSH key operations for managing SSH keys on user accounts and projects. Keys added to an account or project are added to servers at provision. Documentation is available on https://deploy.equinix.com/developers/docs/metal/identity-access-management/ssh-keys/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/ssh/update.go b/internal/ssh/update.go index c1900e3a..9059ad8f 100644 --- a/internal/ssh/update.go +++ b/internal/ssh/update.go @@ -40,7 +40,7 @@ func (c *Client) Update() *cobra.Command { # Updates SSH key 5cb96463-88fd-4d68-94ba-2c9505ff265e with a new label: metal ssh-key update -i 5cb96463-88fd-4d68-94ba-2c9505ff265e -l test-machine-2`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true req := metal.NewSSHKeyInput() diff --git a/internal/twofa/disable2fa.go b/internal/twofa/disable2fa.go index 1b614cdc..00f043dd 100644 --- a/internal/twofa/disable2fa.go +++ b/internal/twofa/disable2fa.go @@ -42,7 +42,7 @@ func (c *Client) Disable() *cobra.Command { # Disable two-factor authentication via APP metal 2fa disable -a -c `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if sms == app { return fmt.Errorf("either sms or app should be set") diff --git a/internal/twofa/enable2fa.go b/internal/twofa/enable2fa.go index 2c6b56cc..fac895e4 100644 --- a/internal/twofa/enable2fa.go +++ b/internal/twofa/enable2fa.go @@ -41,7 +41,7 @@ func (c *Client) Enable() *cobra.Command { # Enable two factor authentication via an application. metal 2fa enable -a -c `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if sms == app { return fmt.Errorf("either sms or app should be set") diff --git a/internal/twofa/receive.go b/internal/twofa/receive.go index a15eef3b..93a97e03 100644 --- a/internal/twofa/receive.go +++ b/internal/twofa/receive.go @@ -40,7 +40,7 @@ func (c *Client) Receive() *cobra.Command { # Issue the token via app: metal 2fa receive -a`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if sms == app { return fmt.Errorf("either sms or app should be set") diff --git a/internal/twofa/twofa.go b/internal/twofa/twofa.go index c66a4764..cbd2ad79 100644 --- a/internal/twofa/twofa.go +++ b/internal/twofa/twofa.go @@ -40,7 +40,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"tfa", "mfa", "totp"}, Short: "Two-factor Authentication operations: receive, enable, disable.", Long: "Enable or disable two-factor authentication on your user account or receive an OTP token. More information is available at https://deploy.equinix.com/developers/docs/metal/identity-access-management/users/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/users/add.go b/internal/users/add.go index 576a3031..20b6ff3e 100644 --- a/internal/users/add.go +++ b/internal/users/add.go @@ -44,7 +44,7 @@ func (c *Client) Add() *cobra.Command { Example: ` # Adds a user to a project with admin role: metal user add --email user@example.org --roles admin --project-id 3b0795ba-fd0b-4a9e-83a7-063e5e12409d `, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true invitationInput := metal.NewInvitationInput(email) diff --git a/internal/users/retrieve.go b/internal/users/retrieve.go index fd2b831c..d98c7df8 100644 --- a/internal/users/retrieve.go +++ b/internal/users/retrieve.go @@ -41,7 +41,7 @@ func (c *Client) Retrieve() *cobra.Command { # Returns information on user 3b0795ba-fd0b-4a9e-83a7-063e5e12409d: metal user get --i 3b0795ba-fd0b-4a9e-83a7-063e5e12409d`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true var err error diff --git a/internal/users/user.go b/internal/users/user.go index 03abe845..db322cfd 100644 --- a/internal/users/user.go +++ b/internal/users/user.go @@ -39,7 +39,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"users"}, Short: "User operations: get and add.", Long: "Adding users or getting their details. For more information on user and account management, visit https://deploy.equinix.com/developers/docs/metal/identity-access-management/users/ in the Equinix Metal documentation.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/virtualcircuit/create.go b/internal/virtualcircuit/create.go index 65685e7d..c4a4e334 100644 --- a/internal/virtualcircuit/create.go +++ b/internal/virtualcircuit/create.go @@ -96,7 +96,7 @@ func (c *Client) Create() *cobra.Command { metal vc create -c 81c9cb9e-b02f-4c73-9e04-06702f1380a0 -p 9c8f0c71-591d-42fe-9519-2f632761e2da -P b4673e33-0f48-4948-961a-c31d6edf64f8 -n test-inter -d test-interconnection -v 15315810-2fda-48b8-b8cd-441ebab684b5 -V 1010 -s 100 metal vc create [-c connection_id] [-p port_id] [-P ] [-n ] [-d ] [-v ] [-M ] [-a ] [-S ] [-c ] [-m ]`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true var ( diff --git a/internal/virtualcircuit/delete.go b/internal/virtualcircuit/delete.go index 01b52287..eb1088b9 100644 --- a/internal/virtualcircuit/delete.go +++ b/internal/virtualcircuit/delete.go @@ -16,7 +16,7 @@ func (c *Client) Delete() *cobra.Command { Long: "Deletes the specified virtual-circuit.", Example: ` # Deletes the specified virtual-circuit: metal vc delete -i 7ec86e23-8dcf-48ed-bd9b-c25c20958277`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true inc := []string{} diff --git a/internal/virtualcircuit/retrieve.go b/internal/virtualcircuit/retrieve.go index 4266bb71..e7822651 100644 --- a/internal/virtualcircuit/retrieve.go +++ b/internal/virtualcircuit/retrieve.go @@ -42,7 +42,7 @@ func (c *Client) Retrieve() *cobra.Command { # Retrieve the details of a specific virtual-circuit: metal vc get -i e9a969b3-8911-4667-9d99-57cd3dd4ef6f`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/virtualcircuit/update.go b/internal/virtualcircuit/update.go index d5b75869..ab8c5af9 100644 --- a/internal/virtualcircuit/update.go +++ b/internal/virtualcircuit/update.go @@ -86,7 +86,7 @@ func (c *Client) Update() *cobra.Command { metal vc update -i e2edb90b-a8ef-47cb-a577-63b0ba129c29 -d "test-inter-fri-dedicated" metal vc update [-i ] [-n ] [-d ] [-M ] [-a ] [-S ] [-c ] [-m ] [-t ]`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true inc := []string{} diff --git a/internal/virtualcircuit/virtualcircuit.go b/internal/virtualcircuit/virtualcircuit.go index 13d0135b..3f91b8f0 100644 --- a/internal/virtualcircuit/virtualcircuit.go +++ b/internal/virtualcircuit/virtualcircuit.go @@ -18,6 +18,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"vc"}, Short: "virtual-circuit operations: create, get, update, delete", Long: "For more information on https://deploy.equinix.com/developers/docs/metal/interconnections.", + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/vlan/create.go b/internal/vlan/create.go index 987b9f13..301316fd 100644 --- a/internal/vlan/create.go +++ b/internal/vlan/create.go @@ -43,7 +43,7 @@ func (c *Client) Create() *cobra.Command { # Creates a VLAN in the sjc1 facility metal virtual-network create -p $METAL_PROJECT_ID -f sjc1`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true virtualNetworkCreateInput := metal.NewVirtualNetworkCreateInput() diff --git a/internal/vlan/delete.go b/internal/vlan/delete.go index b622120f..9e89af31 100644 --- a/internal/vlan/delete.go +++ b/internal/vlan/delete.go @@ -56,7 +56,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes a VLAN, skipping confirmation. metal virtual-network delete -f -i 77e6d57a-d7a4-4816-b451-cf9b043444e2`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/vlan/retrieve.go b/internal/vlan/retrieve.go index 39d2945d..d09e33d4 100644 --- a/internal/vlan/retrieve.go +++ b/internal/vlan/retrieve.go @@ -38,7 +38,7 @@ func (c *Client) Retrieve() *cobra.Command { Long: "Retrieves a list of all VLANs for the specified project.", Example: ` # Lists virtual networks for project 3b0795ba-ec9a-4a9e-83a7-043e7e11407c: metal virtual-network get -p 3b0795ba-ec9a-4a9e-83a7-043e7e11407c`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true request := c.Service.FindVirtualNetworks(cmd.Context(), projectID).Include(c.Servicer.Includes(nil)).Exclude(c.Servicer.Excludes(nil)) diff --git a/internal/vlan/vlan.go b/internal/vlan/vlan.go index bab9895c..2284e599 100644 --- a/internal/vlan/vlan.go +++ b/internal/vlan/vlan.go @@ -38,7 +38,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"vlan", "vlans"}, Short: "Virtual network (VLAN) operations : create, get, delete.", Long: "Managing Virtual Networks on a Project. VLAN assignments to a server's ports is available through the `ports` command. For more information on how VLANs work in Equinix Metal, visit https://deploy.equinix.com/developers/docs/metal/layer2-networking/vlans/.", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil { diff --git a/internal/vrf/create.go b/internal/vrf/create.go index 4291e108..91d020d3 100644 --- a/internal/vrf/create.go +++ b/internal/vrf/create.go @@ -29,6 +29,7 @@ func (c *Client) Create() *cobra.Command { Example: ` # Creates an Creates a Virtual Routing and Forwarding(VRF) for a specified project. metal vrf create [-p ] [-m ] [-n ] [-a ] [-r ] [-t ]`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/vrf/createroute.go b/internal/vrf/createroute.go index f8d1364a..7525bbe6 100644 --- a/internal/vrf/createroute.go +++ b/internal/vrf/createroute.go @@ -25,6 +25,7 @@ func (c *Client) CreateRoute() *cobra.Command { Example: ` # Create a route in a VRF. Currently only static default routes are supported.. metal vrf create-route [-i ] [-p ] [-n nextHop] [-t ]`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true inc := []string{} diff --git a/internal/vrf/delete.go b/internal/vrf/delete.go index d1add3fd..fd604b73 100644 --- a/internal/vrf/delete.go +++ b/internal/vrf/delete.go @@ -36,6 +36,7 @@ func (c *Client) Delete() *cobra.Command { # Deletes a VRF, skipping confirmation. metal delete vrf -f -i 77e6d57a-d7a4-4816-b451-cf9b043444e2`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/vrf/deleteroute.go b/internal/vrf/deleteroute.go index 787a0186..c5185b49 100644 --- a/internal/vrf/deleteroute.go +++ b/internal/vrf/deleteroute.go @@ -36,7 +36,7 @@ func (c *Client) DeleteRoute() *cobra.Command { # Deletes a VRF, skipping confirmation. metal vrf delete-route -f -i 77e6d57a-d7a4-4816-b451-cf9b043444e2`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/vrf/ips.go b/internal/vrf/ips.go index 0ec20e8f..a1196f1b 100644 --- a/internal/vrf/ips.go +++ b/internal/vrf/ips.go @@ -25,6 +25,7 @@ func (c *Client) Ips() *cobra.Command { # Retrieve a specific IP Reservation for a VRF metal vrf ips [-v ]`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true diff --git a/internal/vrf/retrieve.go b/internal/vrf/retrieve.go index abccd64c..17943174 100644 --- a/internal/vrf/retrieve.go +++ b/internal/vrf/retrieve.go @@ -27,7 +27,7 @@ func (c *Client) Retrieve() *cobra.Command { # Lists VRFs for project 3b0795ba-ec9a-4a9e-83a7-043e7e11407c: metal vrf list -p 3b0795ba-ec9a-4a9e-83a7-043e7e11407c`, - + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true inc := []string{} diff --git a/internal/vrf/retrieveroute.go b/internal/vrf/retrieveroute.go index 42528f0f..45f3a505 100644 --- a/internal/vrf/retrieveroute.go +++ b/internal/vrf/retrieveroute.go @@ -20,6 +20,7 @@ func (c *Client) RetrieveRoute() *cobra.Command { Example: ` #Retrieve all routes in the VRF # Retrieve all routes in the VRF metal vrf get-route -i bb526d47-8536-483c-b436-116a5fb72235`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true inc := []string{} diff --git a/internal/vrf/updateroute.go b/internal/vrf/updateroute.go index d508bd53..482425a7 100644 --- a/internal/vrf/updateroute.go +++ b/internal/vrf/updateroute.go @@ -24,6 +24,7 @@ func (c *Client) UpdateRoute() *cobra.Command { Example: ` #Requests a VRF Route be redeployed/update across the network. metal vrf update-route [-i ] [-p ] [-n nextHop] [-t ]`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true inc := []string{} diff --git a/internal/vrf/vrf.go b/internal/vrf/vrf.go index 50963ad7..91d374b8 100644 --- a/internal/vrf/vrf.go +++ b/internal/vrf/vrf.go @@ -18,7 +18,7 @@ func (c *Client) NewCommand() *cobra.Command { Aliases: []string{"vrf"}, Short: "VRF operations : create, get, delete", Long: "VRF operations : It defines a collection of customer-managed IP blocks that can be used in BGP peering on one or more virtual networks and basic operations", - + Args: cobra.NoArgs, PersistentPreRun: func(cmd *cobra.Command, args []string) { if root := cmd.Root(); root != nil { if root.PersistentPreRun != nil {