diff --git a/commands/kubernetes.go b/commands/kubernetes.go index 5c59ff71a..6b067fea9 100644 --- a/commands/kubernetes.go +++ b/commands/kubernetes.go @@ -283,7 +283,7 @@ After creating a cluster, a configuration context is added to kubectl and made a "Enables surge-upgrade for the cluster") AddBoolFlag(cmdKubeClusterCreate, doctl.ArgHA, "", false, "Creates the cluster with a highly-available control plane. Defaults to false. To enable the HA control plane, supply --ha=true.") - AddStringFlag(cmdKubeClusterCreate, doctl.ArgEnableControlPlaneFirewall, "", "", + AddBoolFlag(cmdKubeClusterCreate, doctl.ArgEnableControlPlaneFirewall, "", false, "Creates the cluster with control plane firewall enabled. Defaults to false. To enable the control plane firewall, supply --enable-control-plane-firewall=true.") AddStringSliceFlag(cmdKubeClusterCreate, doctl.ArgControlPlaneFirewallAllowedAddresses, "", nil, "A comma-separated list of allowed addresses that can access the control plane.") @@ -333,7 +333,7 @@ Updates the configuration values for a Kubernetes cluster. The cluster must be r "Enables surge-upgrade for the cluster") AddBoolFlag(cmdKubeClusterUpdate, doctl.ArgHA, "", false, "Enables the highly-available control plane for the cluster") - AddStringFlag(cmdKubeClusterUpdate, doctl.ArgEnableControlPlaneFirewall, "", "", + AddBoolFlag(cmdKubeClusterUpdate, doctl.ArgEnableControlPlaneFirewall, "", false, "Creates the cluster with control plane firewall enabled. Defaults to false. To enable the control plane firewall, supply --enable-control-plane-firewall=true.") AddStringSliceFlag(cmdKubeClusterUpdate, doctl.ArgControlPlaneFirewallAllowedAddresses, "", nil, "A comma-separated list of allowed addresses that can access the control plane.") @@ -1657,17 +1657,13 @@ func buildClusterCreateRequestFromArgs(c *CmdConfig, r *godo.KubernetesClusterCr } r.HA = ha - enableControlPlaneFirewall, err := c.Doit.GetString(c.NS, doctl.ArgEnableControlPlaneFirewall) + enableControlPlaneFirewall, err := c.Doit.GetBoolPtr(c.NS, doctl.ArgEnableControlPlaneFirewall) if err != nil { return err } - if enableControlPlaneFirewall != "" { - enableControlPlaneFirewallBool, err := strconv.ParseBool(enableControlPlaneFirewall) - if err != nil { - return err - } + if enableControlPlaneFirewall != nil { r.ControlPlaneFirewall = &godo.KubernetesControlPlaneFirewall{ - Enabled: &enableControlPlaneFirewallBool, + Enabled: enableControlPlaneFirewall, } } @@ -1679,6 +1675,9 @@ func buildClusterCreateRequestFromArgs(c *CmdConfig, r *godo.KubernetesClusterCr if r.ControlPlaneFirewall == nil { r.ControlPlaneFirewall = &godo.KubernetesControlPlaneFirewall{} } + for i := range controlPlaneFirewallAllowedAddresses { + controlPlaneFirewallAllowedAddresses[i] = strings.TrimSpace(controlPlaneFirewallAllowedAddresses[i]) + } r.ControlPlaneFirewall.AllowedAddresses = controlPlaneFirewallAllowedAddresses } @@ -1772,17 +1771,13 @@ func buildClusterUpdateRequestFromArgs(c *CmdConfig, r *godo.KubernetesClusterUp } r.HA = ha - enableControlPlaneFirewall, err := c.Doit.GetString(c.NS, doctl.ArgEnableControlPlaneFirewall) + enableControlPlaneFirewall, err := c.Doit.GetBoolPtr(c.NS, doctl.ArgEnableControlPlaneFirewall) if err != nil { return err } - if enableControlPlaneFirewall != "" { - enableControlPlaneFirewallBool, err := strconv.ParseBool(enableControlPlaneFirewall) - if err != nil { - return err - } + if enableControlPlaneFirewall != nil { r.ControlPlaneFirewall = &godo.KubernetesControlPlaneFirewall{ - Enabled: &enableControlPlaneFirewallBool, + Enabled: enableControlPlaneFirewall, } } @@ -1794,6 +1789,9 @@ func buildClusterUpdateRequestFromArgs(c *CmdConfig, r *godo.KubernetesClusterUp if r.ControlPlaneFirewall == nil { r.ControlPlaneFirewall = &godo.KubernetesControlPlaneFirewall{} } + for i := range controlPlaneFirewallAllowedAddresses { + controlPlaneFirewallAllowedAddresses[i] = strings.TrimSpace(controlPlaneFirewallAllowedAddresses[i]) + } r.ControlPlaneFirewall.AllowedAddresses = controlPlaneFirewallAllowedAddresses } diff --git a/commands/volume_actions.go b/commands/volume_actions.go index 94fcf68ed..7dab52e5d 100644 --- a/commands/volume_actions.go +++ b/commands/volume_actions.go @@ -16,10 +16,11 @@ package commands import ( "strconv" + "github.com/spf13/cobra" + "github.com/digitalocean/doctl" "github.com/digitalocean/doctl/commands/displayers" "github.com/digitalocean/doctl/do" - "github.com/spf13/cobra" ) type volumeActionFn func(das do.VolumeActionsService) (*do.Action, error)