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

Pass natural/integer preference args to openapi-to-dhall #178

Merged
merged 8 commits into from
Jan 14, 2022

Conversation

arobertn
Copy link
Contributor

@arobertn arobertn commented Nov 11, 2021

This PR addresses #177 by passing the --preferNaturalInt argument to openapi-to-dhall (under PR dhall-lang/dhall-haskell#2316) and including a list of exceptions that should actually be rendered as Dhall Integer.

The list is set based on the version in nix/nixpkgs.nix.make-dhall-kubernetes(), determined by going through the fields in the kubernetes openapi spec files manually. It turns out that there have been no major additions / removals of such fields that should be Integers within current range of versions 1.12 - 1.22, so the list is the same for all. (If a new Kubernetes version is added and a new entry is not added here, an empty argument will be passed to dhall-openapi which will trigger a build failure.)

The preferred solution in #177 that the Kubernetes project includes integer ranges in their Swagger specs is in-process (kubernetes/kubernetes#105533), but this will solve the issue in the meantime, and is isolated and easily reverted when that comes.

pass natural/integer preference args to openapi-to-dhall based on
version being generated.
@arobertn
Copy link
Contributor Author

I've now completed the implementation to utilize the functionality now upstream in dhall-haskell/dhall-openapi and checked that the list of exceptions is in fact the same for all current supported kubernetes versions.

@Gabriella439 Gabriella439 merged commit bc7719e into dhall-lang:master Jan 14, 2022
@Gabriella439
Copy link
Contributor

@arobertn: Thank you for doing this!

@arobertn arobertn deleted the openapi-integer-handling branch January 14, 2022 11:52
@arobertn
Copy link
Contributor Author

Always good to learn something by doing. Any ideas when the next release will happen?

@uthark
Copy link

uthark commented Feb 18, 2022

Generated Kubernetes manifests looks wrong.

terminationGracePeriodSeconds is uint64 in upstream, but generated manifests looks like this:

"terminationGracePeriodSeconds":30.0

Same issue with other fields

{"downwardAPI":{"defaultMode":420.0 ...

Default mode should be integer, not a float value.

@Gabriella439
Copy link
Contributor

@uthark: Are you using dhall-to-json to generate the manifests? This seems more likely to be an issue with the Dhall to JSON conversion logic than dhall-kubernetes, because currently the generated types specify Natural, which is correct: https://github.com/dhall-lang/dhall-kubernetes/search?q=terminationGracePeriodSeconds

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.

3 participants