Add support for thirdparty resource watch/create/put and delete operations#216
Conversation
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
=======================================
Coverage 94.56% 94.56%
=======================================
Files 9 9
Lines 681 681
=======================================
Hits 644 644
Misses 37 37Continue to review full report at Codecov.
|
|
How do I name the classes in swagger? So that we don't get something like DefaultAPi as the api_instance object? |
|
@jonathan-kosgei add a tag to operations. Look at our swagger.json for examples. |
| with open('thirdpartypaths.json', 'r') as third_party_spec_file: | ||
| third_party_spec = json.loads(third_party_spec_file.read()) | ||
| for path in third_party_spec.keys(): | ||
| spec['paths'][path] = third_party_spec[path] |
There was a problem hiding this comment.
Can you just add a validation here to make sure we are not overwriting an existing path?
|
one nit comment. Let me know when you added the tags for better naming and one example. This looks good so far. (btw, use |
|
Awesome tip. Thanks. Pushing changes, including a example. I'll add a few more as I go along. |
| from kube_resource.rest import ApiException | ||
| from pprint import pprint | ||
|
|
||
| with open('/var/run/secrets/kubernetes.io/serviceaccount/token', 'r') as token_file: |
There was a problem hiding this comment.
Please use load_kube_config like other examples.
| resource = 'repos' | ||
| fqdn = 'git.k8s.com' | ||
|
|
||
| body = json.loads('{ "apiVersion": "git.k8s.com/v1", "kind": "RePo", "metadata": { "name": "blog-repo" }, "repo": "github.com/user/my-blog", "oauth": 123456789, "branch": "master", "key": "user-git-deploy-secret", "path": "/path/in/volume", "image": "image to run job in", "then": "hugo --destination=/home/user/hugosite/public", "pvc": "persistent-volume-claim", "username": "repo username", "password": "repo password"}') |
There was a problem hiding this comment.
I would just make it a python map. The syntax is almost identical to json.
| kube_resource.configuration.api_key['Authorization'] = token | ||
| kube_resource.configuration.api_key_prefix['Authorization'] = 'Bearer' | ||
| kube_resource.configuration.ssl_ca_cert = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt' | ||
| api_instance = kube_resource.DefaultApi() |
There was a problem hiding this comment.
I thought you renamed DefaultAPi using tags?
| "summary": "Gets Resources", | ||
| "description": "Returns a list of Resources", | ||
| "tags": [ | ||
| "thirdparty_v1" |
There was a problem hiding this comment.
Name Suggestion : third_party_resource?
|
Look like there are some formatting error too. Use script/update-pep8.sh |
|
On it. |
|
This is something I would really like so that I can use the python client to create a custom operator. Will this be merged/released soon? Is there a current way to watch a specific third party resource I create in version 2.0 as a stop gap? |
|
@jonathan-kosgei any update on this? Can I help with anything? |
|
The code looks good. I will Squash and merge after tests passed. |
|
Hi @pvdvreede Sorry, got caught up with work, fixed |
|
Great! Thanks very much! Hopefully a new release can be done soon? |
|
@jonathan-kosgei The client needs to be updated with the new yaml changes. I will send a follow up PR tomorrow for that. |
|
Thanks @mbohlool I gave this a go last night and used the master branch. It errored saying there was no |
|
I think probably the client needs to be regenerated? @mbohlool |
Fixes #201