diff --git a/cmd/kubernetes/kubernetes.go b/cmd/kubernetes/kubernetes.go index 83f1dcc..0819abb 100644 --- a/cmd/kubernetes/kubernetes.go +++ b/cmd/kubernetes/kubernetes.go @@ -335,6 +335,11 @@ func NewCmdKubernetes(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo return fmt.Errorf("error parsing flag 'high-avail' for kubernetes cluster create : %v", errHi) } + fw, errFw := cmd.Flags().GetBool("enable-firewall") + if errHi != nil { + return fmt.Errorf("error parsing flag 'enable-firewall' for kubernetes cluster create : %v", errFw) + } + nps, errFm := formatNodePools(nodepools) if errFm != nil { return fmt.Errorf("error in node pool formating : %v", errFm) @@ -346,6 +351,7 @@ func NewCmdKubernetes(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo NodePools: nps, Version: version, HAControlPlanes: ha, + EnableFirewall: fw, } k8, err := o.create() @@ -385,6 +391,13 @@ func NewCmdKubernetes(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo highly available, control planes`, ) + create.Flags().BoolP( + "enable-firewall", + "f", + false, + `(optional, default false) whether a firewall group should be created for the cluster`, + ) + create.Flags().StringArrayP( "node-pools", "n", diff --git a/cmd/kubernetes/printer.go b/cmd/kubernetes/printer.go index 1278d8e..7fdf6bd 100644 --- a/cmd/kubernetes/printer.go +++ b/cmd/kubernetes/printer.go @@ -111,6 +111,7 @@ func (c *ClustersPrinter) Data() [][]string { []string{"IP", c.Clusters[i].IP}, []string{"ENDPOINT", c.Clusters[i].Endpoint}, []string{"HIGH AVAIL", strconv.FormatBool(c.Clusters[i].HAControlPlanes)}, + []string{"FIREWALL GROUP ID", c.Clusters[i].FirewallGroupID}, []string{"VERSION", c.Clusters[i].Version}, []string{"REGION", c.Clusters[i].Region}, []string{"STATUS", c.Clusters[i].Status}, @@ -197,6 +198,7 @@ func (c *ClusterPrinter) Data() [][]string { []string{"IP", c.Cluster.IP}, []string{"ENDPOINT", c.Cluster.Endpoint}, []string{"HIGH AVAIL", strconv.FormatBool(c.Cluster.HAControlPlanes)}, + []string{"FIREWALL GROUP ID", c.Cluster.FirewallGroupID}, []string{"VERSION", c.Cluster.Version}, []string{"REGION", c.Cluster.Region}, []string{"STATUS", c.Cluster.Status}, diff --git a/cmd/plans/printer.go b/cmd/plans/printer.go index 07279ea..2fb6445 100644 --- a/cmd/plans/printer.go +++ b/cmd/plans/printer.go @@ -1,13 +1,11 @@ package plans import ( - "encoding/json" "strconv" "github.com/vultr/govultr/v3" "github.com/vultr/vultr-cli/v3/cmd/printer" "github.com/vultr/vultr-cli/v3/cmd/utils" - "gopkg.in/yaml.v3" ) // PlansPrinter represents the plans data from the API @@ -18,21 +16,12 @@ type PlansPrinter struct { // JSON provides the JSON formatted byte data func (p *PlansPrinter) JSON() []byte { - js, err := json.MarshalIndent(p, "", " ") - if err != nil { - panic(err.Error()) - } - - return js + return printer.MarshalObject(p, "json") } // YAML provides the YAML formatted byte data func (p *PlansPrinter) YAML() []byte { - yml, err := yaml.Marshal(p) - if err != nil { - panic(err.Error()) - } - return yml + return printer.MarshalObject(p, "yaml") } // Columns provides the plan columns for the printer @@ -85,6 +74,8 @@ func (p *PlansPrinter) Paging() [][]string { return printer.NewPagingFromMeta(p.Meta).Compose() } +// ====================================== + // MetalPlansPrinter represents the bare metal plans data from the API type MetalPlansPrinter struct { Plans []govultr.BareMetalPlan `json:"plans_metal"` @@ -93,21 +84,12 @@ type MetalPlansPrinter struct { // JSON provides the JSON formatted byte data func (m *MetalPlansPrinter) JSON() []byte { - js, err := json.MarshalIndent(m, "", " ") - if err != nil { - panic(err.Error()) - } - - return js + return printer.MarshalObject(m, "json") } // YAML provides the YAML formatted byte data func (m *MetalPlansPrinter) YAML() []byte { - yml, err := yaml.Marshal(m) - if err != nil { - panic(err.Error()) - } - return yml + return printer.MarshalObject(m, "yaml") } // Columns provides the plan columns for the printer diff --git a/cmd/regions/printer.go b/cmd/regions/printer.go index 304dd4d..4ce9da9 100644 --- a/cmd/regions/printer.go +++ b/cmd/regions/printer.go @@ -68,7 +68,6 @@ func (r *RegionsPrinter) Paging() [][]string { // via the ResourceOutput interface type RegionsAvailabilityPrinter struct { Plans *govultr.PlanAvailability `json:"available_plans"` - Meta *govultr.Meta `json:"meta"` } // JSON provides the JSON formatted byte data @@ -108,5 +107,5 @@ func (r *RegionsAvailabilityPrinter) Data() [][]string { // Paging validates and forms the paging data for output func (r *RegionsAvailabilityPrinter) Paging() [][]string { - return printer.NewPagingFromMeta(r.Meta).Compose() + return nil }