From 3554c88207b8b5db96c82a81d781f70ea05f55d8 Mon Sep 17 00:00:00 2001 From: jasmingacic Date: Mon, 12 Aug 2019 22:40:23 +0200 Subject: [PATCH] Live tests and version 0.0.3 --- .gitignore | 1 + Makefile | 7 +- cmd/create_device.go | 2 + cmd/create_organization.go | 2 + cmd/create_project.go | 2 + cmd/create_ssh-key.go | 2 + cmd/create_virtual_network.go | 2 + cmd/create_volume.go | 3 +- cmd/hardware_reservations.go | 2 +- cmd/retrieve_volume.go | 2 +- cmd/root.go | 8 +- docs/packet.md | 6 +- docs/packet_2fa.md | 4 +- docs/packet_2fa_disable.md | 4 +- docs/packet_2fa_enable.md | 4 +- docs/packet_2fa_receive.md | 4 +- docs/packet_device.md | 4 +- docs/packet_device_create.md | 6 +- docs/packet_device_delete.md | 4 +- docs/packet_device_get.md | 4 +- docs/packet_device_reboot.md | 4 +- docs/packet_device_start.md | 4 +- docs/packet_device_stop.md | 4 +- docs/packet_device_update.md | 4 +- docs/packet_event.md | 4 +- docs/packet_event_get.md | 4 +- docs/packet_facilities.md | 4 +- docs/packet_facilities_get.md | 4 +- ...tion.md => packet_hardware-reservation.md} | 12 +- ....md => packet_hardware-reservation_get.md} | 10 +- ...md => packet_hardware-reservation_move.md} | 10 +- docs/packet_ip.md | 4 +- docs/packet_ip_assign.md | 4 +- docs/packet_ip_available.md | 4 +- docs/packet_ip_get.md | 4 +- docs/packet_ip_remove.md | 4 +- docs/packet_ip_request.md | 4 +- docs/packet_ip_unassign.md | 4 +- docs/packet_operating-systems.md | 4 +- docs/packet_operating-systems_get.md | 4 +- docs/packet_organization.md | 4 +- docs/packet_organization_create.md | 6 +- docs/packet_organization_delete.md | 4 +- docs/packet_organization_get.md | 4 +- ...packet_organization_get_payment-methods.md | 4 +- docs/packet_organization_update.md | 4 +- docs/packet_plan.md | 4 +- docs/packet_plan_get.md | 4 +- docs/packet_project.md | 4 +- docs/packet_project_create.md | 6 +- docs/packet_project_delete.md | 4 +- docs/packet_project_get.md | 7 +- docs/packet_project_update.md | 4 +- docs/packet_ssh-key.md | 4 +- docs/packet_ssh-key_create.md | 6 +- docs/packet_ssh-key_delete.md | 4 +- docs/packet_ssh-key_get.md | 4 +- docs/packet_ssh-key_update.md | 4 +- docs/packet_user.md | 4 +- docs/packet_user_get.md | 4 +- docs/packet_virtual-network.md | 4 +- docs/packet_virtual-network_create.md | 6 +- docs/packet_virtual-network_delete.md | 4 +- docs/packet_virtual-network_get.md | 4 +- docs/packet_volume.md | 4 +- docs/packet_volume_attach.md | 4 +- docs/packet_volume_create.md | 6 +- docs/packet_volume_delete.md | 4 +- docs/packet_volume_detach.md | 4 +- docs/packet_volume_get.md | 6 +- docs/packet_vpn.md | 4 +- docs/packet_vpn_disable.md | 4 +- docs/packet_vpn_enable.md | 4 +- docs/packet_vpn_get.md | 4 +- tests/facilities_test.go | 39 ++++ tests/main_test.go | 140 ++++++++++++ tests/organization_test.go | 127 +++++++++++ tests/plan_test.go | 39 ++++ tests/project_test.go | 101 +++++++++ tests/ssh_key_test.go | 98 +++++++++ tests/virtual_network_test.go | 121 +++++++++++ tests/volumes_test.go | 203 ++++++++++++++++++ 82 files changed, 1042 insertions(+), 150 deletions(-) rename docs/{packet_hardware_reservation.md => packet_hardware-reservation.md} (51%) rename docs/{packet_hardware_reservation_get.md => packet_hardware-reservation_get.md} (65%) rename docs/{packet_hardware_reservation_move.md => packet_hardware-reservation_move.md} (59%) create mode 100644 tests/facilities_test.go create mode 100644 tests/main_test.go create mode 100644 tests/organization_test.go create mode 100644 tests/plan_test.go create mode 100644 tests/project_test.go create mode 100644 tests/ssh_key_test.go create mode 100644 tests/virtual_network_test.go create mode 100644 tests/volumes_test.go diff --git a/.gitignore b/.gitignore index f052ae18..57d9fc80 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.dll *.so *.dylib +packet # Test binary, build with `go test -c` *.test diff --git a/Makefile b/Makefile index c1512a5f..1765c2f9 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ K := $(foreach exec,$(EXECUTABLES),\ ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) BINARY=packet -VERSION=0.0.1 +VERSION=0.0.3 BUILD=`git rev-parse HEAD` PLATFORMS=darwin linux windows ARCHITECTURES=amd64 arm64 @@ -34,4 +34,7 @@ install: generate-docs: clean-docs mkdir -p docs - GENDOCS=true go run main.go \ No newline at end of file + GENDOCS=true go run main.go + +test: + go test ./tests diff --git a/cmd/create_device.go b/cmd/create_device.go index 828f560f..73997617 100644 --- a/cmd/create_device.go +++ b/cmd/create_device.go @@ -149,4 +149,6 @@ func init() { createDeviceCmd.Flags().BoolVarP(&spotInstance, "spot-instance", "I", false, `Set the device as a spot instance`) createDeviceCmd.Flags().Float64VarP(&spotPriceMax, "spot-price-max", "m", 0, `--spot-price-max=1.2 or -m=1.2`) createDeviceCmd.Flags().StringVarP(&terminationTime, "termination-time", "T", "", `Device termination time: --termination-time="15:04:05"`) + createDeviceCmd.PersistentFlags().BoolVarP(&isJSON, "json", "j", false, "JSON output") + createDeviceCmd.PersistentFlags().BoolVarP(&isYaml, "yaml", "y", false, "YAML output") } diff --git a/cmd/create_organization.go b/cmd/create_organization.go index 169db1ad..3dbc3b59 100644 --- a/cmd/create_organization.go +++ b/cmd/create_organization.go @@ -81,4 +81,6 @@ func init() { createOrganizationCmd.Flags().StringVarP(&logo, "logo", "l", "", "Logo URL]") createOrganizationCmd.MarkFlagRequired("name") + createOrganizationCmd.PersistentFlags().BoolVarP(&isJSON, "json", "j", false, "JSON output") + createOrganizationCmd.PersistentFlags().BoolVarP(&isYaml, "yaml", "y", false, "YAML output") } diff --git a/cmd/create_project.go b/cmd/create_project.go index 10d8464c..b27c0414 100644 --- a/cmd/create_project.go +++ b/cmd/create_project.go @@ -74,4 +74,6 @@ func init() { createProjectCmd.Flags().StringVarP(&paymentMethodID, "payment-method-id", "m", "", "UUID of the payment method") createProjectCmd.MarkFlagRequired("name") + createProjectCmd.PersistentFlags().BoolVarP(&isJSON, "json", "j", false, "JSON output") + createProjectCmd.PersistentFlags().BoolVarP(&isYaml, "yaml", "y", false, "YAML output") } diff --git a/cmd/create_ssh-key.go b/cmd/create_ssh-key.go index 098d57ef..04699777 100644 --- a/cmd/create_ssh-key.go +++ b/cmd/create_ssh-key.go @@ -67,4 +67,6 @@ func init() { createSSHKeyCmd.MarkFlagRequired("label") createSSHKeyCmd.MarkFlagRequired("key") + createSSHKeyCmd.PersistentFlags().BoolVarP(&isJSON, "json", "j", false, "JSON output") + createSSHKeyCmd.PersistentFlags().BoolVarP(&isYaml, "yaml", "y", false, "YAML output") } diff --git a/cmd/create_virtual_network.go b/cmd/create_virtual_network.go index 04f180fb..f41f189d 100644 --- a/cmd/create_virtual_network.go +++ b/cmd/create_virtual_network.go @@ -84,4 +84,6 @@ func init() { createVirtualNetworkCmd.MarkFlagRequired("project-id") createVirtualNetworkCmd.MarkFlagRequired("facility") + createVirtualNetworkCmd.PersistentFlags().BoolVarP(&isJSON, "json", "j", false, "JSON output") + createVirtualNetworkCmd.PersistentFlags().BoolVarP(&isYaml, "yaml", "y", false, "YAML output") } diff --git a/cmd/create_volume.go b/cmd/create_volume.go index c5ba2af7..012a54ad 100644 --- a/cmd/create_volume.go +++ b/cmd/create_volume.go @@ -84,5 +84,6 @@ func init() { createVolumeCmd.Flags().StringVarP(&billingCycle, "billing-cycle", "b", "hourly", "Billing cycle") createVolumeCmd.Flags().StringVarP(&description, "description", "d", "", "Description of the volume") createVolumeCmd.Flags().BoolVarP(&locked, "locked", "l", false, "Set the volume to be locked") - + createVolumeCmd.PersistentFlags().BoolVarP(&isJSON, "json", "j", false, "JSON output") + createVolumeCmd.PersistentFlags().BoolVarP(&isYaml, "yaml", "y", false, "YAML output") } diff --git a/cmd/hardware_reservations.go b/cmd/hardware_reservations.go index f323e889..63b03e1c 100644 --- a/cmd/hardware_reservations.go +++ b/cmd/hardware_reservations.go @@ -26,7 +26,7 @@ import ( // hardwareReservationsCmd represents the hardwareReservations command var hardwareReservationsCmd = &cobra.Command{ - Use: "hardware_reservation", + Use: "hardware-reservation", Short: "Hardware reservation operations", Long: `Hardware reservation operations: get, move`, } diff --git a/cmd/retrieve_volume.go b/cmd/retrieve_volume.go index d0a9e748..c3a45ab1 100644 --- a/cmd/retrieve_volume.go +++ b/cmd/retrieve_volume.go @@ -41,7 +41,7 @@ Retrieve the list of volumes: packet volume get --project-id [project_UUID] Retrieve a specific volume: -packet get volume --id [volume_UUID] +packet volume get --id [volume_UUID] `, Run: func(cmd *cobra.Command, args []string) { diff --git a/cmd/root.go b/cmd/root.go index c6234f91..56cfc40e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -49,7 +49,7 @@ var rootCmd = &cobra.Command{ func packetConnect(cmd *cobra.Command, args []string) { if packetToken == "" { - fmt.Println("Packet authentication token not provided. Please either set the 'PACKET_TOKEN' environment variable or create a JSON configuration file.") + fmt.Println("Packet authentication token not provided. Please either set the 'PACKET_TOKEN' environment variable or create a JSON or YAML configuration file.") os.Exit(1) } client, err := packngo.NewClientWithBaseURL("Packet CLI", packetToken, nil, "https://api.packet.net/") @@ -86,11 +86,7 @@ func initConfig() { viper.AddConfigPath(userHomeDir()) } - err := viper.ReadInConfig() - if err != nil { - fmt.Printf("Unable to read in config file, check the file path and defaults (./packet-cli.{yaml,json} in user home directory) and try again") - os.Exit(1) - } + viper.ReadInConfig() if viper.GetString("token") != "" { packetToken = viper.GetString("token") diff --git a/docs/packet.md b/docs/packet.md index 599631b9..efd7b176 100644 --- a/docs/packet.md +++ b/docs/packet.md @@ -9,7 +9,7 @@ Command line interface for Packet Host ### Options ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file -h, --help Help for packet --version Version for packet ``` @@ -20,7 +20,7 @@ Command line interface for Packet Host * [packet device](packet_device.md) - Device operations * [packet event](packet_event.md) - Events operations * [packet facilities](packet_facilities.md) - Facility operations -* [packet hardware_reservation](packet_hardware_reservation.md) - Hardware reservation operations +* [packet hardware-reservation](packet_hardware-reservation.md) - Hardware reservation operations * [packet ip](packet_ip.md) - IP operations * [packet operating-systems](packet_operating-systems.md) - Operating system operations * [packet organization](packet_organization.md) - Organization operations @@ -32,4 +32,4 @@ Command line interface for Packet Host * [packet volume](packet_volume.md) - Volume operations * [packet vpn](packet_vpn.md) - VPN service operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_2fa.md b/docs/packet_2fa.md index 9e15b9ac..bbf52b33 100644 --- a/docs/packet_2fa.md +++ b/docs/packet_2fa.md @@ -15,7 +15,7 @@ Two Factor Authentication operations: enable, disable, receive ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -25,4 +25,4 @@ Two Factor Authentication operations: enable, disable, receive * [packet 2fa enable](packet_2fa_enable.md) - Enables two factor authentication * [packet 2fa receive](packet_2fa_receive.md) - Receive two factor authentication token -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_2fa_disable.md b/docs/packet_2fa_disable.md index 5b2b4972..7d937219 100644 --- a/docs/packet_2fa_disable.md +++ b/docs/packet_2fa_disable.md @@ -29,11 +29,11 @@ packet 2fa disable [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet 2fa](packet_2fa.md) - Two Factor Authentication operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_2fa_enable.md b/docs/packet_2fa_enable.md index 1a5d3632..f8bf5623 100644 --- a/docs/packet_2fa_enable.md +++ b/docs/packet_2fa_enable.md @@ -29,11 +29,11 @@ packet 2fa enable [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet 2fa](packet_2fa.md) - Two Factor Authentication operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_2fa_receive.md b/docs/packet_2fa_receive.md index f1727d73..6a1581c9 100644 --- a/docs/packet_2fa_receive.md +++ b/docs/packet_2fa_receive.md @@ -28,11 +28,11 @@ packet 2fa receive [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet 2fa](packet_2fa.md) - Two Factor Authentication operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device.md b/docs/packet_device.md index 67cdfa98..b993f76e 100644 --- a/docs/packet_device.md +++ b/docs/packet_device.md @@ -15,7 +15,7 @@ Device operations: create, delete, update, start/stop, reboot and get. ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -29,4 +29,4 @@ Device operations: create, delete, update, start/stop, reboot and get. * [packet device stop](packet_device_stop.md) - Stops a device * [packet device update](packet_device_update.md) - Updates a device -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_create.md b/docs/packet_device_create.md index c355e352..af136528 100644 --- a/docs/packet_device_create.md +++ b/docs/packet_device_create.md @@ -25,6 +25,7 @@ packet device create [flags] -h, --help Help for create -H, --hostname string Hostname -i, --ipxe-script-url string URL to the iPXE script + -j, --json JSON output -o, --operating-system string Operating system name for the device -P, --plan string Name of the plan -p, --project-id string UUID of the project where the device will be created @@ -35,16 +36,17 @@ packet device create [flags] -t, --tags strings Tags for the device: --tags="tag1,tag2" -T, --termination-time string Device termination time: --termination-time="15:04:05" -u, --userdata string User data + -y, --yaml YAML output ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_delete.md b/docs/packet_device_delete.md index 7100bc62..09b688cc 100644 --- a/docs/packet_device_delete.md +++ b/docs/packet_device_delete.md @@ -25,11 +25,11 @@ packet device delete [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_get.md b/docs/packet_device_get.md index 19314507..6b2ac545 100644 --- a/docs/packet_device_get.md +++ b/docs/packet_device_get.md @@ -27,11 +27,11 @@ packet device get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_reboot.md b/docs/packet_device_reboot.md index 8b5ac082..53c4dfcf 100644 --- a/docs/packet_device_reboot.md +++ b/docs/packet_device_reboot.md @@ -24,11 +24,11 @@ packet device reboot [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_start.md b/docs/packet_device_start.md index bbbf1965..3ca0e624 100644 --- a/docs/packet_device_start.md +++ b/docs/packet_device_start.md @@ -24,11 +24,11 @@ packet device start [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_stop.md b/docs/packet_device_stop.md index 0411950e..fc10d1fd 100644 --- a/docs/packet_device_stop.md +++ b/docs/packet_device_stop.md @@ -24,11 +24,11 @@ packet device stop [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_device_update.md b/docs/packet_device_update.md index 41f64e93..c8a5deac 100644 --- a/docs/packet_device_update.md +++ b/docs/packet_device_update.md @@ -32,11 +32,11 @@ packet device update [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet device](packet_device.md) - Device operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_event.md b/docs/packet_event.md index c1699700..e25863a4 100644 --- a/docs/packet_event.md +++ b/docs/packet_event.md @@ -15,7 +15,7 @@ Events operations: get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -23,4 +23,4 @@ Events operations: get * [packet](packet.md) - Command line interface for Packet Host * [packet event get](packet_event_get.md) - Retrieves one or more events for organizations, projects, or devices. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_event_get.md b/docs/packet_event_get.md index 09a49543..9e90bfc4 100644 --- a/docs/packet_event_get.md +++ b/docs/packet_event_get.md @@ -43,11 +43,11 @@ packet event get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet event](packet_event.md) - Events operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_facilities.md b/docs/packet_facilities.md index a6100760..e8c4a21d 100644 --- a/docs/packet_facilities.md +++ b/docs/packet_facilities.md @@ -15,7 +15,7 @@ Facility operations: get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -23,4 +23,4 @@ Facility operations: get * [packet](packet.md) - Command line interface for Packet Host * [packet facilities get](packet_facilities_get.md) - Retrieves a list of available facilities. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_facilities_get.md b/docs/packet_facilities_get.md index f0db298a..77fda5ea 100644 --- a/docs/packet_facilities_get.md +++ b/docs/packet_facilities_get.md @@ -25,11 +25,11 @@ packet facilities get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet facilities](packet_facilities.md) - Facility operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_hardware_reservation.md b/docs/packet_hardware-reservation.md similarity index 51% rename from docs/packet_hardware_reservation.md rename to docs/packet_hardware-reservation.md index 7ecb842c..9cd4eb9f 100644 --- a/docs/packet_hardware_reservation.md +++ b/docs/packet_hardware-reservation.md @@ -1,4 +1,4 @@ -## packet hardware_reservation +## packet hardware-reservation Hardware reservation operations @@ -9,19 +9,19 @@ Hardware reservation operations: get, move ### Options ``` - -h, --help Help for hardware_reservation + -h, --help Help for hardware-reservation ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet](packet.md) - Command line interface for Packet Host -* [packet hardware_reservation get](packet_hardware_reservation_get.md) - Retrieves all hardware reservations of a project or a single hardware reservation -* [packet hardware_reservation move](packet_hardware_reservation_move.md) - Move hardware reservation to another project +* [packet hardware-reservation get](packet_hardware-reservation_get.md) - Retrieves all hardware reservations of a project or a single hardware reservation +* [packet hardware-reservation move](packet_hardware-reservation_move.md) - Move hardware reservation to another project -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_hardware_reservation_get.md b/docs/packet_hardware-reservation_get.md similarity index 65% rename from docs/packet_hardware_reservation_get.md rename to docs/packet_hardware-reservation_get.md index e1a86eca..6917b513 100644 --- a/docs/packet_hardware_reservation_get.md +++ b/docs/packet_hardware-reservation_get.md @@ -1,4 +1,4 @@ -## packet hardware_reservation get +## packet hardware-reservation get Retrieves all hardware reservations of a project or a single hardware reservation @@ -11,7 +11,7 @@ packet hardware_reservations get -p [project_id] ``` -packet hardware_reservation get [flags] +packet hardware-reservation get [flags] ``` ### Options @@ -27,11 +27,11 @@ packet hardware_reservation get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO -* [packet hardware_reservation](packet_hardware_reservation.md) - Hardware reservation operations +* [packet hardware-reservation](packet_hardware-reservation.md) - Hardware reservation operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_hardware_reservation_move.md b/docs/packet_hardware-reservation_move.md similarity index 59% rename from docs/packet_hardware_reservation_move.md rename to docs/packet_hardware-reservation_move.md index 4aead443..d65aa41a 100644 --- a/docs/packet_hardware_reservation_move.md +++ b/docs/packet_hardware-reservation_move.md @@ -1,4 +1,4 @@ -## packet hardware_reservation move +## packet hardware-reservation move Move hardware reservation to another project @@ -10,7 +10,7 @@ packet hardware_reservation move -i [hardware_reservation_UUID] -p [project_UUID ``` -packet hardware_reservation move [flags] +packet hardware-reservation move [flags] ``` ### Options @@ -24,11 +24,11 @@ packet hardware_reservation move [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO -* [packet hardware_reservation](packet_hardware_reservation.md) - Hardware reservation operations +* [packet hardware-reservation](packet_hardware-reservation.md) - Hardware reservation operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip.md b/docs/packet_ip.md index a5bccabc..b1242d1a 100644 --- a/docs/packet_ip.md +++ b/docs/packet_ip.md @@ -15,7 +15,7 @@ IP address, reservations and assignment operations: assign, unassign, remove, av ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -28,4 +28,4 @@ IP address, reservations and assignment operations: assign, unassign, remove, av * [packet ip request](packet_ip_request.md) - Request an IP block * [packet ip unassign](packet_ip_unassign.md) - Unassigns an IP address. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip_assign.md b/docs/packet_ip_assign.md index 9b2b95a9..777a699e 100644 --- a/docs/packet_ip_assign.md +++ b/docs/packet_ip_assign.md @@ -25,11 +25,11 @@ packet ip assign [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ip](packet_ip.md) - IP operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip_available.md b/docs/packet_ip_available.md index 13d41832..b0d50d1e 100644 --- a/docs/packet_ip_available.md +++ b/docs/packet_ip_available.md @@ -25,11 +25,11 @@ packet ip available [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ip](packet_ip.md) - IP operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip_get.md b/docs/packet_ip_get.md index 154b326a..7da6b1c6 100644 --- a/docs/packet_ip_get.md +++ b/docs/packet_ip_get.md @@ -38,11 +38,11 @@ packet ip get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ip](packet_ip.md) - IP operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip_remove.md b/docs/packet_ip_remove.md index 30fc3c47..ccaaa50e 100644 --- a/docs/packet_ip_remove.md +++ b/docs/packet_ip_remove.md @@ -24,11 +24,11 @@ packet ip remove [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ip](packet_ip.md) - IP operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip_request.md b/docs/packet_ip_request.md index cf24a455..d3b8b066 100644 --- a/docs/packet_ip_request.md +++ b/docs/packet_ip_request.md @@ -28,11 +28,11 @@ packet ip request [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ip](packet_ip.md) - IP operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ip_unassign.md b/docs/packet_ip_unassign.md index a842dcfc..13187214 100644 --- a/docs/packet_ip_unassign.md +++ b/docs/packet_ip_unassign.md @@ -24,11 +24,11 @@ packet ip unassign [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ip](packet_ip.md) - IP operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_operating-systems.md b/docs/packet_operating-systems.md index 6320b1a8..84314c20 100644 --- a/docs/packet_operating-systems.md +++ b/docs/packet_operating-systems.md @@ -15,7 +15,7 @@ Operating system operations: get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -23,4 +23,4 @@ Operating system operations: get * [packet](packet.md) - Command line interface for Packet Host * [packet operating-systems get](packet_operating-systems_get.md) - Retrieves a list of available operating systems. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_operating-systems_get.md b/docs/packet_operating-systems_get.md index 9f9ed8fb..e79b86b4 100644 --- a/docs/packet_operating-systems_get.md +++ b/docs/packet_operating-systems_get.md @@ -22,11 +22,11 @@ packet operating-systems get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet operating-systems](packet_operating-systems.md) - Operating system operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_organization.md b/docs/packet_organization.md index 3c3a88d1..9b381c5f 100644 --- a/docs/packet_organization.md +++ b/docs/packet_organization.md @@ -15,7 +15,7 @@ Organization operations: create, update, delete and get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -26,4 +26,4 @@ Organization operations: create, update, delete and get * [packet organization get](packet_organization_get.md) - Retrieves an organization or list of organizations * [packet organization update](packet_organization_update.md) - Updates an organization -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_organization_create.md b/docs/packet_organization_create.md index be3ce4fd..4139b138 100644 --- a/docs/packet_organization_create.md +++ b/docs/packet_organization_create.md @@ -19,20 +19,22 @@ packet organization create [flags] ``` -d, --description string Description of the organization -h, --help Help for create + -j, --json JSON output -l, --logo string Logo URL] -n, --name string Name of the organization -t, --twitter string Twitter URL of the organization -w, --website string Website URL of the organization + -y, --yaml YAML output ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet organization](packet_organization.md) - Organization operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_organization_delete.md b/docs/packet_organization_delete.md index 0a7dfaf4..323125e3 100644 --- a/docs/packet_organization_delete.md +++ b/docs/packet_organization_delete.md @@ -25,11 +25,11 @@ packet organization delete [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet organization](packet_organization.md) - Organization operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_organization_get.md b/docs/packet_organization_get.md index f325b46f..aff4011c 100644 --- a/docs/packet_organization_get.md +++ b/docs/packet_organization_get.md @@ -30,7 +30,7 @@ packet organization get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -38,4 +38,4 @@ packet organization get [flags] * [packet organization](packet_organization.md) - Organization operations * [packet organization get payment-methods](packet_organization_get_payment-methods.md) - Retrieves a list of payment methods for the organization -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_organization_get_payment-methods.md b/docs/packet_organization_get_payment-methods.md index 49fdaaed..0f8bd865 100644 --- a/docs/packet_organization_get_payment-methods.md +++ b/docs/packet_organization_get_payment-methods.md @@ -24,7 +24,7 @@ packet organization get payment-methods [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file -j, --json JSON output -y, --yaml YAML output ``` @@ -33,4 +33,4 @@ packet organization get payment-methods [flags] * [packet organization get](packet_organization_get.md) - Retrieves an organization or list of organizations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_organization_update.md b/docs/packet_organization_update.md index 2384e8b0..37437512 100644 --- a/docs/packet_organization_update.md +++ b/docs/packet_organization_update.md @@ -29,11 +29,11 @@ packet organization update [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet organization](packet_organization.md) - Organization operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_plan.md b/docs/packet_plan.md index 08915fad..810cab30 100644 --- a/docs/packet_plan.md +++ b/docs/packet_plan.md @@ -15,7 +15,7 @@ Plan operations: get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -23,4 +23,4 @@ Plan operations: get * [packet](packet.md) - Command line interface for Packet Host * [packet plan get](packet_plan_get.md) - Retrieves a list of all available plans. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_plan_get.md b/docs/packet_plan_get.md index 17dc5c3d..145c8c3a 100644 --- a/docs/packet_plan_get.md +++ b/docs/packet_plan_get.md @@ -25,11 +25,11 @@ packet plan get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet plan](packet_plan.md) - Plan operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_project.md b/docs/packet_project.md index 70f1be0f..8dbe3365 100644 --- a/docs/packet_project.md +++ b/docs/packet_project.md @@ -15,7 +15,7 @@ Project operations: create, delete, update and get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -26,4 +26,4 @@ Project operations: create, delete, update and get * [packet project get](packet_project_get.md) - Retrieves all available projects or a single project * [packet project update](packet_project_update.md) - Updates a project -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_project_create.md b/docs/packet_project_create.md index bfc506ea..b16fc358 100644 --- a/docs/packet_project_create.md +++ b/docs/packet_project_create.md @@ -18,19 +18,21 @@ packet project create [flags] ``` -h, --help Help for create + -j, --json JSON output -n, --name string Name of the project -o, --organization-id string UUID of the organization -m, --payment-method-id string UUID of the payment method + -y, --yaml YAML output ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet project](packet_project.md) - Project operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_project_delete.md b/docs/packet_project_delete.md index f221047d..d5afcad2 100644 --- a/docs/packet_project_delete.md +++ b/docs/packet_project_delete.md @@ -25,11 +25,11 @@ packet project delete [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet project](packet_project.md) - Project operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_project_get.md b/docs/packet_project_get.md index 9e60dce6..ba9ad354 100644 --- a/docs/packet_project_get.md +++ b/docs/packet_project_get.md @@ -11,7 +11,7 @@ packet project get Retrieve a specific project: packet project get -i [project_UUID] - +packet project get -n [project_name] ``` @@ -23,6 +23,7 @@ packet project get [flags] ``` -h, --help Help for get -j, --json JSON output + -n, --project string Name of the project -i, --project-id string UUID of the project -y, --yaml YAML output ``` @@ -30,11 +31,11 @@ packet project get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet project](packet_project.md) - Project operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_project_update.md b/docs/packet_project_update.md index 5b12636f..b1dd0c89 100644 --- a/docs/packet_project_update.md +++ b/docs/packet_project_update.md @@ -26,11 +26,11 @@ packet project update [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet project](packet_project.md) - Project operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ssh-key.md b/docs/packet_ssh-key.md index ee40a5cb..5f01f3e1 100644 --- a/docs/packet_ssh-key.md +++ b/docs/packet_ssh-key.md @@ -15,7 +15,7 @@ SSH key operations: create, delete, update and get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -26,4 +26,4 @@ SSH key operations: create, delete, update and get * [packet ssh-key get](packet_ssh-key_get.md) - Retrieves a list of available SSH keys or a single SSH key * [packet ssh-key update](packet_ssh-key_update.md) - Updates a project -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ssh-key_create.md b/docs/packet_ssh-key_create.md index acf152da..4cb8ae64 100644 --- a/docs/packet_ssh-key_create.md +++ b/docs/packet_ssh-key_create.md @@ -18,18 +18,20 @@ packet ssh-key create [flags] ``` -h, --help Help for create + -j, --json JSON output -k, --key string Public SSH key string -l, --label string Name of the SSH key + -y, --yaml YAML output ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ssh-key](packet_ssh-key.md) - SSH key operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ssh-key_delete.md b/docs/packet_ssh-key_delete.md index 06a61d2c..a9f23e17 100644 --- a/docs/packet_ssh-key_delete.md +++ b/docs/packet_ssh-key_delete.md @@ -25,11 +25,11 @@ packet ssh-key delete [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ssh-key](packet_ssh-key.md) - SSH key operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ssh-key_get.md b/docs/packet_ssh-key_get.md index 36e5d56d..ff27648e 100644 --- a/docs/packet_ssh-key_get.md +++ b/docs/packet_ssh-key_get.md @@ -30,11 +30,11 @@ packet ssh-key get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ssh-key](packet_ssh-key.md) - SSH key operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_ssh-key_update.md b/docs/packet_ssh-key_update.md index e69e44dd..44f5992f 100644 --- a/docs/packet_ssh-key_update.md +++ b/docs/packet_ssh-key_update.md @@ -26,11 +26,11 @@ packet ssh-key update [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet ssh-key](packet_ssh-key.md) - SSH key operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_user.md b/docs/packet_user.md index 2585bd70..6be06b29 100644 --- a/docs/packet_user.md +++ b/docs/packet_user.md @@ -15,7 +15,7 @@ User operations: get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -23,4 +23,4 @@ User operations: get * [packet](packet.md) - Command line interface for Packet Host * [packet user get](packet_user_get.md) - Retrieves information about the current user or a specified user -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_user_get.md b/docs/packet_user_get.md index 271b01e8..b5102939 100644 --- a/docs/packet_user_get.md +++ b/docs/packet_user_get.md @@ -30,11 +30,11 @@ packet user get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet user](packet_user.md) - User operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_virtual-network.md b/docs/packet_virtual-network.md index bc1294b8..9d7ea29b 100644 --- a/docs/packet_virtual-network.md +++ b/docs/packet_virtual-network.md @@ -15,7 +15,7 @@ Virtual network operations: create, delete and get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -25,4 +25,4 @@ Virtual network operations: create, delete and get * [packet virtual-network delete](packet_virtual-network_delete.md) - Deletes a Virtual Network * [packet virtual-network get](packet_virtual-network_get.md) - Retrieves a list of virtual networks for a single project. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_virtual-network_create.md b/docs/packet_virtual-network_create.md index 749c266f..4221fb72 100644 --- a/docs/packet_virtual-network_create.md +++ b/docs/packet_virtual-network_create.md @@ -20,19 +20,21 @@ packet virtual-network create [flags] -d, --description string Description of the virtual network -f, --facility string Code of the facility -h, --help Help for create + -j, --json JSON output -p, --project-id string UUID of the project -l, --vlan int Virtual LAN ID -x, --vxlan int VXLAN ID + -y, --yaml YAML output ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet virtual-network](packet_virtual-network.md) - Virtual network operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_virtual-network_delete.md b/docs/packet_virtual-network_delete.md index ce631d97..ef19f0d6 100644 --- a/docs/packet_virtual-network_delete.md +++ b/docs/packet_virtual-network_delete.md @@ -25,11 +25,11 @@ packet virtual-network delete [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet virtual-network](packet_virtual-network.md) - Virtual network operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_virtual-network_get.md b/docs/packet_virtual-network_get.md index e979f753..65be219f 100644 --- a/docs/packet_virtual-network_get.md +++ b/docs/packet_virtual-network_get.md @@ -26,11 +26,11 @@ packet virtual-network get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet virtual-network](packet_virtual-network.md) - Virtual network operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_volume.md b/docs/packet_volume.md index 4f25e5bc..3b4dde9d 100644 --- a/docs/packet_volume.md +++ b/docs/packet_volume.md @@ -15,7 +15,7 @@ Volume operations: create, delete, attach, detach and get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -27,4 +27,4 @@ Volume operations: create, delete, attach, detach and get * [packet volume detach](packet_volume_detach.md) - Detaches a volume from a device * [packet volume get](packet_volume_get.md) - Retrieves a volume list or volume details. -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_volume_attach.md b/docs/packet_volume_attach.md index 1b829d50..83996bbe 100644 --- a/docs/packet_volume_attach.md +++ b/docs/packet_volume_attach.md @@ -25,11 +25,11 @@ packet volume attach [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet volume](packet_volume.md) - Volume operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_volume_create.md b/docs/packet_volume_create.md index b96e0d29..ddf4fe35 100644 --- a/docs/packet_volume_create.md +++ b/docs/packet_volume_create.md @@ -21,20 +21,22 @@ packet volume create [flags] -d, --description string Description of the volume -f, --facility string Code of the facility where the volume will be created -h, --help Help for create + -j, --json JSON output -l, --locked Set the volume to be locked -P, --plan string Name of the plan -p, --project-id string UUID of the project -s, --size int Size in GB] + -y, --yaml YAML output ``` ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet volume](packet_volume.md) - Volume operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_volume_delete.md b/docs/packet_volume_delete.md index 5589c4bb..45b79c21 100644 --- a/docs/packet_volume_delete.md +++ b/docs/packet_volume_delete.md @@ -25,11 +25,11 @@ packet volume delete [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet volume](packet_volume.md) - Volume operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_volume_detach.md b/docs/packet_volume_detach.md index d659b81c..7f79730b 100644 --- a/docs/packet_volume_detach.md +++ b/docs/packet_volume_detach.md @@ -24,11 +24,11 @@ packet volume detach [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet volume](packet_volume.md) - Volume operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_volume_get.md b/docs/packet_volume_get.md index 5565c076..b38acd8d 100644 --- a/docs/packet_volume_get.md +++ b/docs/packet_volume_get.md @@ -10,7 +10,7 @@ Retrieve the list of volumes: packet volume get --project-id [project_UUID] Retrieve a specific volume: -packet get volume --id [volume_UUID] +packet volume get --id [volume_UUID] @@ -31,11 +31,11 @@ packet volume get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet volume](packet_volume.md) - Volume operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_vpn.md b/docs/packet_vpn.md index 9a59c0e7..018a70f3 100644 --- a/docs/packet_vpn.md +++ b/docs/packet_vpn.md @@ -15,7 +15,7 @@ VPN service operations: enable, disable, get ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO @@ -25,4 +25,4 @@ VPN service operations: enable, disable, get * [packet vpn enable](packet_vpn_enable.md) - Enables VPN service * [packet vpn get](packet_vpn_get.md) - Retrieves VPN service -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_vpn_disable.md b/docs/packet_vpn_disable.md index 6f32db50..a21e6f23 100644 --- a/docs/packet_vpn_disable.md +++ b/docs/packet_vpn_disable.md @@ -23,11 +23,11 @@ packet vpn disable [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet vpn](packet_vpn.md) - VPN service operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_vpn_enable.md b/docs/packet_vpn_enable.md index 29d5c5bd..5d92ade5 100644 --- a/docs/packet_vpn_enable.md +++ b/docs/packet_vpn_enable.md @@ -23,11 +23,11 @@ packet vpn enable [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet vpn](packet_vpn.md) - VPN service operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/docs/packet_vpn_get.md b/docs/packet_vpn_get.md index 4503b114..89fc4d26 100644 --- a/docs/packet_vpn_get.md +++ b/docs/packet_vpn_get.md @@ -26,11 +26,11 @@ packet vpn get [flags] ### Options inherited from parent commands ``` - --config string Path to JSON or YAML configuration file (default "/Users/jasmingacic/.packet-cli.json") + --config string Path to JSON or YAML configuration file ``` ### SEE ALSO * [packet vpn](packet_vpn.md) - VPN service operations -###### Auto generated by spf13/cobra on 8-Oct-2018 +###### Auto generated by spf13/cobra on 12-Aug-2019 diff --git a/tests/facilities_test.go b/tests/facilities_test.go new file mode 100644 index 00000000..7ed04577 --- /dev/null +++ b/tests/facilities_test.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "os" + "os/exec" + "path" + "strings" + "testing" +) + +func TestFacilitiesOperations(t *testing.T) { + tests := []Test{ + {"facilities get", []string{"facilities", "get"}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + + }) + } +} diff --git a/tests/main_test.go b/tests/main_test.go new file mode 100644 index 00000000..a9f8bec9 --- /dev/null +++ b/tests/main_test.go @@ -0,0 +1,140 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "os/exec" + "path" + "strings" + "testing" + "time" + + "github.com/packethost/packngo" +) + +const binaryName = "packet" + +func TestMain(m *testing.M) { + err := os.Chdir("..") + if err != nil { + fmt.Printf("could not change dir: %v", err) + os.Exit(1) + } + fmt.Println("build") + build := exec.Command("go", "build", "-o", binaryName) + err = build.Run() + if err != nil { + fmt.Printf("could not build binary for %s: %v", binaryName, err) + os.Exit(1) + } + + os.Exit(m.Run()) +} + +var projectID string +var deviceID string +var client *packngo.Client + +type Test struct { + name string + args []string +} + +func TestCliArgs(t *testing.T) { + client, _ = packngo.NewClientWithBaseURL("Packet CLI", os.Getenv("PACKET_TOKEN"), nil, "https://api.packet.net/") + projects, _, _ := client.Projects.List(nil) + projectID = projects[0].ID + tests := []Test{ + {"no arguments", []string{}}, + {"operating-systems get", []string{"operating-systems", "get", "-j"}}, + {"plan get", []string{"plan", "get", "-j"}}, + {"organization get", []string{"organization", "get", "-j"}}, + {"project get", []string{"project", "get", "-j"}}, + { + "create device", + []string{ + "device", "create", + "--hostname", "clitest", + "--plan", "baremetal_1", + "--facility", "ewr1", + "--operating-system", "centos_7", + "--project-id", projectID, + "-j", + }, + }, + {"devices get", []string{"device", "get", "project-id", projectID, "-j"}}, + {"device update", []string{"device", "update", "hostname", "updatedfromcli", "-i"}}, + {"device reboot", []string{"device", "reboot", "-i"}}, + {"device stop", []string{"device", "stop", "-i"}}, + {"device start", []string{"device", "start", "-i"}}, + {"device delete", []string{"device", "delete", "-i"}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + if tt.name == "device delete" && deviceID != "" { + tt.args = append(tt.args, deviceID, "-f") + } + + if (tt.name == "device update" || + tt.name == "device reboot" || + tt.name == "device stop" || + tt.name == "device start") && deviceID != "" { + tt.args = append(tt.args, deviceID) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + if len(tt.args) > 0 { + if tt.args[0] == "project" { + project := &[]packngo.Project{} + err := json.Unmarshal([]byte(actual), project) + if err != nil { + t.Fatal(err) + } + projectID = (*project)[0].ID + } else if tt.args[0] == "device" && tt.args[1] == "create" { + device := &packngo.Device{} + // fmt.Println(actual) + err := json.Unmarshal([]byte(actual), device) + if err != nil { + t.Fatal(err) + } + + deviceID = (*device).ID + for { + dev, _, err := client.Devices.Get(deviceID) + if err != nil { + break + } + if dev.State == "active" { + break + } + time.Sleep(2 * time.Second) + } + } + } + }) + } +} + +type organizationsRoot struct { + Organizations []packngo.Organization `json:"organizations"` +} diff --git a/tests/organization_test.go b/tests/organization_test.go new file mode 100644 index 00000000..65a27337 --- /dev/null +++ b/tests/organization_test.go @@ -0,0 +1,127 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "os/exec" + "path" + "strings" + "testing" + + "github.com/packethost/packngo" +) + +var organizationID string + +func TestOrganizationOperations(t *testing.T) { + client, _ = packngo.NewClientWithBaseURL("Packet CLI", os.Getenv("PACKET_TOKEN"), nil, "https://api.packet.net/") + setupTests := []Test{ + { + "create organization", + []string{ + "organization", "create", + "--name", "clitestOrg", + "-j", + }, + }, + } + tests := []Test{ + + {"organization list", []string{"organization", "get"}}, + {"organization get", []string{"organization", "get", "-i"}}, + {"organization update", []string{"organization", "update", "-n", "updatednamefromCLI", "-i"}}, + } + cleanUp := []Test{ + + {"organization delete", []string{"organization", "delete", "-i"}}, + } + + for _, tt := range setupTests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + + if tt.args[0] == "organization" && tt.args[1] == "create" { + organization := &packngo.Organization{} + err := json.Unmarshal([]byte(actual), organization) + if err != nil { + t.Fatal(err) + } + + organizationID = (*organization).ID + } + }) + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + if (tt.name == "organization get" || + tt.name == "organization update") && organizationID != "" { + tt.args = append(tt.args, organizationID) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } + + for _, tt := range cleanUp { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + if tt.name == "organization delete" && organizationID != "" { + tt.args = append(tt.args, organizationID) + tt.args = append(tt.args, "-f") + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } +} diff --git a/tests/plan_test.go b/tests/plan_test.go new file mode 100644 index 00000000..cb4a8c53 --- /dev/null +++ b/tests/plan_test.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "os" + "os/exec" + "path" + "strings" + "testing" +) + +func TestPlanOperations(t *testing.T) { + tests := []Test{ + {"plan get", []string{"plan", "get"}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + + }) + } +} diff --git a/tests/project_test.go b/tests/project_test.go new file mode 100644 index 00000000..1044b3ef --- /dev/null +++ b/tests/project_test.go @@ -0,0 +1,101 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "os/exec" + "path" + "strings" + "testing" + + "github.com/packethost/packngo" +) + +func TestProjectOperations(t *testing.T) { + client, _ = packngo.NewClientWithBaseURL("Packet CLI", os.Getenv("PACKET_TOKEN"), nil, "https://api.packet.net/") + orgs, _, _ := client.Organizations.List() + orgID := orgs[0].ID + + tests := []Test{ + {"project create", []string{"project", "create", "-n", "test", "-o", orgID, "-j"}}, + {"project get", []string{"project", "get"}}, + } + + sshKeys, _, _ := client.SSHKeys.List() + for _, key := range sshKeys { + if key.Label == "test" { + sshKeyID = key.ID + fmt.Println("sshkeyID", sshKeyID) + + break + } + } + + cleanup := []Test{ + {"project get", []string{"project", "get", "-i"}}, + {"project delete", []string{"project", "delete", "-i"}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + + if tt.name == "project create" { + project := &packngo.Project{} + err := json.Unmarshal([]byte(actual), project) + if err != nil { + t.Fatal(err) + } + + projectID = (*project).ID + } + }) + } + + for _, tt := range cleanup { + t.Run(tt.name, func(t *testing.T) { + if tt.name == "project get" && projectID != "" { + tt.args = append(tt.args, projectID) + } + + if tt.name == "project delete" && projectID != "" { + tt.args = append(tt.args, projectID) + tt.args = append(tt.args, "-f") + } + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } +} diff --git a/tests/ssh_key_test.go b/tests/ssh_key_test.go new file mode 100644 index 00000000..403afa48 --- /dev/null +++ b/tests/ssh_key_test.go @@ -0,0 +1,98 @@ +package main + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "path" + "strings" + "testing" + + "github.com/packethost/packngo" +) + +var sshKeyID string + +func TestSSHKeyOperations(t *testing.T) { + client, _ = packngo.NewClientWithBaseURL("Packet CLI", os.Getenv("PACKET_TOKEN"), nil, "https://api.packet.net/") + + data, err := ioutil.ReadFile(os.Getenv("HOME") + "/.ssh/id_rsa.pub") + if err != nil { + fmt.Println("File reading error", err) + return + } + key := string(data) + + tests := []Test{ + {"ssh-key create", []string{"ssh-key", "create", "-l", "test", "-k", key}}, + {"ssh-key list", []string{"ssh-key", "get", "-j"}}, + } + + sshKeys, _, _ := client.SSHKeys.List() + for _, key := range sshKeys { + if key.Label == "test" { + sshKeyID = key.ID + fmt.Println("sshkeyID", sshKeyID) + + break + } + } + + cleanup := []Test{ + {"ssh-key get", []string{"ssh-key", "get", "-i"}}, + {"ssh-key delete", []string{"ssh-key", "delete", "-i"}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } + + for _, tt := range cleanup { + t.Run(tt.name, func(t *testing.T) { + if tt.name == "ssh-key get" && sshKeyID != "" { + tt.args = append(tt.args, sshKeyID) + } + + if tt.name == "ssh-key delete" && sshKeyID != "" { + tt.args = append(tt.args, sshKeyID) + tt.args = append(tt.args, "-f") + } + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } +} diff --git a/tests/virtual_network_test.go b/tests/virtual_network_test.go new file mode 100644 index 00000000..3550a554 --- /dev/null +++ b/tests/virtual_network_test.go @@ -0,0 +1,121 @@ +package main + +import ( + "encoding/json" + "fmt" + "github.com/packethost/packngo" + "os" + "os/exec" + "path" + "strings" + "testing" +) + +var virtualNetworkID string + +func TestVirtualNetworkOperations(t *testing.T) { + client, _ = packngo.NewClientWithBaseURL("Packet CLI", os.Getenv("PACKET_TOKEN"), nil, "https://api.packet.net/") + projects, _, _ := client.Projects.List(nil) + projectID = projects[0].ID + setupTests := []Test{ + { + "create virtual-network", + []string{ + "virtual-network", "create", + "--facility", "ewr1", + "--project-id", projectID, + "-j", + }, + }, + } + tests := []Test{ + + {"virtual-network list", []string{"virtual-network", "get", "-p", projectID}}, + } + cleanUp := []Test{ + + {"virtual-network delete", []string{"virtual-network", "delete", "-i"}}, + } + + for _, tt := range setupTests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + + if tt.args[0] == "virtual-network" && tt.args[1] == "create" { + virtualNetwork := &packngo.VirtualNetwork{} + err := json.Unmarshal([]byte(actual), virtualNetwork) + if err != nil { + t.Fatal(err) + } + + virtualNetworkID = (*virtualNetwork).ID + } + }) + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } + + for _, tt := range cleanUp { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + if tt.name == "virtual-network delete" && virtualNetworkID != "" { + tt.args = append(tt.args, virtualNetworkID) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } +} diff --git a/tests/volumes_test.go b/tests/volumes_test.go new file mode 100644 index 00000000..44ebdfdb --- /dev/null +++ b/tests/volumes_test.go @@ -0,0 +1,203 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "os/exec" + "path" + "strings" + "testing" + "time" + + "github.com/packethost/packngo" +) + +var volumeID string + +func TestVolumeOperations(t *testing.T) { + client, _ = packngo.NewClientWithBaseURL("Packet CLI", os.Getenv("PACKET_TOKEN"), nil, "https://api.packet.net/") + projects, _, _ := client.Projects.List(nil) + projectID = projects[0].ID + setupTests := []Test{ + { + "create volume", + []string{ + "volume", "create", + "--size", "25", + "--plan", "storage_1", + "--facility", "ewr1", + "--project-id", projectID, + "-j", + }, + }, + { + "create device", + []string{ + "device", "create", + "--hostname", "clivolumestest", + "--plan", "baremetal_1", + "--facility", "ewr1", + "--operating-system", "centos_7", + "--project-id", projectID, + "-j", + }, + }, + } + tests := []Test{ + + {"volumes list", []string{"volume", "get", "project-id", projectID, "-j"}}, + {"volume get", []string{"volume", "get", "-i"}}, + {"volume attach", []string{"volume", "attach", "-i"}}, + {"volume detach", []string{"volume", "detach", "-i"}}, + } + cleanUp := []Test{ + + {"volume delete", []string{"volume", "delete", "-i"}}, + {"device delete", []string{"device", "delete", "-i"}}, + } + + for _, tt := range setupTests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + if len(tt.args) > 0 { + if tt.args[0] == "device" && tt.args[1] == "create" { + device := &packngo.Device{} + // fmt.Println(actual) + err := json.Unmarshal([]byte(actual), device) + if err != nil { + t.Fatal(err) + } + + deviceID = (*device).ID + for { + dev, _, err := client.Devices.Get(deviceID) + if err != nil { + break + } + if dev.State == "active" { + break + } + time.Sleep(2 * time.Second) + } + } + if tt.args[0] == "volume" && tt.args[1] == "create" { + volume := &packngo.Volume{} + // fmt.Println(actual) + err := json.Unmarshal([]byte(actual), volume) + if err != nil { + t.Fatal(err) + } + + volumeID = (*volume).ID + for { + vol, _, err := client.Volumes.Get(volumeID) + if err != nil { + break + } + if vol.State == "active" { + break + } + time.Sleep(2 * time.Second) + } + } + } + }) + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + if tt.name == "volume get" && volumeID != "" { + tt.args = append(tt.args, volumeID, "-j") + } + + if tt.name == "volume attach" && volumeID != "" { + tt.args = append(tt.args, volumeID, "--device-id", deviceID) + } + + if tt.name == "volume detach" && volumeID != "" { + tt.args = append(tt.args, volumeID) + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + if len(tt.args) > 0 { + if tt.args[0] == "volume" && (tt.args[1] == "attach" || tt.args[1] == "detach") { + for { + vol, _, err := client.Volumes.Get(volumeID) + if err != nil { + break + } + if vol.State == "active" { + break + } + time.Sleep(2 * time.Second) + } + } + } + }) + } + + for _, tt := range cleanUp { + t.Run(tt.name, func(t *testing.T) { + fmt.Println(tt.name, tt.args) + + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + if tt.name == "volume delete" && volumeID != "" { + tt.args = append(tt.args, volumeID, "-f") + } + + if tt.name == "device delete" && deviceID != "" { + tt.args = append(tt.args, deviceID, "-f") + } + + cmd := exec.Command(path.Join(dir, binaryName), tt.args...) + + output, err := cmd.CombinedOutput() + if err != nil { + t.Fatal(err) + } + + actual := string(output) + if strings.Contains(actual, "Error:") { + t.Fatal(actual) + } + }) + } +}