-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
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 37 Continue 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. |
scripts/preprocess_spec.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you renamed DefaultAPi using tags?
scripts/thirdpartypaths.json
Outdated
"summary": "Gets Resources", | ||
"description": "Returns a list of Resources", | ||
"tags": [ | ||
"thirdparty_v1" |
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.
Name Suggestion : third_party_resource?
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.
third_party_resources
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