Skip to content
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

Properly parse metadata of custom Kubernetes objects #1695

Merged
merged 4 commits into from
May 28, 2024

Conversation

schrodit
Copy link
Contributor

@schrodit schrodit commented May 26, 2024

Partially fixed #852 by adding a helper Seriliazer.
That serializer is aware of Kubernetes objects and parses them accordingly to a valid KubernetesObject (before some types were wrongly parsed e.g. creationTimestamp was a string instead of a Date).

Supporting custom objects will follow in a separate PR.
But the idea is that there will be a second map in the new Serializer were custom objects can be added at runtime.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 26, 2024
@schrodit
Copy link
Contributor Author

/assign brendandburns

Copy link
Member

@mstruebing mstruebing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work - only a couple of nitpicks.

I think we should port this over to release-1.x as well so that we will have it in the next major release as well.

src/serializer.ts Show resolved Hide resolved
src/serializer.ts Show resolved Hide resolved
src/serializer.ts Outdated Show resolved Hide resolved
src/serializer.ts Outdated Show resolved Hide resolved
@schrodit schrodit requested a review from mstruebing May 27, 2024 20:04
@schrodit
Copy link
Contributor Author

/assign mstruebing

@schrodit
Copy link
Contributor Author

Great work - only a couple of nitpicks.

I think we should port this over to release-1.x as well so that we will have it in the next major release as well.

Whats the process here?
Do I just open another PR for the release-1.x branch?

@mstruebing
Copy link
Member

Yes exactly, otherwise these changes will be lost once we release the new client without the request library as a replacement for the current master. You can probably reuse most of the code you've created in this PR.

Your changes looking good from my point of view - will just wait a bit for @brendandburns to have a look as well probably.

@brendandburns
Copy link
Contributor

Looks good to me also.

/lgtm

Once this merges, you can cherry-pick this against the release-1.x branch, but it may require reworking.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2024
@brendandburns
Copy link
Contributor

Looks like this is failing linting. Please fix to match our style guide.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 28, 2024
@schrodit
Copy link
Contributor Author

Looks good to me also.

/lgtm

Once this merges, you can cherry-pick this against the release-1.x branch, but it may require reworking.

ok will do that once merged

@mstruebing
Copy link
Member

mstruebing commented May 28, 2024

From the github action logs:

[warn] src/object.ts
[warn] src/serializer_test.ts
[warn] src/serializer.ts
[warn] Code style issues found in 3 files. Run Prettier to fix.

You should run: npm run format and commit the formatting changes.

@schrodit
Copy link
Contributor Author

From the github action logs:

[warn] src/object.ts
[warn] src/serializer_test.ts
[warn] src/serializer.ts
[warn] Code style issues found in 3 files. Run Prettier to fix.

You should run: npm run format and commit the formatting changes.

thanks. Pushed all changes

@mstruebing
Copy link
Member

/lgtm
/approve

Thanks 🚀

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 28, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 28, 2024
@k8s-ci-robot k8s-ci-robot merged commit 153a808 into kubernetes-client:master May 28, 2024
7 checks passed
@schrodit schrodit deleted the fix-obj-typing branch May 30, 2024 08:51
schrodit pushed a commit to schrodit/javascript that referenced this pull request May 30, 2024
Properly parse metadata of custom Kubernetes objects
@schrodit schrodit mentioned this pull request May 30, 2024
k8s-ci-robot added a commit that referenced this pull request May 30, 2024
cdrage added a commit to cdrage/podman-desktop that referenced this pull request Oct 8, 2024
### What does this PR do?

* Removes undeeded metadata objects which are not applicable / not
  needed when applying a patch. This includes resourceVersion, UID,
  selfLink and creationTimestamp. These are automatically created when
  applying a resource if undefined / blank.
* This change is needed as Kubernetes javascript client added
  serialization / checks with regards to creationTimestamps as well as
  other metadata objects from PR: kubernetes-client/javascript#1695

### Screenshot / video of UI

<!-- If this PR is changing UI, please include
screenshots or screencasts showing the difference -->

### What issues does this PR fix or reference?

<!-- Include any related issues from Podman Desktop
repository (or from another issue tracker). -->

Closes podman-desktop#9260
Closes podman-desktop#9262

### How to test this PR?

<!-- Please explain steps to verify the functionality,
do not forget to provide unit/component tests -->

- [X] Tests are covering the bug fix or the new feature

1. Edit any k8s yaml
2. Press apply
3. Success
4. Edit again
5. Press apply
6. Success

Signed-off-by: Charlie Drage <[email protected]>
cdrage added a commit to podman-desktop/podman-desktop that referenced this pull request Oct 8, 2024
### What does this PR do?

* Removes undeeded metadata objects which are not applicable / not
  needed when applying a patch. This includes resourceVersion, UID,
  selfLink and creationTimestamp. These are automatically created when
  applying a resource if undefined / blank.
* This change is needed as Kubernetes javascript client added
  serialization / checks with regards to creationTimestamps as well as
  other metadata objects from PR: kubernetes-client/javascript#1695

### Screenshot / video of UI

<!-- If this PR is changing UI, please include
screenshots or screencasts showing the difference -->

### What issues does this PR fix or reference?

<!-- Include any related issues from Podman Desktop
repository (or from another issue tracker). -->

Closes #9260
Closes #9262

### How to test this PR?

<!-- Please explain steps to verify the functionality,
do not forget to provide unit/component tests -->

- [X] Tests are covering the bug fix or the new feature

1. Edit any k8s yaml
2. Press apply
3. Success
4. Edit again
5. Press apply
6. Success

Signed-off-by: Charlie Drage <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KubernetesObjectApi does not properly return typed objects
4 participants