-
Notifications
You must be signed in to change notification settings - Fork 95
fix: reconsider behavior when providing a value lower than 500 for bu… #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@fulviodenza are you free to give it a look? |
Hi @harsh082ip, thanks for your contribution! While the original issue has already been marked as closed and some parts of it were resolved, I think we should discuss whether we want to let the @alessandroargentieri @fulviodenza @uzaxirr thoughts? |
Hii @giornetta , Thanks for the context! I agree, auto-selecting a higher size with --yes might lead to unexpected charges. Happy to align on the best approach. |
cmd/objectstore/objectstore.go
Outdated
@@ -45,10 +45,11 @@ func init() { | |||
ObjectStoreCmd.AddCommand(objectStoreCredentialCmd) | |||
|
|||
//Flags for create cmd | |||
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", 500, "Size of the Object store") | |||
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", 500, "Size of the Object store in GB (minimum: 500)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use a variable for this 500
value,
os.Exit(1) | ||
} | ||
if !accept { | ||
os.Exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this indicates success, the operation, when not accepted is not a success, we need os.Exit(1)
for this
utility.Error("Unable to parse the input: %s", err) | ||
os.Exit(1) | ||
if !yesFlag { | ||
utility.YellowConfirm("The size to create an object store must be a multiple of 500. Would you like to create an %s of %d GB instead? (y/n) ? ", utility.Green("object store"), bucketSize+(500-bucketSize%500)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should specify that 500 and 1000GB are the only allowed sizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bucketSize+(500-bucketSize%500))
could be a small function
Hi @fulviodenza, apologies for the delay — I've pushed the required changes. Let me know if anything else is needed. |
@@ -45,10 +50,11 @@ func init() { | |||
ObjectStoreCmd.AddCommand(objectStoreCredentialCmd) | |||
|
|||
//Flags for create cmd | |||
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", 500, "Size of the Object store (Minimum size is 500GB)") | |||
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", minBucketSizeGB, fmt.Sprintf("Size of the Object store (Allowed sizes: %dGB or 1000GB)", minBucketSizeGB)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the 500 is set as constant while the 1000 isn't?
|
||
var objectStoreCreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Aliases: []string{"new", "add"}, | ||
Example: "civo objectstore create OBJECTSTORE_NAME --size SIZE", | ||
Short: "Create a new Object Store", | ||
Long: "Bucket size should be in Gigabytes (GB) and must be a multiple of 500, starting from 500.\n", | ||
Long: "Bucket size should be in Gigabytes (GB) and must be either 500 or 1000.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't we use the constants of before, declared in a common package?
As mentioned in issue #394, the following changes have been made:
The command will now fail immediately for values less than 500 GB with an appropriate error message.
Introduced a --yes flag to automatically adjust the bucket size to the nearest multiple of 500 without prompting the user.
For example:
Warning: The size to create an object store must be a multiple of 500. Would you like to create an object store of 1000 GB instead? (y/n)?
Using the --yes flag, users can bypass this prompt.
Improved the help message to make the minimum and default size requirements explicit:
-s, --size int Size of the Object store in GB (minimum: 500) (default 500)
Screenshot:

Please review and let me know if any changes are needed.
@haardikdharma10 @uzaxirr @RealHarshThakur @alejandrojnm