-
Notifications
You must be signed in to change notification settings - Fork 896
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
Support operation clear
on CloudObjectStoreContainer
#14082
Conversation
@miq-bot add_label enhancement,wip |
566326d
to
f179dc7
Compare
f179dc7
to
3d08efd
Compare
This pull request is not mergeable. Please rebase and repush. |
3d08efd
to
50f2a9f
Compare
empty
in CloudObjectStoreContainer
@durandom could you peek at this one as well? It's just a tiny upgrade of yesterday's PR that introduced |
@miha-plesko how does S3 implement this? Is there an |
@durandom aws-sdk names this operation "clear", see this line: I believe this operation could be reused on any model that groups other models. Like "empty orchestration stack" would mean to delete all instances within or "empty cloud network" would mean to remove all cloud subnets within. I would go with |
092691e
to
d3f99ae
Compare
empty
in CloudObjectStoreContainerempty_container
on CloudObjectStoreContainer
@blomquisg @agrare @bzwei @Ladas whats your opinion wrt naming this? |
@durandom @miha-plesko I tend to like the more descriptive name as well but this is somewhat subjective, I don't get why you would have the long name for the main method and the short name for the raw method though...I would think they should keep the same name scheme. Also for |
d3f99ae
to
93ace7b
Compare
@durandom @agrare I've renamed to cloud_object_store_container_empty
raw_cloud_object_store_container_empty The reason I prefer suffix over prefix is miq_product_features.yml file where all the names are suffix-like: (Should we decide to use prefix form |
end | ||
|
||
def raw_cloud_object_store_container_empty | ||
raise NotImplementedError, _("must be implemented in subclass") |
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.
It looks like the AWS API call is clear
. I think that's more descriptive than empty
.
My first impression with cloud_object_store_container_emtpy
was that it was missing a question mark and it should be predicate method.
I think cloud_object_store_container_clear
sounds like it's going to clear the container.
Or, do what @agrare said, and reverse the naming by putting the verb before the object: empty_cloud_object_store_container
. In either case, I lean closer to sticking with clear
instead of empty
. But, I could live with either if the verb comes first.
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.
My first impression with cloud_object_store_container_emtpy was that it was missing a question mark and it should be predicate method.
I thought the same thing when I saw :container_empty
I agree clear
is more obvious especially if that is what the native method is called.
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.
93ace7b
to
35c76de
Compare
empty_container
on CloudObjectStoreContainerclear
on CloudObjectStoreContainer
@blomquisg thanks for the review, I totally agree to @miq-bot remove_label sql migration |
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.
generally ok
suffix vs. prefix: the supports feature mixin has more features with the verb being the prefix. But the product_features.yml has more suffixes, so...
@@ -120,6 +120,7 @@ module SupportsFeatureMixin | |||
:update_security_group => 'Security Group Update', | |||
:block_storage => 'Block Storage', | |||
:object_storage => 'Object Storage', | |||
:cloud_object_store_container_clear => 'Clear Object Store Container', |
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.
could you put that in alphabetical order?
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.
Oh, will try although there is no real alphabetical order to put in 😄
@@ -15,4 +15,6 @@ class CloudObjectStoreContainer < ApplicationRecord | |||
alias_attribute :name, :key | |||
|
|||
supports_not :delete, :reason => N_("Delete operation is not supported.") | |||
supports_not :cloud_object_store_container_clear, | |||
:reason => N_("Clear Object Store Container operation is not supported.") |
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.
you can omit the :reason
and it will default to Operation not supported
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.
👍
35c76de
to
9f8449a
Compare
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.
@durandom thanks for the review, I've applied your latest minor comments.
Regarding suffix vs prefix: the button on UI triggers whatever is written in miq_product_features.yml so if the function in supports_feature_mixin.rb is named differently, the UI controller needs to perform a mapping. My thinking was that we should avoid the mapping is possible.
@@ -120,6 +120,7 @@ module SupportsFeatureMixin | |||
:update_security_group => 'Security Group Update', | |||
:block_storage => 'Block Storage', | |||
:object_storage => 'Object Storage', | |||
:cloud_object_store_container_clear => 'Clear Object Store Container', |
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.
Oh, will try although there is no real alphabetical order to put in 😄
@@ -15,4 +15,6 @@ class CloudObjectStoreContainer < ApplicationRecord | |||
alias_attribute :name, :key | |||
|
|||
supports_not :delete, :reason => N_("Delete operation is not supported.") | |||
supports_not :cloud_object_store_container_clear, | |||
:reason => N_("Clear Object Store Container operation is not supported.") |
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.
👍
Thats a great rationale 👍 |
@blomquisg @agrare I like it how we're converging towards excelence here. Is there anything else to be improved, or did we converge? 🥇 |
@@ -15,4 +15,5 @@ class CloudObjectStoreContainer < ApplicationRecord | |||
alias_attribute :name, :key | |||
|
|||
supports_not :delete, :reason => N_("Delete operation is not supported.") | |||
supports_not :cloud_object_store_container_clear |
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 might need the :reason here, to get a user friendly message?
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.
Nah, I just asked @miha-plesko to drop the reason. This is most likely not displayed in the UI at all and only adds a burden to i18n to translate messages that are not used.
Actually I'm inclined to remove all supports_not
reason that are on a base class
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.
ok, interesting
@miha-plesko looks good in general. Also, when you add a new feature, it's good to list it in some default user roles, https://github.com/Ladas/manageiq/blob/497be4eb4bf197e603eb81e3cd7c87d4ce1c97ed/db/fixtures/miq_user_roles.yml#L8-L8 Otherwise, superadmin will be the only one that sees it by default. |
Operation `clear` removes all CloudObjectStoreObjects from the CloudObjectStoreContainer. Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
9f8449a
to
92e7dfb
Compare
Checked commit xlab-si@92e7dfb with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
LGTM thanks @miha-plesko ! |
Operation
clear
removes all CloudObjectStoreObjects from the CloudObjectStoreContainer. Since this kind of operation is not recognized by miq yet, I had to register it insupports_feature_mixin.rb
.