Skip to content

Commit 04cb05c

Browse files
authored
Merge pull request #399 from Tinyblargon/GuestID
feat: type `GuestID`
2 parents 0f3daee + b433e36 commit 04cb05c

34 files changed

+263
-184
lines changed

cli/command/create/create-snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var (
1515
TraverseChildren: true,
1616
Args: cobra.RangeArgs(2, 3),
1717
RunE: func(cmd *cobra.Command, args []string) (err error) {
18-
id := cli.ValidateIntIDset(args, "GuestID")
18+
id := cli.ValidateGuestIDset(args, "GuestID")
1919
snapName := cli.RequiredIDset(args, 1, "SnapshotName")
2020
config := proxmox.ConfigSnapshot{
2121
Name: proxmox.SnapshotName(snapName),

cli/command/create/guest/create-guest.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package guest
22

33
import (
44
"context"
5-
"strconv"
65

76
"github.com/Telmate/proxmox-api-go/cli"
87
"github.com/Telmate/proxmox-api-go/cli/command/create"
@@ -21,7 +20,7 @@ func init() {
2120
}
2221

2322
func createGuest(ctx context.Context, args []string, IDtype string) (err error) {
24-
id := cli.ValidateIntIDset(args, IDtype+"ID")
23+
id := cli.ValidateGuestIDset(args, IDtype+"ID")
2524
node := cli.RequiredIDset(args, 1, "NodeID")
2625
vmr := proxmox.NewVmRef(id)
2726
vmr.SetNode(node)
@@ -61,6 +60,6 @@ func createGuest(ctx context.Context, args []string, IDtype string) (err error)
6160
if err != nil {
6261
return
6362
}
64-
cli.PrintItemCreated(guestCmd.OutOrStdout(), strconv.Itoa(id), IDtype)
63+
cli.PrintItemCreated(guestCmd.OutOrStdout(), id.String(), IDtype)
6564
return
6665
}

cli/command/delete/delete-guest.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package delete
22

33
import (
4-
"strconv"
5-
64
"github.com/Telmate/proxmox-api-go/cli"
75
"github.com/Telmate/proxmox-api-go/proxmox"
86
"github.com/spf13/cobra"
@@ -13,7 +11,7 @@ var delete_guestCmd = &cobra.Command{
1311
Short: "Deletes the Specified Guest",
1412
Args: cobra.ExactArgs(1),
1513
RunE: func(cmd *cobra.Command, args []string) (err error) {
16-
id := cli.ValidateIntIDset(args, "GuestID")
14+
id := cli.ValidateGuestIDset(args, "GuestID")
1715
vmr := proxmox.NewVmRef(id)
1816
c := cli.NewClient()
1917
_, err = c.StopVm(cli.Context(), vmr)
@@ -24,7 +22,7 @@ var delete_guestCmd = &cobra.Command{
2422
if err != nil {
2523
return
2624
}
27-
cli.PrintItemDeleted(deleteCmd.OutOrStdout(), strconv.Itoa(id), "GuestID")
25+
cli.PrintItemDeleted(deleteCmd.OutOrStdout(), id.String(), "GuestID")
2826
return
2927
},
3028
}

cli/command/delete/delete-snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var (
1212
Short: "Deletes the Specified snapshot",
1313
Args: cobra.ExactArgs(2),
1414
RunE: func(cmd *cobra.Command, args []string) (err error) {
15-
id := cli.ValidateIntIDset(args, "GuestID")
15+
id := cli.ValidateGuestIDset(args, "GuestID")
1616
snapName := cli.RequiredIDset(args, 1, "SnapshotName")
1717
_, err = proxmox.SnapshotName(snapName).Delete(cli.Context(), cli.NewClient(), proxmox.NewVmRef(id))
1818
if err != nil {

cli/command/get/guest/get-guest-config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var configCmd = &cobra.Command{
1111
Short: "Gets the configuration of the specified guest",
1212
Args: cobra.ExactArgs(1),
1313
RunE: func(cmd *cobra.Command, args []string) (err error) {
14-
id := cli.ValidateIntIDset(args, "GuestID")
14+
id := cli.ValidateGuestIDset(args, "GuestID")
1515
vmr := proxmox.NewVmRef(id)
1616
c := cli.NewClient()
1717
err = c.CheckVmRef(cli.Context(), vmr)

cli/command/get/guest/get-guest-feature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var featureCmd = &cobra.Command{
1111
Short: "Gets the available features of the specified guest",
1212
Args: cobra.ExactArgs(1),
1313
RunE: func(cmd *cobra.Command, args []string) (err error) {
14-
id := cli.ValidateIntIDset(args, "GuestID")
14+
id := cli.ValidateGuestIDset(args, "GuestID")
1515
vmr := proxmox.NewVmRef(id)
1616
c := cli.NewClient()
1717
err = c.CheckVmRef(cli.Context(), vmr)

cli/command/get/id/get-id-check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
)
99

1010
var id_checkCmd = &cobra.Command{
11-
Use: "check ID",
12-
Short: "Checks if a ID is available",
11+
Use: "check GuestID",
12+
Short: "Checks if a GuestID is available",
1313
Args: cobra.ExactArgs(1),
1414
RunE: func(cmd *cobra.Command, args []string) (err error) {
15-
id := cli.ValidateIntIDset(args, "ID")
15+
id := cli.ValidateGuestIDset(args, "GUESTID")
1616
c := cli.NewClient()
1717
exists, err := c.VMIdExists(cli.Context(), id)
1818
if err != nil {

cli/command/guest/guest-rollback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var guest_rollbackCmd = &cobra.Command{
1313
Short: "Shuts the specified guest down",
1414
Args: cobra.ExactArgs(2),
1515
RunE: func(cmd *cobra.Command, args []string) (err error) {
16-
vmr := proxmox.NewVmRef(cli.ValidateIntIDset(args, "GuestID"))
16+
vmr := proxmox.NewVmRef(cli.ValidateGuestIDset(args, "GuestID"))
1717
snapName := cli.RequiredIDset(args, 1, "SnapshotName")
1818
_, err = proxmox.SnapshotName(snapName).Rollback(cli.Context(), cli.NewClient(), vmr)
1919
if err == nil {

cli/command/guest/guest-shutdown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var guest_shutdownCmd = &cobra.Command{
1111
Short: "Shuts the specified guest down",
1212
Args: cobra.ExactArgs(1),
1313
RunE: func(cmd *cobra.Command, args []string) (err error) {
14-
vmr := proxmox.NewVmRef(cli.ValidateIntIDset(args, "GuestID"))
14+
vmr := proxmox.NewVmRef(cli.ValidateGuestIDset(args, "GuestID"))
1515
c := cli.NewClient()
1616
_, err = c.ShutdownVm(cli.Context(), vmr)
1717
if err == nil {

cli/command/guest/guest-start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var guest_statusCmd = &cobra.Command{
1111
Short: "Starts the specified guest",
1212
Args: cobra.ExactArgs(1),
1313
RunE: func(cmd *cobra.Command, args []string) (err error) {
14-
vmr := proxmox.NewVmRef(cli.ValidateIntIDset(args, "GuestID"))
14+
vmr := proxmox.NewVmRef(cli.ValidateGuestIDset(args, "GuestID"))
1515
c := cli.NewClient()
1616
_, err = c.StartVm(cli.Context(), vmr)
1717
if err == nil {

0 commit comments

Comments
 (0)