-
Notifications
You must be signed in to change notification settings - Fork 220
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 #12568 - Add module versions to /version #343
Conversation
@@ -34,4 +34,9 @@ def test_version | |||
get "/version" | |||
assert_equal({"version" => Proxy::VERSION}, JSON.parse(last_response.body)) | |||
end | |||
|
|||
def test_version_header | |||
get "/version" |
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 would test another path :) but 👍
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 would work only with /version
and /features
. I guess I could add another test for features too
what about plugin versions? |
Please use a new Redmine ticket under the smart proxy project, not a Foreman one (http://projects.theforeman.org/projects/foreman/wiki/Reviewing_patches-commit_message_format#Notes). |
Why adding a header -- we already have |
I agree, and if we are going to touch the version, then imho we should also
include plugin versions. (or per feature)
|
|
i think while you might be right, we might need to do conditional info per
API call, therefore it does make sense to have the version handy. (instead
of saving it on foreman db or similar).
we already do the same in foreman.
|
@ohadlevy: not sure I'm following. You mean you want to track incompatible api changes via plugin versions? It's one way to do it, but this is going to turn messy in no time. I would suggest implementing proper api versioning; I think it will have to be per-module though. |
I like the header because I was actually about to submit similar functionality for discovery image (http://projects.theforeman.org/issues/12412). The problem FDI have is I need to find out which endpoint is FDI configured with - if its a proxy or foreman instance. My idea is to keep the header and also add one extra one: "Foreman_Endpoint" with hardcoded "smart-proxy" in it? I could do similar patch in Foreman Core returning "foreman" so single GET / would easily give us information if this is Foreman or Proxy. Another option would be to create a "status" or "version" call with same paths on both, but the header approach looks like a better one to me. Opinions? |
Nitpick: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html looks like headers follow this naming conventions:
|
Again, what are we trying to accomplish? If we need module version information (to show it to users, for example), I suggest extending If we need versioned API, then I would be in favour of using headers, but these should be separate from module versions:
In short, I don't want to piggyback on module version information to track API changes; data representations such as http headers and json are employed for different purposes, let's use them accordingly. |
I agree with @witlessbird. [
"dhcp",
"dns",
"openscap",
"tftp",
{
"versions": [
{
"openscap": "0.5.0"
},
{
"foreman_proxy": "1.11.0"
},
{
"dns": "1.11.0"
},
{
"tftp": "1.11.0"
},
{
"dhcp": "1.11.0"
}
]
}
] Does that make sense? |
@shlomizadok: good point; This is still incompatible though. I think
|
8d4fbdc
to
d125208
Compare
@witlessbird - I have added the module versions to |
@shlomizadok: nods, pls. drop the header. |
d125208
to
958cda2
Compare
Done. 👍 - thanks for the review @witlessbird |
get "/version" | ||
assert_equal({"version" => Proxy::VERSION}, JSON.parse(last_response.body)) | ||
assert_equal(Proxy::VERSION, JSON.parse(last_response.body)["version"]) | ||
modules = Hash[::Proxy::Plugins.enabled_plugins.collect {|plugin| [plugin.plugin_name.to_s, plugin.version.to_s]}].reject { |key| key == 'foreman_proxy' } |
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 know exactly what you are getting back (you stubbed enabled_plugins
method). You can hardcode the expected reply, which, I think, will read better.
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.
Right, but hard-coding will enforce me to change if the stubbing ever changes.
I think it is ok to leave this as is
{:version => Proxy::VERSION}.to_json | ||
content_type :json | ||
modules = Hash[::Proxy::Plugins.enabled_plugins.collect {|plugin| [plugin.plugin_name.to_s, plugin.version.to_s]}].reject { |key| key == 'foreman_proxy' } | ||
{:version => Proxy::VERSION, :modules => modules}.to_json |
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.
Q: does this means we are breaking the API ? what about foreman code where the proxies are not updated, should we start talking about API versions?
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.
Adding another key to this hash shouldn't break existing clients: they expect hash, but are only aware of :version key, which remains. Newer clients can use both keys.
We should probably add versioning to api; if anything, this would give plugin authors more freedom/flexibility to make breaking changes in their api.
Merged in 1128d93. Thanks, @shlomizadok! |
Adds header
Proxy_version
to RootApi calls (/features
,/version
) so it could be later used to display in Foreman see #12605