feat(kube): Convert kube_openapi Resource to DynamicObject #180

Merged
johnride merged 1 commits from feat/kube_convert_dynamic_resource into master 2025-11-05 21:48:32 +00:00
Owner

Utility function to allow initializing strongly typed resources and then bundle various types into a list of DynamicObject

Utility function to allow initializing strongly typed resources and then bundle various types into a list of DynamicObject
johnride added 1 commit 2025-10-29 21:27:46 +00:00
letian reviewed 2025-11-03 14:58:37 +00:00
@ -0,0 +115,4 @@
secret.metadata.namespace = Some("false".to_string());
let modified_value = serde_json::to_value(&secret).expect("Failed to serialize Secret");
assert_ne!(modified_value, dynamic_value);
Owner

What's the purpose of these 3 last lines? They don't really seem relevant for this test, it's basically testing serde_json::to_value and not kube_resource_to_dynamic

What's the purpose of these 3 last lines? They don't really seem relevant for this test, it's basically testing `serde_json::to_value` and not `kube_resource_to_dynamic`
Author
Owner

I know it looks this way but I feel more comfortable having them in.

We're completely dependent on the serialized values for the "real" assertion above and I've often seen cases where the value just ended up being empty or missing some relevant field so assert_eq!(empty, empty) is true and the tests passes. But if for some reason the serialization implementation of the kube::Resource changes to exclude the metadata field or something like that we would be broken without a test failing.

I know I'm kind of splitting hair but I'm just speaking from experience even if I can't explain it that well.

I know it looks this way but I feel more comfortable having them in. We're completely dependent on the serialized values for the "real" assertion above and I've often seen cases where the value just ended up being empty or missing some relevant field so assert_eq!(empty, empty) is true and the tests passes. But if for some reason the serialization implementation of the kube::Resource changes to exclude the metadata field or something like that we would be broken without a test failing. I know I'm kind of splitting hair but I'm just speaking from experience even if I can't explain it that well.
letian reviewed 2025-11-03 15:02:01 +00:00
@ -0,0 +178,4 @@
.unwrap(),
"nginx".to_string()
);
}
Owner

I'm not sure about the value of these 2 last assertions. The main assert assert_eq!(original_value, dynamic_value) already validates this.

I'm not sure about the value of these 2 last assertions. The main assert `assert_eq!(original_value, dynamic_value)` already validates this.
Author
Owner

It does not validate "this" directly, it just validates that the serde Serialize implementation returns equal values for original and dynamic. For all we know they could be empty. I want to make sure they contain the actual correct data, that the dynamic type truly contains the fields expected.

It does not validate "this" directly, it just validates that the serde Serialize implementation returns equal values for original and dynamic. For all we know they could be empty. I want to make sure they contain the actual correct data, that the dynamic type truly contains the fields expected.
letian approved these changes 2025-11-03 15:04:39 +00:00
letian left a comment
Owner

After checking my comments 👍

After checking my comments 👍
letian changed title from feat(kube): Utility function to convert kube_openapi Resource to DynamicObject. This will allow initializing resources strongly typed and then bundle various types into a list of DynamicObject to feat(kube): Convert kube_openapi Resource to DynamicObject 2025-11-03 15:10:59 +00:00
Author
Owner

I am merging, we can continue the conversation later.

I am merging, we can continue the conversation later.
johnride merged commit 4ff57062ae into master 2025-11-05 21:48:32 +00:00
johnride deleted branch feat/kube_convert_dynamic_resource 2025-11-05 21:48:33 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: NationTech/harmony#180
No description provided.