-
Notifications
You must be signed in to change notification settings - Fork 143
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
Use standard create/update/delete features for Authentications #1220
Use standard create/update/delete features for Authentications #1220
Conversation
3e4ae01
to
7ca006f
Compare
klass = ::Authentication.descendant_get(attrs['type']) | ||
ensure_supports(type, klass, :create) |
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.
Darn, this is very close to the api_resource
model.
almost like we want to define:
def resource_search(id, type)
::Authentication.descendant_get(type)
end
def create_resource(type, _id, data)
api_resource(type, nil, "Creating", :supports => :create) do |klass|
manager_resource, attrs = validate_auth_attrs(data)
{:task_id => klass.create_in_provider_queue(manager_resource.id, attrs.deep_symbolize_keys)}
end
end
But may need to fall back to api_action
.
Now that I think about it, I had refactored this method a number of times.
Never got it quite right.
This is a definite improvement.
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.
ooh, right
I kept splitting apart the validate_auth_attrs
:
def create_resource(_type, _id, data)
type, id = data_resource(data)
# maybe attrs from data_resource ?
api_resource(type, id, "Creating", :supports => :create) do |auth, klass|
{:task_id => klass.create_in_provider_queue(auth.id, attrs.deep_symbolize_keys)}
end
end
def data_resource(data)
href = Href.new(data['manager_resource']['href'])
raise 'invalid manager_resource href specified' unless href.subject && href.subject_id
[href.subject, href.subject_id]
end
nvr mind. there is a reason I never created a PR for this.
the tests turned out very nicely. I think getting to I think I have refactored this a number of times but got derailed with so many changes across the other controllers. Lets do as much as you want here but get it in. The changes to the tests really show that you are on the right track. |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
@agrare un-WIP if you ready to merge this one. There was only one suggestion for |
Hey thanks for the nudge @kbrock let me rebase this and see if it still passes specs |
7ca006f
to
8e86202
Compare
8e86202
to
a6bb13d
Compare
Checked commit agrare@a6bb13d with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint spec/requests/authentications_spec.rb
spec/requests/configuration_script_payloads_spec.rb
|
kicking. I want this in |
Not all authentications are tied to a provider, so will this change prevent any operations on those? I'm asking because I thought this one was "special" for exactly this reason. |
This still doesn't require authentications to be tied to a provider, previously we used only the presence of a |
@kbrock @Fryguy I still need to update the providers to ensure they have the correct supports set, realizing now that is why I had it WIP before #1220 (comment) |
can you restate this? |
We have We need to find all authentication classes that define these methods but not corresponding |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
re: WIP I think ManageIQ/manageiq#22894 is the only change needed. It does not require a change in the class listed. (though I did add a caveat that adding to each of the child leaf nodes is an option) |
@kbrock I think this is the list
So your PR ManageIQ/manageiq#22894 covers the EmbeddedAnsible ones, so we just need ManageIQ/manageiq-providers-awx#24 |
Move the
/api/authentications
endpoint towards using standard create/update/delete supports features rather than checking for specific methods.The goal is to use the standard
create_ems_resource
andems_resource
actions hereDepends on: