Skip to content
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

Hide deprecated and duplicate attributes #20664

Merged
merged 2 commits into from
Dec 8, 2020

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Oct 7, 2020

Hide deprecated and duplicate attributes

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to start using.

Now, the attributes are still accessible. So nothing will break. But
these attributes are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.
So it will fix #18130 and also allows us to introduce attributes in PRs like #20532 because we will not need to expose the newly introduced attribute.

This does modify the report builder, but minimal changes over in the api repo are necessary to plug up this hole over there.

Copy link
Contributor

@d-m-u d-m-u left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this is excellent, it looks perfectly cromulent

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some thoughts about making this a bit more robust and avoid some smells. I think the concept is fine though, so feel free to push back if you think these suggestions are invalid.

lib/miq_expression.rb Outdated Show resolved Hide resolved
@kbrock
Copy link
Member Author

kbrock commented Oct 9, 2020

I think the preferred way to do this is to use private instead of adding yet more metadata - but I felt like turning all these fields private has some unknown consequences

@kbrock kbrock force-pushed the hidden_attributes branch 2 times, most recently from 9022920 to e9aaf79 Compare October 12, 2020 17:34
lib/miq_expression.rb Outdated Show resolved Hide resolved
@Fryguy
Copy link
Member

Fryguy commented Oct 12, 2020

I like this idea... seems like a decent compromise over straight private. In that sense, can we name it private_attribute or perhaps even better private_virtual_attribute (since I assume we'll never want to hide regular attributes - though password does come to mind 😉 )

@d-m-u
Copy link
Contributor

d-m-u commented Oct 15, 2020

yea so models that inherit from the ActsAsArModel aren't going to work with this as it is now

@kbrock kbrock force-pushed the hidden_attributes branch 2 times, most recently from c0f9097 to 35c92d3 Compare October 23, 2020 23:59
lib/extensions/ar_visible_attribute.rb Outdated Show resolved Hide resolved
lib/extensions/ar_visible_attribute.rb Outdated Show resolved Hide resolved
lib/extensions/ar_visible_attribute.rb Show resolved Hide resolved
spec/lib/extensions/ar_visible_attribute_spec.rb Outdated Show resolved Hide resolved
@NickLaMuro
Copy link
Member

NickLaMuro commented Nov 16, 2020

Just pushed whitespace fix...

This doesn't sound like a just a whitespace fix...

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Took a peek at the tests, which look good and I think are a solid/clever way of testing without mucking with "un-privatizing" methods after each test.

Regarding Jason's feedback, I will leave that discussion to him. I can see both sides of that argument, so I don't have a strong opinion one way or the other.

@@ -909,7 +909,7 @@ def self.build_relats(model, parent = {}, seen = [])
parent[:class_path] ||= model.name
parent[:assoc_path] ||= model.name
parent[:root] ||= model.name
result = {:columns => model.attribute_names, :parent => parent}
result = {:columns => model.public_attribute_names, :parent => parent}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public_attribute_names is a good addition here, and really cleaned this up. 👍

Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the name private_attribute because it makes me think that the attribute will act like a private method (unusable to public callers), maybe hidden_attribute would be better? Or built into deprecate_attribute as deprecated_attributes on the class? 🤷‍♂️

Overall, I like the idea of having a way to list the non-deprecated (public) attributes on a model. 👍

@kbrock
Copy link
Member Author

kbrock commented Nov 16, 2020

maybe hidden_attribute would be better?
-- @bdunne

<3 I agree and that is the original name. [ref]

But I just want the thing merged and am good with any name that people pick.
(the branch name also suggests my agreement with your statement)

@kbrock
Copy link
Member Author

kbrock commented Nov 17, 2020

I had this in deprecated attribute mixin. But the original intent was to hide new virtual attributes

@kbrock
Copy link
Member Author

kbrock commented Nov 17, 2020

@miq-bot cross-repo-tests #20664

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Nov 17, 2020
@kbrock
Copy link
Member Author

kbrock commented Nov 17, 2020

for this pr, lets test across many repos (trying to get a handle on how this bot stuff works)

@miq-bot cross-repo-tests manageiq-ui-classic, manageiq-api, ManageIQ/manageiq-providers-amazon, ManageIQ/manageiq-providers-azure, ManageIQ/manageiq-providers-ibm_cloud, ManageIQ/manageiq-providers-kubernetes, ManageIQ/manageiq-providers-openstack, ManageIQ/manageiq-providers-vmware

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Nov 17, 2020
Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised to the customer
     as attributes to use.

After this change, the attributes are still accessible. Just these attributes
are no longer advertised on the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532

Hide deprecated and duplicate attributes.

Some virtual_attributes are not needed in reporting nor the api.
Some deprecated attributes should not be advertised for customers to use.

After this change, the attributes are still accessible. So nothing will break, but
these attributes are no longer advertised in the public apis (i.e.: report builder and rest api).

This allows us to control which parts of our models are exposed.

This fixes ManageIQ#18130
This enables ManageIQ#20532
@kbrock
Copy link
Member Author

kbrock commented Dec 8, 2020

status: cross repo failure was because this PR is against an older version of the code base
Just pushed a rebase and those should be fixed

@kbrock
Copy link
Member Author

kbrock commented Dec 8, 2020

@miq-bot cross-repo-tests manageiq-ui-classic, manageiq-api, ManageIQ/manageiq-providers-amazon, ManageIQ/manageiq-providers-azure, ManageIQ/manageiq-providers-ibm_cloud, ManageIQ/manageiq-providers-kubernetes, ManageIQ/manageiq-providers-openstack, ManageIQ/manageiq-providers-vmware

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Dec 8, 2020
@Fryguy
Copy link
Member

Fryguy commented Dec 8, 2020

I had this in deprecated attribute mixin. But the original intent was to hide new virtual attributes

Ahhhh...my original intent was for it to act more like private (ref & ref). This is probably why I was confused here.

However, I'm good if your intent is to act more like hidden. If that's the case, then I agree that hidden_attribute makes more sense as a name.

EDIT: Apologies for the super-late reply (I do realize my comment makes some annoying changes)

@kbrock
Copy link
Member Author

kbrock commented Dec 8, 2020

right about now is when I wish my git-fu were not as good and I had an earlier commit with the hidden word in it (rather than rebasing and the changes I made)

coming right up

UPDATE: huh. for some reason I had the rename as a separate commit. Only had to add the fixes to this one (for the children tests).

@miq-bot
Copy link
Member

miq-bot commented Dec 8, 2020

Checked commits kbrock/manageiq@a926389~...151b057 with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint
8 files checked, 0 offenses detected
Everything looks fine. 👍

@kbrock
Copy link
Member Author

kbrock commented Dec 8, 2020

@bdunne and @Fryguy is this closer to what we want?

Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@bdunne bdunne merged commit a571d97 into ManageIQ:master Dec 8, 2020
@bdunne bdunne assigned bdunne and unassigned NickLaMuro Dec 8, 2020
@Fryguy
Copy link
Member

Fryguy commented Dec 8, 2020

cc @agrare ... wonder if we can start using this to hide the support features stuff.

@kbrock kbrock deleted the hidden_attributes branch December 8, 2020 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExtManagementSystem: Multiple columns called "Total Memory"
7 participants