Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #36

Merged
merged 5 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ clean-docs:
rm -rf docs/

install:
go install ${LDFLAGS}
go install ${LDFLAGS}
mv ${GOPATH}/bin/packet-cli ${GOPATH}/bin/packet

generate-docs: clean-docs
mkdir -p docs
Expand Down
4 changes: 2 additions & 2 deletions cmd/create_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ packet device create --hostname [hostname] --plan [plan] --facility [facility_co
request := &packngo.DeviceCreateRequest{
Hostname: hostname,
Plan: plan,
Facility: facility,
Facility: []string{facility},
OS: operatingSystem,
BillingCycle: billingCycle,
ProjectID: projectID,
Expand Down Expand Up @@ -102,7 +102,7 @@ packet device create --hostname [hostname] --plan [plan] --facility [facility_co
}

if terminationTime != "" {
parsedTime, err := time.Parse(`"`+time.RFC3339+`"`, terminationTime)
parsedTime, err := time.Parse(time.RFC3339, terminationTime)
if err != nil {
fmt.Printf("Error occured while parsing time string: %s", err.Error())
return
Expand Down
13 changes: 2 additions & 11 deletions cmd/create_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ packet virtual-network create --project-id [project_UUID] --facility [facility_c
ProjectID: projectID,
Facility: facility,
}

if vxlan != 0 {
req.VXLAN = vxlan
}

if vlan != 0 {
req.VLAN = vlan
}

if description != "" {
req.Description = description
}
Expand All @@ -78,8 +69,8 @@ packet virtual-network create --project-id [project_UUID] --facility [facility_c
func init() {
createVirtualNetworkCmd.Flags().StringVarP(&projectID, "project-id", "p", "", "UUID of the project")
createVirtualNetworkCmd.Flags().StringVarP(&facility, "facility", "f", "", "Code of the facility")
createVirtualNetworkCmd.Flags().IntVarP(&vlan, "vlan", "l", 0, "Virtual LAN ID")
createVirtualNetworkCmd.Flags().IntVarP(&vxlan, "vxlan", "x", 0, "VXLAN ID")
// createVirtualNetworkCmd.Flags().IntVarP(&vlan, "vlan", "l", 0, "Virtual LAN ID")
// createVirtualNetworkCmd.Flags().IntVarP(&vxlan, "vxlan", "x", 0, "VXLAN ID")
createVirtualNetworkCmd.Flags().StringVarP(&description, "description", "d", "", "Description of the virtual network")

createVirtualNetworkCmd.MarkFlagRequired("project-id")
Expand Down
7 changes: 4 additions & 3 deletions cmd/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (

// deviceCmd represents the device command
var deviceCmd = &cobra.Command{
Use: "device",
Short: "Device operations",
Long: `Device operations: create, delete, update, start/stop, reboot and get.`,
Use: "device",
Aliases: []string{"server"},
Short: "Device operations",
Long: `Device operations: create, delete, update, start/stop, reboot and get.`,
}

func init() {
Expand Down
5 changes: 1 addition & 4 deletions cmd/request_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ packet ip request --quantity [quantity] --facility [facility_code] --type [addre
req := &packngo.IPReservationRequest{
Type: ttype,
Quantity: quantity,
Facility: facility,
Facility: &facility,
}

if comments != "" {
req.Comments = comments
}
reservation, _, err := PacknGo.ProjectIPs.Request(projectID, req)
if err != nil {
fmt.Println("Client error:", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ packet device get --id [device_UUID]
output(devices, header, &data)
} else if deviceID != "" {

device, _, err := PacknGo.Devices.Get(deviceID)
device, _, err := PacknGo.Devices.Get(deviceID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
5 changes: 3 additions & 2 deletions cmd/retrieve_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ packet event get
events := []packngo.Event{}
var err error
header := []string{"ID", "Body", "Type", "Created"}
listOpt := &packngo.ListOptions{Includes: "relationships"}
listOpt := &packngo.ListOptions{Includes: []string{"relationships"}}

if deviceID != "" && projectID != "" && organizationID != "" && eventID != "" {
fmt.Println("The id, project-id, device-id, and organization-id parameters are mutually exclusive")
Expand All @@ -80,7 +80,8 @@ packet event get
return
}
} else if eventID != "" {
event, _, err := PacknGo.Events.Get(eventID, listOpt)
getOpt := &packngo.GetOptions{Includes: listOpt.Includes}
event, _, err := PacknGo.Events.Get(eventID, getOpt)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_facilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ packet facilities get

`,
Run: func(cmd *cobra.Command, args []string) {
facilities, _, err := PacknGo.Facilities.List()
facilities, _, err := PacknGo.Facilities.List(nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
5 changes: 3 additions & 2 deletions cmd/retrieve_hardware_reservations.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ packet hardware_reservations get -p [project_id]
`,
Run: func(cmd *cobra.Command, args []string) {
header := []string{"ID", "Facility", "Plan", "Created"}
listOpt := &packngo.ListOptions{Includes: "project,facility,device"}
listOpt := &packngo.ListOptions{Includes: []string{"project,facility,device"}}

if hardwareReservationID == "" && projectID == "" {
fmt.Println("Either id or project-id should be set.")
Expand All @@ -61,7 +61,8 @@ packet hardware_reservations get -p [project_id]

output(reservations, header, &data)
} else if hardwareReservationID != "" {
r, _, err := PacknGo.HardwareReservations.Get(hardwareReservationID, listOpt)
getOpt := &packngo.GetOptions{Includes: listOpt.Includes}
r, _, err := PacknGo.HardwareReservations.Get(hardwareReservationID, getOpt)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/retrieve_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ packet ip get --reservation-id [reservation_UUID]

output(ips, header, &data)
} else if projectID == "" && reservationID == "" && assignmentID != "" {
ip, _, err := PacknGo.DeviceIPs.Get(assignmentID)
ip, _, err := PacknGo.DeviceIPs.Get(assignmentID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand All @@ -81,7 +81,7 @@ packet ip get --reservation-id [reservation_UUID]

output(ip, header, &data)
} else if projectID == "" && assignmentID == "" && reservationID != "" {
ip, _, err := PacknGo.ProjectIPs.Get(reservationID)
ip, _, err := PacknGo.ProjectIPs.Get(reservationID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/retrieve_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ packet organization get -i [organization-id]
`,
Run: func(cmd *cobra.Command, args []string) {
if organizationID == "" {
orgs, _, err := PacknGo.Organizations.List()
orgs, _, err := PacknGo.Organizations.List(nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand All @@ -56,7 +56,7 @@ packet organization get -i [organization-id]

output(orgs, header, &data)
} else {
org, _, err := PacknGo.Organizations.Get(organizationID)
org, _, err := PacknGo.Organizations.Get(organizationID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
3 changes: 2 additions & 1 deletion cmd/retrieve_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var retrievePlansCmd = &cobra.Command{

`,
Run: func(cmd *cobra.Command, args []string) {
plans, _, err := PacknGo.Plans.List()
plans, _, err := PacknGo.Plans.List(nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand All @@ -45,6 +45,7 @@ var retrievePlansCmd = &cobra.Command{
data := make([][]string, len(plans))

for i, p := range plans {
fmt.Println(p.Pricing)
data[i] = []string{p.ID, p.Slug, p.Name}
}
header := []string{"ID", "Slug", "Name"}
Expand Down
4 changes: 2 additions & 2 deletions cmd/retrieve_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ packet project get -n [project_name]
}
if projectID == "" {
listOpt := &packngo.ListOptions{
Includes: "members",
Includes: []string{"members"},
}

projects, _, err := PacknGo.Projects.List(listOpt)
Expand Down Expand Up @@ -79,7 +79,7 @@ packet project get -n [project_name]
header := []string{"ID", "Name", "Created"}
output(projects, header, &data)
} else {
p, _, err := PacknGo.Projects.GetExtra(projectID, []string{"members"}, []string{})
p, _, err := PacknGo.Projects.Get(projectID, &packngo.GetOptions{Includes: []string{"members"}})
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ packet ssh-key get --id [ssh-key_UUID]

output(sshKeys, header, &data)
} else {
sshKey, _, err := PacknGo.SSHKeys.Get(sshKeyID)
sshKey, _, err := PacknGo.SSHKeys.Get(sshKeyID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ packet user get --id [user_UUID]
return
}
} else {
user, _, err = PacknGo.Users.Get(userID)
user, _, err = PacknGo.Users.Get(userID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ packet virtual-network get -p [project_UUID]

`,
Run: func(cmd *cobra.Command, args []string) {
vnets, _, err := PacknGo.ProjectVirtualNetworks.List(projectID)
vnets, _, err := PacknGo.ProjectVirtualNetworks.List(projectID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ packet volume get --id [volume_UUID]
output(volumes, header, &data)
} else if volumeID != "" {

v, _, err := PacknGo.Volumes.Get(volumeID)
v, _, err := PacknGo.Volumes.Get(volumeID, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/retrieve_vpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Enable VPN service:
packet vpn get --faciliy ewr1
`,
Run: func(cmd *cobra.Command, args []string) {
config, _, err := PacknGo.VPN.Get(facility)
config, _, err := PacknGo.VPN.Get(facility, nil)
if err != nil {
fmt.Println("Client error:", err)
return
Expand Down
6 changes: 3 additions & 3 deletions docs/packet.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Command line interface for Packet Host

```
--config string Path to JSON or YAML configuration file
-h, --help Help for packet
--version Version for packet
-h, --help help for packet
--version version for packet
```

### SEE ALSO
Expand All @@ -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 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_2fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Two Factor Authentication operations: enable, disable, receive
### Options

```
-h, --help Help for 2fa
-h, --help help for 2fa
```

### Options inherited from parent commands
Expand All @@ -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 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_2fa_disable.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ packet 2fa disable [flags]

```
-a, --app Issues otp uri for auth application
-h, --help Help for disable
-h, --help help for disable
-s, --sms Issues SMS otp token to user's phone
-t, --token string Two factor authentication token
```
Expand All @@ -36,4 +36,4 @@ packet 2fa disable [flags]

* [packet 2fa](packet_2fa.md) - Two Factor Authentication operations

###### Auto generated by spf13/cobra on 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_2fa_enable.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ packet 2fa enable [flags]

```
-a, --app Issues otp uri for auth application
-h, --help Help for enable
-h, --help help for enable
-s, --sms Issues SMS otp token to user's phone
-t, --token string Two factor authentication token
```
Expand All @@ -36,4 +36,4 @@ packet 2fa enable [flags]

* [packet 2fa](packet_2fa.md) - Two Factor Authentication operations

###### Auto generated by spf13/cobra on 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_2fa_receive.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ packet 2fa receive [flags]

```
-a, --app Issues otp uri for auth application
-h, --help Help for receive
-h, --help help for receive
-s, --sms Issues SMS otp token to user's phone
```

Expand All @@ -35,4 +35,4 @@ packet 2fa receive [flags]

* [packet 2fa](packet_2fa.md) - Two Factor Authentication operations

###### Auto generated by spf13/cobra on 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Device operations: create, delete, update, start/stop, reboot and get.
### Options

```
-h, --help Help for device
-h, --help help for device
```

### Options inherited from parent commands
Expand All @@ -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 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_device_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ packet device create [flags]
-c, --customdata string Custom data
-f, --facility string Code of the facility where the device will be created
-r, --hardware-reservation-id string UUID of the hardware reservation
-h, --help Help for create
-h, --help help for create
-H, --hostname string Hostname
-i, --ipxe-script-url string URL to the iPXE script
-j, --json JSON output
Expand All @@ -49,4 +49,4 @@ packet device create [flags]

* [packet device](packet_device.md) - Device operations

###### Auto generated by spf13/cobra on 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_device_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ packet device delete [flags]

```
-f, --force Force removal of the device
-h, --help Help for delete
-h, --help help for delete
-i, --id string UUID of the device
```

Expand All @@ -32,4 +32,4 @@ packet device delete [flags]

* [packet device](packet_device.md) - Device operations

###### Auto generated by spf13/cobra on 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
4 changes: 2 additions & 2 deletions docs/packet_device_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ packet device get [flags]
### Options

```
-h, --help Help for get
-h, --help help for get
-i, --id string UUID of the device
-j, --json JSON output
-p, --project-id string UUID of the project
Expand All @@ -34,4 +34,4 @@ packet device get [flags]

* [packet device](packet_device.md) - Device operations

###### Auto generated by spf13/cobra on 12-Aug-2019
###### Auto generated by spf13/cobra on 25-Nov-2019
Loading