(c *CmdConfig)
| 832 | } |
| 833 | |
| 834 | func buildDatabaseStorageAutoscaleRequestFromArgs(c *CmdConfig) (*godo.DatabaseStorageAutoscale, error) { |
| 835 | if c.Command == nil { |
| 836 | return nil, errors.New("command flags are not available") |
| 837 | } |
| 838 | |
| 839 | flags := c.Command.Flags() |
| 840 | |
| 841 | enabledStr, err := flags.GetString(doctl.ArgDatabaseStorageAutoscaleEnabled) |
| 842 | if err != nil { |
| 843 | return nil, err |
| 844 | } |
| 845 | if strings.TrimSpace(enabledStr) == "" { |
| 846 | return nil, doctl.NewMissingArgsErr(doctl.ArgDatabaseStorageAutoscaleEnabled) |
| 847 | } |
| 848 | |
| 849 | enabled, err := strconv.ParseBool(enabledStr) |
| 850 | if err != nil { |
| 851 | return nil, fmt.Errorf("%q is not a valid boolean for --enabled (use true or false)", enabledStr) |
| 852 | } |
| 853 | |
| 854 | if !enabled { |
| 855 | return &godo.DatabaseStorageAutoscale{Enabled: false}, nil |
| 856 | } |
| 857 | |
| 858 | thresholdPercent := defaultDatabaseStorageAutoscaleThresholdPercent |
| 859 | if flags.Changed(doctl.ArgDatabaseStorageAutoscaleThresholdPercent) { |
| 860 | thresholdPercent, err = flags.GetInt(doctl.ArgDatabaseStorageAutoscaleThresholdPercent) |
| 861 | if err != nil { |
| 862 | return nil, err |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | incrementGib := uint64(defaultDatabaseStorageAutoscaleIncrementGib) |
| 867 | if flags.Changed(doctl.ArgDatabaseStorageAutoscaleIncrementGib) { |
| 868 | val, err := flags.GetInt(doctl.ArgDatabaseStorageAutoscaleIncrementGib) |
| 869 | if err != nil { |
| 870 | return nil, err |
| 871 | } |
| 872 | incrementGib = uint64(val) |
| 873 | } |
| 874 | |
| 875 | return &godo.DatabaseStorageAutoscale{ |
| 876 | Enabled: true, |
| 877 | ThresholdPercent: &thresholdPercent, |
| 878 | IncrementGib: &incrementGib, |
| 879 | }, nil |
| 880 | } |
| 881 | |
| 882 | func databaseUser() *Command { |
| 883 | cmd := &Command{ |
no test coverage detected