kubernetes-client / javascript

Javascript client
Apache License 2.0
2.01k stars 513 forks source link

add examples to generic api (inside object.ts) #1705

Closed zfrhv closed 3 months ago

zfrhv commented 4 months ago

solves #1595

let me know if it looks good. then I will add it to docs and maybe also use genericApi at get/apply/delete...

k8s-ci-robot commented 4 months ago

Welcome @zfrhv!

It looks like this is your first PR to kubernetes-client/javascript 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/javascript has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

brendandburns commented 4 months ago

This looks pretty good, added some small comments and it looks like you need to rebase to pick up some dependabot changes that got merged.

zfrhv commented 4 months ago

I was going to create genericApi class for get/apply/delete/create.. functions but i stumbled into object.ts, it looks like its the generic api that I was looking for. although looking at example usage it seems a bit complicated to use. still this class is exactly what I was about to make.

should I just add more example and try to use watch with object.ts instead of creating genericApi?

brendandburns commented 4 months ago

@zfrhv Thanks! I had forgotten about that. Yes, I think adding watch to that and also maybe simplifying it if you want to? That would be great!

zfrhv commented 3 months ago

I tried to combine object.ts with watch.ts but it seems too complex for me. I can create seperate watch function inside object.ts but thats just copy paste from watch.ts and it will look messy. So I tried to call the watch function from KubernetesObjectApi inside object.ts but cant figure out how to pass the Kubernetes config, it seems like its locally stored as a token and im not sure how to use it. maybe @schrodit can help to create watch inside object.ts

About the extra examples I added: i didnt tested them but i think they should work. All my k8s clusters are airgapped and testing something from the internet is pain. I wish someone else could test it for me <3

schrodit commented 3 months ago

I tried to combine object.ts with watch.ts but it seems too complex for me.

I can create seperate watch function inside object.ts but thats just copy paste from watch.ts and it will look messy.

So I tried to call the watch function from KubernetesObjectApi inside object.ts but cant figure out how to pass the Kubernetes config, it seems like its locally stored as a token and im not sure how to use it.

maybe @schrodit can help to create watch inside object.ts

About the extra examples I added: i didnt tested them but i think they should work.

All my k8s clusters are airgapped and testing something from the internet is pain.

I wish someone else could test it for me <3

I think I already did that in an internal wrapper.

Let me take a look and I open a separate PR.

zfrhv commented 3 months ago

I fixed the examples. Im not good enought to understand how to add watch function inside object.js so I will leave it to the pros

mstruebing commented 3 months ago

@zfrhv started the CI process and it seems like you have linting errors. You can see the results either in the github action logs or locally by running npm run lint

brendandburns commented 3 months ago

You can also run npm run format to fix at least some of them.

mstruebing commented 3 months ago

/lgtm /approve

Thanks for these example, I think they are very useful for new users. 🚀 As mentioned above, if you ever find the time, it would be great to port these to the release-1.x branch as well.

k8s-ci-robot commented 3 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mstruebing, zfrhv

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-client/javascript/blob/master/OWNERS)~~ [mstruebing] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment