-
Notifications
You must be signed in to change notification settings - Fork 223
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 #38241 - Extend userdata API by MAC address endpoint #912
base: develop
Are you sure you want to change the base?
Conversation
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.
Refs #34887
That issue has been closed and already a Fixed in release
version that went out so you can't use Refs
for that. Please open a new issue.
2cd7c55
to
9c711de
Compare
9c711de
to
cc8044a
Compare
cc8044a
to
4c295e8
Compare
Thanks a lot for the fast responses! @ekohl |
f38d5a1
to
9ec90d9
Compare
|
||
get "/:mac/:kind" do |mac, kind| | ||
log_halt(500, "Failed to retrieve #{kind} userdata template for #{params.inspect}: ") do | ||
Proxy::Templates::UserdataProxyRequest.new.get([mac, kind], request.env, params) |
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.
Looking at the method this feels like an abuse of the API:
def get(kind, env, params) |
Technically it may work since it calls flatten
, but I really don't like flatten
because it ends up being really unpredictable what gets called.
But that's probably not the real issue. If you look at ProxyRequest
you can see it copies the parameters while removing a blacklist:
smart-proxy/modules/templates/proxy_request.rb
Lines 30 to 33 in 6624f2c
opts = params.clone.merge(:url => template_url) | |
BLACKLIST_PARAMETERS.each do |blacklisted_parameter| | |
opts.delete(blacklisted_parameter) | |
end |
Looking at that blacklist, we can see kind
is in there:
BLACKLIST_PARAMETERS = ['path', 'template', 'kind', 'hostgroup', 'splat', 'captures'] |
I suspect both mac
and kind
are in params
. Not entirely sure what the correct thing to do here, but this whole API feels awkward.
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.
Alright, I see why hostgroup
and template
don't need to be added in the test - thanks!
However, to make this API feel less awkward I see two improvements currently:
a.) Add another function in UserdataProxyRequest
to mitigate the flatten
here?
Like a def get_mac
and then put the mac
as mandatory function parameter? But, this makes it less generic..
b.) Overwrite BLACKLIST_PARAMETERS when inheriting ProxyRequest
and add mac
there?
What do you think?
Make the Smart Proxy Userdata API endpoint consistent with the Foreman API which was extended in #34887 (46ca3e70).
9ec90d9
to
a64822c
Compare
Extend the proxy API to match the userdata API of foreman: theforeman/foreman#9213