-
Notifications
You must be signed in to change notification settings - Fork 900
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
Adding custom attributes to provider (UI + API) #10897
Conversation
67ca6a4
to
67397b7
Compare
depends on: #10896 |
defb30b
to
250a22e
Compare
CONNECTION_ATTRS = %w(connection_configurations).freeze | ||
ENDPOINT_ATTRS = %w(hostname ipaddress port security_protocol).freeze | ||
RESTRICTED_ATTRS = [TYPE_ATTR, CREDENTIALS_ATTR, ZONE_ATTR, "zone_id"] | ||
RESTRICTED_ATTRS = [TYPE_ATTR, CREDENTIALS_ATTR, ZONE_ATTR, "zone_id"].freeze |
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.
Please don't mix unrelated rubocops in the same PR and the feature itself (i.e. these freezes).
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.
Removed.
So, I think we already have methods for adding and removing custom attributes (perhaps not via the REST API). I'm not sure why we need to re-add that under a new name of "meta data" cc @gmcculloug I think you've done this before, right? |
def meta_data_resource_providers(_type, _id = nil, data) | ||
provider = ExtManagementSystem.find_by_name(data.delete("name")) | ||
data.each do |key, value| | ||
attribute = provider.custom_attributes.find_by_name(key) |
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 is an N+1. I think you can query all of the requisite attributes up front (or just query them all)
an action name of "meta_data" by itself is very strange. Since it does a full replacement (but no deletes?) I would expect an action word in the front like "update_metadata" Also,
|
Sorry, one more thing...we also have the concept of different types of custom_attributes as handled by the "source" column. So ManageIQ can have it's own custom_attributes which I think uses the |
4b4ef23
to
e9e2810
Compare
Are there tests to support that? |
7cfbf04
to
3aa1775
Compare
@abellotti fixed minor comments, @imtayadeway Yes the current tests are supporting add/edit/delete. |
@miq-bot add_label euwe/yes |
Hi @alongoldboim thanks for the updates. could you take of the rubocop warnings ? Thanks. |
👍 LGTM. Will merge once the rubocops are addressed. |
3aa1775
to
731cee8
Compare
731cee8
to
e406e78
Compare
Checked commits alongoldboim/manageiq@66b37e3~...e406e78 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
@gtanzillo Rubocop is happy now. |
Adding custom attributes to provider (UI + API) (cherry picked from commit 46277ee)
Euwe Backport details: $ git log
commit a16aedc889a2bec9e37a2530b530f46483b31d33
Author: Gregg Tanzillo <[email protected]>
Date: Thu Oct 6 11:08:03 2016 -0400
Merge pull request #10897 from alongoldboim/provider_meta_data
Adding custom attributes to provider (UI + API)
(cherry picked from commit 46277eefa4ea925a2607628c7815fbc5a8f214c0) |
For now, make the test expectations different for ruby 2.4.0+ vs. prior rubies. CustomAttribute#value_type returns a symbol for a ruby core class, a hardcoded value instead of the class's behavior. Do we use this? Why are we returning a value instead of caring about behavior of the old Fixnum and Integer? If we don't use this, we should remove the whole method and it's tests added in: ManageIQ@4687394 The PR that added this was: ManageIQ#11000 Adding CustomAttribute to provider UI/API was added in: ManageIQ#10897
New view

Added a new api endpoint:
url: http://localhost:3000/api/providers/3/custom_attributes
method: Post
Request.payload: