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

Refs #38077 - Don't build hidden params as options #634

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

ofedoren
Copy link
Member

Requires:

@adamlazik1, you might be interested in this, since it tries to use your changes in theforeman/foreman#10322.

Note: this PR includes test data from Foreman 3.14 API docs, generated using theforeman/foreman#10322.

Copy link

@adamlazik1 adamlazik1 left a comment

Choose a reason for hiding this comment

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

Can't comment on the code much but I tested it with theforeman/foreman#10322 and it works as intended.

Comment on lines 244 to 245
# require 'pry-byebug'; binding.pry if associated_resource.to_s == "location"
# parent_show_from_api = ParamsNameFilter.new("#{aliased_name}_id").for_action(@resource.action(@context[:action].to_s)).first&.show?

Choose a reason for hiding this comment

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

Suggested change
# require 'pry-byebug'; binding.pry if associated_resource.to_s == "location"
# parent_show_from_api = ParamsNameFilter.new("#{aliased_name}_id").for_action(@resource.action(@context[:action].to_s)).first&.show?

options << family.parent(
optionamize("--#{aliased_name}-id"),
"#{aliased_name}_id".upcase,
description("#{aliased_name}_id", @context[:action]),
attribute_name: HammerCLI.option_accessor_name("#{resource_name}_id"),
referenced_resource: resource_name,
aliased_resource: aliased_name,
format: HammerCLI::Options::Normalizers::Number.new
format: HammerCLI::Options::Normalizers::Number.new,
# show: parent_show_from_api ? parent_show_from_api : true

Choose a reason for hiding this comment

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

Suggested change
# show: parent_show_from_api ? parent_show_from_api : true

@ofedoren ofedoren force-pushed the refs-38077-param-with-show branch from 3471fcc to 1a88c77 Compare January 7, 2025 13:50
@ofedoren ofedoren force-pushed the refs-38077-param-with-show branch from 1a88c77 to a7ff2ad Compare January 7, 2025 13:51
@ofedoren
Copy link
Member Author

ofedoren commented Jan 7, 2025

Oops, some debug leftovers, updated.

Thanks, @adamlazik1 !

Since the PRs in Foreman and apipie-bindings got merged, could you please re-test it in case I missed something?

Copy link

@adamlazik1 adamlazik1 left a comment

Choose a reason for hiding this comment

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

Confirming that it works as intented.
Retested with hammer user-group external:
Before:

$ hammer user-group external create -h
Usage:
    hammer user-group external create [OPTIONS]

Options:
 --auth-source[-id] VALUE/NUMBER         Name/id of linked authentication source
 --location[-id|-title] VALUE/NUMBER     Set the current location context for the request
 --name VALUE                            External user group name
 --organization[-id|-title] VALUE/NUMBER Set the current organization context for the request
 --user-group[-id] VALUE                 Name/id or name of user group
 -h, --help                              Print help

After:

$ hammer user-group external create -h
Usage:
    hammer user-group external create [OPTIONS]

Options:
 --auth-source[-id] VALUE/NUMBER Name/id of linked authentication source
 --name VALUE                    External user group name
 --user-group[-id] VALUE         Name/id or name of user group
 -h, --help                      Print help

The repository in unit tests needs to be reverted before merging. Just putting it here so it is not forgotten.

@ofedoren ofedoren force-pushed the refs-38077-param-with-show branch from a7ff2ad to e3563f9 Compare January 8, 2025 10:49
@ofedoren ofedoren merged commit fd288fe into theforeman:master Jan 8, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants