-
Notifications
You must be signed in to change notification settings - Fork 292
CA-245333: changes to facilitate autogeneration of historical releases in API derivatives #3038
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
Conversation
This PR has to be merged together with xapi-project/xen-api-sdk#95 to prevent build breakage. |
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.
Some small improvements needed when working with files.
ocaml/doc/jsapi.ml
Outdated
let templ = Mustache.of_string (String.concat "\n" lines_read) in | ||
let rendered = Mustache.render templ json in | ||
let out_chan = open_out output_file in | ||
finally (fun () -> Printf.fprintf out_chan "%s" rendered) |
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.
This finally
does not catch any problems with open_out
or other failures in the lines above. To emit a string to a file, use output_string
:
val Pervasives.output_string: out_channel -> string -> unit
ocaml/doc/jsapi.ml
Outdated
let populate_releases templates_dir dest_dir= | ||
let infile x = Filename.concat templates_dir x in | ||
let outfile x = Filename.concat dest_dir x in | ||
let render x = render_template (infile (fst x)) json_releases (outfile (snd x)) in |
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.
When x
is a pair, it would be better to define let render (infile, outfile) =
and to use infile
and outfile
. Does it have to be a pair? These could be also passed as separate parameters.
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 doesn't have to be a pair, I just thought it's convenient for piping a list of input-output file pairs.
ocaml/idl/dm_api.ml
Outdated
let rec getlast l = (* TODO: move to standard library *) | ||
match l with [x] -> x | _::xs -> getlast xs | [] -> raise (Invalid_argument "getlast") in | ||
match l with | ||
| [x] -> x.code_name |
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 think it's not a good idea to mix a standard function (getlast
- usually called last
) with something specific here. I'd keep getlast
and work with the result at the call site:
getlast xs |> fun x -> x.code_name
I think we should also add |
@stephen-turner and/or @jonludlam could you please double check I've got the version mapping in the datamodel_types right, as there are some small inconsistencies with what we had in https://github.com/xapi-project/xen-api-sdk/blob/master/csharp/src/Helper.cs#L38 |
I'm fairly confident the ones in the current SDK are correct. I notice you sometimes have two different "releases" with the same API version: the SDK wouldn't know about those, of course. |
These are filtered out, please compare to xapi-project/xen-api-sdk#95 |
ocaml/doc/jsapi.ml
Outdated
|
||
let render_template template_file json output_file = | ||
let lines_read = Stdext.Unixext.read_lines template_file in | ||
let templ = Mustache.of_string (String.concat "\n" lines_read) in |
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.
This could be
let templ =
Stdext.Unixext.string_of_file template_file
|> Mustache.of_string
in
This writes directly to the string, will avoid creating a list and then concatenating it.
let lines_read = Stdext.Unixext.read_lines template_file in | ||
let templ = Mustache.of_string (String.concat "\n" lines_read) in | ||
let rendered = Mustache.render templ json in | ||
let out_chan = open_out output_file in |
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 think the safest is
finally (fun () -> output_string out_chan rendered)
(fun () -> close_out out_chan)
I don't think output_string
closes the file on error.
ocaml/idl/datamodel_types.ml
Outdated
code_name = Some rel_rio; | ||
version_major = 1; | ||
version_minor = 1; | ||
branding = "XCP 0.5"; |
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.
This isn't quite right: there was no XCP before Midnight Ride. In fact, I think we should just remove the special XCP branding entirely, and have just one string, like on http://xapi-project.github.io/xen-api/releases.html. We can just keep a single version of the docs on ocaml/doc, since XCP doesn't exist anymore.
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.
Ah ok, I didn't know rio was wrong, I simply copied it from branding.js. Good to hear it can go, this means we don't need to package 2 docs versions in the server any more.
ocaml/idl/datamodel_types.ml
Outdated
branding = "XenServer 7.0"; | ||
xs_branding = "XenServer 7.0"; | ||
}; { | ||
code_name = Some rel_dundee_plus; |
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 think this is completely unused and should be removed from the datamodel. And if it is used in datamodel, then that should be fixed :)
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 is used in the datamodel, for example PVS is under dundee-plus, which means it's too late to change it :(
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.
We should just change those to ely, because that's where they were released, and dundee-plus doesn't exist.
ocaml/idl/datamodel_types.ml
Outdated
code_name = Some rel_indigo; | ||
version_major = 2; | ||
version_minor = 4; | ||
branding = "indigo (unreleased)"; |
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 think that this can be called "XenServer 6.5 SP1 Hotfix X", but we have to look up "X"...
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.
Hotfix 31
Changes Unknown when pulling 07e382e on kc284:master into ** on xapi-project:master**. |
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
ocaml/idl/datamodel.ml
Outdated
let dundee_plus_release = | ||
{ internal = get_product_releases rel_dundee_plus | ||
let ely_release = | ||
{ internal = get_product_releases rel_dundee |
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.
?
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.
Oooops! 😳
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
…I version and branding info. Thus clients and documentation generated from the API can be udpated automatically without having each time to map manually the release code name to the version or the branding, which is an error prone process Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
…enu. This solution proposes to use mustache templates which can be populated at runtime with the values defined in the datamodel. Thus we avoid duplication of definitions which may as well get out of sync. Also, removed the obsolete XCP branding. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
let dundee_plus_release = | ||
{ internal = get_product_releases rel_dundee_plus | ||
let ely_release = | ||
{ internal = get_product_releases rel_ely |
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.
OK :) I'm surprised that we didn't have ely_release
before 😕
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 can see why it might be forgotten: x_release and rel_x are in different files.
The first commit is minor refactoring. The second is needed so the SDK can autogenerate the releases without us having to re-map manually release code names to API versions and server versions. The third commit is not strictly necessary for this ticket, but it can save us some trouble (as long as it doesn't conflict with existing plans regarding the docs).
Please double check the mapping is correct, as the API version has not always been bumped between releases.