Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/hammer_cli_foreman/smart_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ListCommand < HammerCLIForeman::ListCommand
field :status, _("Status")
field :url, _("URL")
field :_features, _( "Features"), Fields::List, :hide_blank => true
field :unrecognized_features, _("Unrecognized features"), Fields::List, :hide_blank => true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for the sake of consistency (even if it's painful for the eyes)

Suggested change
field :unrecognized_features, _("Unrecognized features"), Fields::List, :hide_blank => true
field :_unrecognized_features, _("Unrecognized features"), Fields::List, :hide_blank => true

end

def extend_data(proxy)
Expand All @@ -31,10 +32,18 @@ class InfoCommand < HammerCLIForeman::InfoCommand
field :name, _('Name')
field :version, _('Version')
end
collection :_unrecognized_features, _("Unrecognized features"), :hide_blank => true do
field :name, _('Name')
end
HammerCLIForeman::References.taxonomies(self)
HammerCLIForeman::References.timestamps(self)
end

def extend_data(proxy)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd move it to the list command's extend_data and merge that:

# L19
def extend_data(proxy)
  proxy['_features'] = proxy['features'].map { |f| f['name'] } if proxy['features']
  proxy['_unrecognized_features'] = proxy['unrecognized_features'].map { |f| f['name'] } if proxy['unrecognized_features']
  proxy
end

Info command here expects "correct" or "expected" response with features, that's why we don't have _ workaround, but for list command we do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For features the api returns a list of hashes, which we can use as-is in info and which we have to transform for list. For unrecognized, it is the other way around - the api gives a flat list which we can use as-is in list, but have to transform it info. That's where the asymmetry comes from. I can try messing with it a bit more, but it will probably never be as clean as we'd like

proxy['_unrecognized_features'] = proxy.delete('unrecognized_features').map { |f| { 'name' => f } } if proxy['unrecognized_features']
proxy
end

build_options
end

Expand Down
Loading