Skip to content

Commit

Permalink
Merge branch 'master' into paul/fix-pagination-panic
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSonOfLars committed Feb 26, 2024
2 parents 73f596e + 30dfcfd commit 83bf7aa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
13 changes: 13 additions & 0 deletions cmd/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions cmd/kubernetes/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down
30 changes: 6 additions & 24 deletions cmd/plans/printer.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"`
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cmd/regions/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 83bf7aa

Please sign in to comment.