Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/apikey/apikey_current.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"

"github.com/civo/cli/common"
"github.com/civo/cli/config"
"github.com/civo/cli/utility"
"github.com/spf13/cobra"
Expand All @@ -24,7 +25,19 @@ var apikeyCurrentCmd = &cobra.Command{
if index != "" {
config.Current.Meta.CurrentAPIKey = index
config.SaveConfig()
fmt.Printf("Set the default API Key to be %s\n", utility.Green(index))

ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("name", index, "Name")

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
fmt.Printf("Set the default API Key to be %s\n", utility.Green(index))
}
}

},
Expand Down
13 changes: 12 additions & 1 deletion cmd/apikey/apikey_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ var apikeyRemoveCmd = &cobra.Command{
config.SaveConfig()

if numKeys > len(config.Current.APIKeys) {
fmt.Printf("Removed the API Key %s\n", utility.Green(index))
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("name", index, "Name")

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
fmt.Printf("Removed the API Key %s\n", utility.Green(index))
}
} else {
utility.Error("The API Key %q couldn't be found", args[0])
os.Exit(1)
Expand Down
21 changes: 17 additions & 4 deletions cmd/instance/instance_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,23 @@ var instancePublicIPCmd = &cobra.Command{
utility.Error("%s", err)
}

if args[0] == "disable" {
fmt.Printf("Instance %s has been updated to NOT have a Public IP\n", utility.Green(instance.Hostname))
} else {
fmt.Printf("Instance %s has been updated to have a Public IP. IP addressed will be assigned shortly.\n", utility.Green(instance.Hostname))
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("id", instance.ID, "ID")
ow.AppendDataWithLabel("hostname", instance.Hostname, "Hostname")
ow.AppendDataWithLabel("public_ip", args[0], "Public IP")

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
if args[0] == "disable" {
fmt.Printf("Instance %s has been updated to NOT have a Public IP\n", utility.Green(instance.Hostname))
} else {
fmt.Printf("Instance %s has been updated to have a Public IP. IP addressed will be assigned shortly.\n", utility.Green(instance.Hostname))
}
}
},
}
23 changes: 17 additions & 6 deletions cmd/instance/instance_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ Example:
utility.Error("%s", err)
os.Exit(1)
}
fmt.Println("Instance ID is: ", instance.ID)
Comment thread
giornetta marked this conversation as resolved.

if args[0] == "enable" {
_, err := client.EnableRecoveryMode(instance.ID)
if err != nil {
Expand All @@ -63,10 +61,23 @@ Example:
}
}

if args[0] == "enable" {
fmt.Printf("Recovery mode has been enabled for instance %s\n", utility.Green(instance.Hostname))
} else {
fmt.Printf("Recovery mode has been disabled for instance %s\n", utility.Green(instance.Hostname))
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("id", instance.ID, "ID")
ow.AppendDataWithLabel("hostname", instance.Hostname, "Hostname")
ow.AppendDataWithLabel("recovery_mode", args[0], "Recovery Mode")

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
if args[0] == "enable" {
fmt.Printf("Recovery mode has been enabled for instance %s (%s)\n", utility.Green(instance.Hostname), instance.ID)
} else {
fmt.Printf("Recovery mode has been disabled for instance %s (%s)\n", utility.Green(instance.Hostname), instance.ID)
}
}
},
}
15 changes: 14 additions & 1 deletion cmd/kubernetes/kubernetes_nodepool_instance_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,20 @@ var kubernetesNodePoolInstanceDeleteCmd = &cobra.Command{
os.Exit(1)
}

fmt.Printf("Instance %s has been deleted from node pool %s in cluster %s\n", instanceID, nodePoolID, kubernetesFindCluster.Name)
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("instance_id", instanceID, "Instance ID")
ow.AppendDataWithLabel("node_pool_id", nodePoolID, "Node Pool ID")
ow.AppendDataWithLabel("cluster_name", kubernetesFindCluster.Name, "Cluster Name")

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
fmt.Printf("Instance %s has been deleted from node pool %s in cluster %s\n", instanceID, nodePoolID, kubernetesFindCluster.Name)
}
} else {
fmt.Println("Operation aborted.")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/kubernetes/kubernetes_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ var kubernetesRemoveCmd = &cobra.Command{
} else {
ow.WriteMultipleObjectsJSON(common.PrettySet)
}
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
fmt.Printf("The Kubernetes %s (%s) %s been deleted\n",
Expand Down
14 changes: 13 additions & 1 deletion cmd/kubernetes/kubernetes_update_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ var kubernetesUpdateKubeconfigCmd = &cobra.Command{
os.Exit(1)
}

fmt.Printf("Updated kubeconfig with cluster %s configuration\n", utility.Green(cluster.Name))
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("id", cluster.ID, "ID")
ow.AppendDataWithLabel("name", cluster.Name, "Name")

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
fmt.Printf("Updated kubeconfig with cluster %s configuration\n", utility.Green(cluster.Name))
}
},
}
77 changes: 51 additions & 26 deletions cmd/network/network_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package network
import (
"fmt"
"os"
"strconv"

"github.com/civo/cli/common"
"github.com/civo/cli/config"
"github.com/civo/cli/utility"
"github.com/spf13/cobra"
Expand All @@ -29,36 +31,59 @@ var networkShowCmd = &cobra.Command{
os.Exit(1)
}

// Display Core Network Details
fmt.Println("Network Details:")
fmt.Printf("ID: %s\n", network.ID)
fmt.Printf("Name: %s\n", network.Name)
fmt.Printf("Default: %s\n", utility.BoolToYesNo(network.Default))
fmt.Printf("CIDR: %s\n", network.CIDR)
fmt.Printf("Status: %s\n", network.Status)
fmt.Printf("IPv4 Enabled: %s\n", utility.BoolToYesNo(network.IPv4Enabled))
fmt.Printf("IPv6 Enabled: %s\n", utility.BoolToYesNo(network.IPv6Enabled))

// Conditional VLAN Details
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendDataWithLabel("id", network.ID, "ID")
ow.AppendDataWithLabel("name", network.Name, "Name")
ow.AppendDataWithLabel("default", utility.BoolToYesNo(network.Default), "Default")
ow.AppendDataWithLabel("cidr", network.CIDR, "CIDR")
ow.AppendDataWithLabel("status", network.Status, "Status")
ow.AppendDataWithLabel("ipv4_enabled", utility.BoolToYesNo(network.IPv4Enabled), "IPv4 Enabled")
ow.AppendDataWithLabel("ipv6_enabled", utility.BoolToYesNo(network.IPv6Enabled), "IPv6 Enabled")
ow.AppendDataWithLabel("gateway_ipv4", network.GatewayIPv4, "Gateway IPv4")
if network.VlanID != 0 {
fmt.Println("\nVLAN Details:")
fmt.Printf("VLAN ID: %d\n", network.VlanID)
fmt.Printf("Hardware Address: %s\n", network.PhysicalInterface)
fmt.Printf("Gateway IPv4: %s\n", network.GatewayIPv4)
fmt.Printf("Allocation Pool IPv4 Start: %s\n", network.AllocationPoolV4Start)
fmt.Printf("Allocation Pool IPv4 End: %s\n", network.AllocationPoolV4End)
} else {
fmt.Println("\nNo VLAN Configuration")
ow.AppendDataWithLabel("vlan_id", strconv.Itoa(network.VlanID), "VLAN ID")
ow.AppendDataWithLabel("physical_interface", network.PhysicalInterface, "Hardware Address")
ow.AppendDataWithLabel("allocation_pool_v4_start", network.AllocationPoolV4Start, "Allocation Pool IPv4 Start")
ow.AppendDataWithLabel("allocation_pool_v4_end", network.AllocationPoolV4End, "Allocation Pool IPv4 End")
}
ow.AppendDataWithLabel("nameservers_v4", utility.SliceToString(network.NameserversV4), "Nameservers IPv4")
ow.AppendDataWithLabel("nameservers_v6", utility.SliceToString(network.NameserversV6), "Nameservers IPv6")

// Nameserver Details
if len(network.NameserversV4) > 0 || len(network.NameserversV6) > 0 {
fmt.Println("\nNameserver Details:")
if len(network.NameserversV4) > 0 {
fmt.Printf("Nameservers IPv4: %s\n", utility.SliceToString(network.NameserversV4))
switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
fmt.Println("Network Details:")
fmt.Printf("ID: %s\n", network.ID)
fmt.Printf("Name: %s\n", network.Name)
fmt.Printf("Default: %s\n", utility.BoolToYesNo(network.Default))
fmt.Printf("CIDR: %s\n", network.CIDR)
fmt.Printf("Status: %s\n", network.Status)
fmt.Printf("IPv4 Enabled: %s\n", utility.BoolToYesNo(network.IPv4Enabled))
fmt.Printf("IPv6 Enabled: %s\n", utility.BoolToYesNo(network.IPv6Enabled))
fmt.Printf("Gateway IPv4: %s\n", network.GatewayIPv4)

if network.VlanID != 0 {
fmt.Println("\nVLAN Details:")
fmt.Printf("VLAN ID: %d\n", network.VlanID)
fmt.Printf("Hardware Address: %s\n", network.PhysicalInterface)
fmt.Printf("Allocation Pool IPv4 Start: %s\n", network.AllocationPoolV4Start)
fmt.Printf("Allocation Pool IPv4 End: %s\n", network.AllocationPoolV4End)
} else {
fmt.Println("\nNo VLAN Configuration")
}
if len(network.NameserversV6) > 0 {
fmt.Printf("Nameservers IPv6: %s\n", utility.SliceToString(network.NameserversV6))

if len(network.NameserversV4) > 0 || len(network.NameserversV6) > 0 {
fmt.Println("\nNameserver Details:")
if len(network.NameserversV4) > 0 {
fmt.Printf("Nameservers IPv4: %s\n", utility.SliceToString(network.NameserversV4))
}
if len(network.NameserversV6) > 0 {
fmt.Printf("Nameservers IPv6: %s\n", utility.SliceToString(network.NameserversV6))
}
}
}
},
Expand Down
Loading