Repository navigation
Fixes #38182 - Delete multiple locations from comma-separated --id - #662
anandjambhulkar wants to merge 1 commit into
Conversation
|
Are we absolutely sure this is a good idea? This would introduce an inconsistency where some options accept |
ofedoren
left a comment
There was a problem hiding this comment.
Even though the issue suggests for this option to support multiple ids, it's not something that we do. For multiple ids we have --<resource>-ids options where applicable.
This command maps the API endpoint: 1 location deletion per 1 call. Same applies to this command. In other words: this is not the solution.
When I re-read the issue, it says that this option is a bit confusing since it doesn't check for the actual value was provided, and implicitly takes the first number it can.
For that reason, we have option normalizers, such as https://github.com/theforeman/hammer-cli/blob/master/lib/hammer_cli/options/normalizers.rb#L200
Ideally this option should already have some automatically assigned normalizer/validator per API description, so the same id value can be used for API call directly or as option in hammer. Currently, the endpoint documents this as identifier: https://github.com/theforeman/foreman/blob/develop/app/controllers/concerns/api/v2/taxonomies_controller.rb#L90, which means this: https://github.com/theforeman/foreman/blob/develop/config/initializers/apipie.rb#L123
If we really want to fix this properly, we shouldn't just add support for multiple ids for this option, we need to ensure this option behaves the same way as the corresponding API param. Worst case, I'd image this option being "hardcoded" as numerical, but it's also worth revisiting the API side and actually check/ask: do we really need/support identifier type as location ids.
|
Hello @adamruzicka @ofedoren. Thanks for the clarification — I misunderstood the issue as “support multiple deletes,”. However, the real problem is that --id , is accepted and only the first id is used. |
|
Thanks, @anandjambhulkar !
More or less -- yes. My only concern that API documents this parameter/option as So in other words: API is the source of truth hammer must follow. If API accepts strings as IDs, hammer should also. You can take a look how we deal with other such parameters/options. |
Summary
hammer location delete --id 4,5now deletes each listed location--idand--namebehavior is unchangedRelated issue
Fixes https://projects.theforeman.org/issues/38182
Test plan
hammer location delete --id <id1>,<id2>deletes both--idstill works--namestill worksbundle exec rake test TEST=test/functional/location_test.rb