-
Notifications
You must be signed in to change notification settings - Fork 985
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
fixes #9031 - Add routes to view template_combinations per hostgroup / env #2259
Conversation
Environment.authorized(:view_templates).find(params[:environment_id]) rescue nil | ||
end | ||
|
||
def requested_resource |
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.
Is it possible to use the find_*_nested_object
support in the API base controller here? It looks like you'd just specify allowed_nested_id and it could look up the base object.
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.
Done
@@ -28,6 +41,16 @@ def create | |||
def show | |||
end | |||
|
|||
api :PUT, "/config_templates/:config_template_id/template_combinations/:id", N_("Update template combination") | |||
api :PUT, "/hostgroups/:hostgroup_id/template_combinations/:id", N_("Update template combination") | |||
api :PUT, "/environments/:environment_id/template_combinations/:id", N_("Update template combination") |
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 need to define :config_template_id/hostgroup_id etc. They're already on the actions above, so I'd suggest creating a param_group and using that on all three actions to avoid copy/pasting it a third time.
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.
Done, though I really wanted to copy and paste three times
end | ||
|
||
api :POST, "/config_templates/:config_template_id/template_combinations", N_("Add a template combination") | ||
api :POST, "/hostgroups/:hostgroup_id/template_combinations", N_("Add a template combination") | ||
api :POST, "/environments/:environment_id/template_combinations", N_("Add a template combination") |
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.
These routes don't seem to work, they're not listed in rake routes
for me and I get: ActionController::RoutingError (No route matches [POST] "/api/v2/environments/production/template_combinations")
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.
Seems to work now.
Weird, my |
@config_template = ConfigTemplate.authorized(:view_templates).find(params[:config_template_id]) rescue nil | ||
end | ||
|
||
def requested_resource |
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.
Is this necessary any more? It looks like find_parent_config_template is handled by the nested resource filter, and that the "return not_found" part could be handled by using find_required_nested_obj rather than optional. Or is there a subtle difference?
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 is necessary, the subtle difference is that we'd like to return one of config_template OR nested_obj as the resource for the template combination (tests fail w/o assigning this resource).
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.
Sorry, I don't think I was clear by putting this comment on the wrong line. I meant to ask whether find_parent_config_template
is required, because config_template_id is in the allowed_nested_id list. Then everything is handled via the nested object lookup in the base controller, and all we need nested_obj
.
e.g. domcleal@a298ae5
Tests pass for me, but to be honest, they're not very thorough...
@@ -36,9 +62,13 @@ def destroy | |||
end | |||
|
|||
def find_parent_config_template |
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.
also unused? I can't see any references to @config_template
, I'm pretty sure it's all going through nested_obj
now.
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.
Actually @config_template
is used and is required by :index, :create
(failing without it.)
I tried to removed it, as I thought it will be through nested_obj
but those actions require it.
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.
I see in your link that this filter's called, but both methods called nested_obj
. It seems to work here when I comment out the filter, what error do you see?
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.
The error I see is me forgetting to remove the before_filter
😳
…hostgroup / environment
Merged as ee66b3a, thanks @shlomizadok. |
Created under
/api/v2/hostgroups/:id/template_combinations
and/api/v2/environments/:id/template_combinations
, as it seems more reasonable.I have also added the option to update template combinations.