Repository navigation
fix(versioned): Make changedValues in tracking status optional
#1325
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
Changes from all commits
f773537
0d89cbf
35c5e47
0d81a7b
1adc8f4
7b4e824
752ac04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
Techassi marked this conversation as resolved.
Resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| use serde_json::json; | ||
|
|
||
| use crate::person::{Person, PersonStatusWithChangedValues, PersonVersion}; | ||
|
|
||
| mod person; | ||
|
|
||
| // Objects created directly in the storage version never pass through the conversion webhook, so | ||
| // their status doesn't contain any changed values. Operators must still be able to patch and read | ||
| // the status of such objects. | ||
| #[test] | ||
| fn status_does_not_require_changed_values() { | ||
| let merged_crd = Person::merged_crd(PersonVersion::V2).expect("the CRDs must be mergeable"); | ||
|
|
||
| for version in merged_crd.spec.versions { | ||
| let status_schema = version | ||
| .schema | ||
| .and_then(|schema| schema.open_api_v3_schema) | ||
| .and_then(|schema| schema.properties) | ||
| .and_then(|mut properties| properties.remove("status")) | ||
| .expect("the CRD must contain a status schema"); | ||
|
|
||
| assert!( | ||
| !status_schema | ||
| .required | ||
| .unwrap_or_default() | ||
| .contains(&"changedValues".to_owned()), | ||
| "changedValues must not be required in the status of version {version}", | ||
| version = version.name | ||
| ); | ||
| } | ||
|
|
||
| let status: PersonStatusWithChangedValues = serde_json::from_value(json!({ "alive": false })) | ||
| .expect("the status must deserialize without changedValues"); | ||
| assert!(status.changed_values.is_empty()); | ||
|
|
||
| // Empty changed values are not serialized | ||
| assert_eq!( | ||
| serde_json::to_value(&status).expect("the status must serialize"), | ||
| json!({ "alive": false }) | ||
| ); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.