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

Attach detach cloud volume form (simplified) #1149

Merged
merged 1 commit into from
Apr 20, 2022

Conversation

MelsHyrule
Copy link
Member

Required for upgrading _attach.html.haml and _detach.html.haml to react as per 7603.

Introduces the attach_resource and detach_resource endpoints for cloud volumes.

This PR is a more simplified version of work done on 1141. Here we have not yet introduced the work done to make options more generic. That logic needs further testing and for the purposes of this PR falls slightly out of scope.

@miq-bot add-reviewer @kbrock
@miq-bot add-reviewer @agrare
@miq-bot add-reviewer @kavyanekkalapu
@miq-bot assign @kavyanekkalapu

@MelsHyrule MelsHyrule requested a review from bdunne as a code owner April 18, 2022 17:57
@miq-bot miq-bot requested review from kbrock and agrare April 18, 2022 17:58
@miq-bot
Copy link
Member

miq-bot commented Apr 18, 2022

@MelsHyrule Cannot add the following reviewer because they are not recognized: kavyanekkalapu

@miq-bot
Copy link
Member

miq-bot commented Apr 18, 2022

@MelsHyrule 'kavyanekkalapu' is an invalid assignee, ignoring...

Comment on lines 577 to 581
if resource.try(:params_for_attach) ## TODO can we make this one line?
render_options(type, :form_schema => resource.params_for_attach)
else
render_options(type, :form_schema => {}) ## {:fields => []}
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if resource.try(:params_for_attach) ## TODO can we make this one line?
render_options(type, :form_schema => resource.params_for_attach)
else
render_options(type, :form_schema => {}) ## {:fields => []}
end
render_options(type, :form_schema => resource.try(:params_for_attach) || {})

Copy link
Member

Choose a reason for hiding this comment

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

I think that should get you to a single line as per your TODO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 37 to 38
action = params["option_action"] || "update"
send("render_#{action}_resource_options", id)
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned here that someone might pass a strange option_action, which could bypass security in the future. Not sure if it's better to whitelist attach and detach or just have separate calls out to render_attach_resource_options render_update_resource_options.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was something that slipped through from the other PR in the split, it will not be merged here so we can look into it more in the other PR https://github.com/ManageIQ/manageiq-api/pull/1141/files#diff-ff1fde5895f3426d678a7f5731cc08c27f3602cda6453a66677502b4731f5173R37-R38

Comment on lines 572 to 583
def render_attach_resource_options(id)
type = @req.collection.to_sym
resource = resource_search(id, type)
raise BadRequestError, resource.unsupported_reason(:attach_volume) unless resource.supports?(:attach_volume)

if resource.try(:params_for_attach) ## TODO can we make this one line?
render_options(type, :form_schema => resource.params_for_attach)
else
render_options(type, :form_schema => {}) ## {:fields => []}
end
end

Copy link
Member

Choose a reason for hiding this comment

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

Hey @MelsHyrule I thought for this simplified version we were going to drop the OPTIONS / params_for_attach and take care of that in a follow-up

Copy link
Member Author

Choose a reason for hiding this comment

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

This function slipped through the cracks when i was simplifying, it's not being used or called so ill remove it now

Comment on lines 37 to 38
action = params["option_action"] || "update"
send("render_#{action}_resource_options", id)
Copy link
Member

Choose a reason for hiding this comment

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

Don't think you're using these options either right now

@MelsHyrule MelsHyrule requested a review from agrare April 19, 2022 13:52
@MelsHyrule MelsHyrule force-pushed the attach_detach_api branch 2 times, most recently from e542fd9 to bb39a1a Compare April 19, 2022 13:56
@MelsHyrule MelsHyrule requested a review from Fryguy April 19, 2022 13:59
config/api.yml Outdated
@@ -801,6 +801,10 @@
:identifier: cloud_volume_backup_create
- :name: restore_backup
:identifier: cloud_volume_backup_restore
- :name: attach
Copy link
Member

Choose a reason for hiding this comment

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

it may make things simpler to call this :attach_volume

I like the name :attach, but since CloudVolume. supports :attach_volume, the consistency may help things.

Not sure if someone else has an opinion here.

huh. Looks like we forgot to add the base case CloudVolume.supports_not :attach_volume

Copy link
Member

Choose a reason for hiding this comment

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

@MelsHyrule MelsHyrule force-pushed the attach_detach_api branch 2 times, most recently from 42903ad to 5017def Compare April 19, 2022 19:34
@MelsHyrule MelsHyrule requested a review from kbrock April 19, 2022 19:35
@miq-bot
Copy link
Member

miq-bot commented Apr 19, 2022

Checked commit MelsHyrule@7e7af8d with ruby 2.6.9, rubocop 1.19.1, haml-lint 0.35.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@agrare
Copy link
Member

agrare commented Apr 20, 2022

LGTM, @kbrock ?

@agrare agrare merged commit 6308f34 into ManageIQ:master Apr 20, 2022
@kbrock kbrock mentioned this pull request Apr 20, 2022
3 tasks
@kbrock kbrock mentioned this pull request Jun 10, 2022
1 task
@Fryguy Fryguy mentioned this pull request Dec 22, 2022
18 tasks
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.

5 participants