infrastructure-as-types
infrastructure-as-types copied to clipboard
Generate DSL similar to k8s-kotlin-dsl based on OpenAPI defs?
Asked by @pawelprazak :
How difficult would it be to generate a DSL automatically based on OpenAPI (see iat-openapi
sbt module)?
https://github.com/fkorotkov/k8s-kotlin-dsl#complete-deployment-example
Description of the task by @pawelprazak: The idea is to provide easy to use DLS for Kubernetes API, similiar to what's here for Kotlin: https://github.com/fkorotkov/k8s-kotlin-dsl#complete-deployment-example.
Notes:
-
Skuber
as inGuestBook
example is not good enough. - Java API is unusable
- OpenAPI auto generated API as in
kubernetes/client/openapi/api
is also hard to use. - Using
ZIO
would be a good call - K8s uses metadata of objects to call API paths. https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#objects So it's possible to create path using metadata for example:
/apis/${group}/${version}/namespaces/${namespace}/{kind plural}/[${name}]
- Writing our own generator should be easier then forking https://github.com/OpenAPITools/openapi-generator
- Use scala HTTP and Json library: Sttp + circe
- Important support for K8s Custom Resources
For more information ask @pawelprazak.