Skip to content

Commit

Permalink
Update metadata.rs (#259)
Browse files Browse the repository at this point in the history
Skip serializing fields if empty or undefined
  • Loading branch information
morenol committed Aug 22, 2023
1 parent fdda349 commit 07cae78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/k8-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "k8-types"
version = "0.8.3"
version = "0.8.4"
authors = ["Fluvio Contributors <team@fluvio.io>"]
description = "Kubernetes Object Types"
repository = "https://github.com/infinyon/k8-api"
Expand Down
12 changes: 12 additions & 0 deletions src/k8-types/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,31 @@ pub trait LabelProvider: Sized {
pub struct ObjectMeta {
// mandatory fields
pub name: String,
#[serde(skip_serializing_if = "String::is_empty")]
pub namespace: String,
#[serde(skip_serializing_if = "String::is_empty")]
pub uid: String,
#[serde(skip_serializing_if = "String::is_empty")]
pub creation_timestamp: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub generation: Option<i32>,
#[serde(skip_serializing_if = "String::is_empty")]
#[serde(default)]
pub resource_version: String,
// optional
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deletion_timestamp: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deletion_grace_period_seconds: Option<u32>,
#[serde(skip_serializing_if = "HashMap::is_empty")]
pub labels: HashMap<String, String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub owner_references: Vec<OwnerReferences>,
#[serde(skip_serializing_if = "HashMap::is_empty")]
pub annotations: HashMap<String, String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub finalizers: Vec<String>,
}

Expand Down

0 comments on commit 07cae78

Please sign in to comment.