Closed anthcp-infocom closed 3 years ago
I managed to get OpenShift Routes working by adding the Route components from the openapi-v3.json to your original open API file and rebuilding etc... However, to get the get_yaml() function to work properly on my OSX Mac, I had to use PyYaml as I was getting dictionary's listed in the list values as {} etc... An example of the routes... y = Route( spec=RouteSpec( to=RouteTargetReference(kind="Service", name="service-name"), host="www.example.com", path="/test", ), apiVersion="v1", kind="Route", metadata=ObjectMeta(name="route-unsecured"), )
I hadn't considered OpenShift support; I've currently been working on connecting Hikaru to the Kubernetes Python client so sending requests is a little more seamless, and was planning subsequently to improve the API in Hikaru to offer a CRUD-like experience. This is an interesting notion though, but I think the build system will need some work as there are lots of artefacts that reflect the inconsistencies in the Kubernetes swagger file. I'm happy for you to leave this as an open request, but I can't make any representations at the moment.
Hi, being inspired by what you have done, I managed to cobble a Openshift 3.11 version which I have called Pydalio... It uses Pydantic and seems to work fine for a pre-alpha and is pretty basic at the moment... Its at https://github.com/anthcp-infocom/Pydalio. I am using it at work at the moment and have integrated it into the openshift-K8s rest client...
I just came back from having a look at Pydalio; nice going. Did you modify Hikaru's build.py or did you start from scratch?
This is making me think that the builder might be something to pull out into an independent project. It will need some work to separate out the quirks from straightforward processing.
Someone else suggested pydantic as well. Pydantic is already used in the underlying Kubernetes stuff I have mixed feelings putting it into the Kubernetes Hikaru build as it feels slightly like overkill, but more importantly there are other features I'd consider activating via properties and I'm not sure that using pydantic will make those harder to put in place later.
I experimented with datamodel-codegen (https://github.com/koxudaxi/datamodel-code-generator) to convert the openapi spec Openshift 3.11 file to Pydantic python objects and found it worked a treat! From there I just build some functions as you can see to use at work to replace helm... It was your work that inspired me to do this!!!
Well cool! I guess I'll close this out then, but if you want to revisit in the future then just open again or create a new one.
Do you plan to support OpenShift? If not please ignore or delete this issue. If you do then I have converted the openshift swagger file to version 3 of the open API but it fails the build process with an error; Traceback (most recent call last): File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/anthcp/code/hikaru-oc/hikaru/build.py", line 556, in
build_it(sys.argv[1])
File "/Users/anthcp/code/hikaru-oc/hikaru/build.py", line 547, in build_it
load_stable(swagger_file)
File "/Users/anthcp/code/hikaru-oc/hikaru/build.py", line 218, in load_stable
for k, v in d["definitions"].items():
KeyError: 'definitions'
I have attached the swagger json file... openapi-v3.json.gz