Skip to content

Commit

Permalink
fix: Fix few tui generated code issues (#877)
Browse files Browse the repository at this point in the history
Change-Id: Iac7169de7ee07fa06e48dec56d0e9656c2d7e45a

Changes are triggered by https://review.opendev.org/937856
  • Loading branch information
gtema authored Dec 17, 2024
1 parent 077aa59 commit fcb94f0
Show file tree
Hide file tree
Showing 39 changed files with 228 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct BlockStorageBackupDelete {

impl fmt::Display for BlockStorageBackupDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct BlockStorageSnapshotDelete {

impl fmt::Display for BlockStorageSnapshotDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct BlockStorageVolumeDelete {

impl fmt::Display for BlockStorageVolumeDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct ComputeAggregateDelete {

impl fmt::Display for ComputeAggregateDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/compute/v2/aggregate/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ pub struct ComputeAggregateShow {

impl fmt::Display for ComputeAggregateShow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/compute/v2/flavor/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct ComputeFlavorDelete {

impl fmt::Display for ComputeFlavorDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/compute/v2/flavor/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ pub struct ComputeFlavorShow {

impl fmt::Display for ComputeFlavorShow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/compute/v2/hypervisor/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ pub struct ComputeHypervisorShow {

impl fmt::Display for ComputeHypervisorShow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ pub struct ComputeQuotaSetShow {
impl fmt::Display for ComputeQuotaSetShow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
if self.user_id.is_some() || self.user_name.is_some() {
parts.push(format!(
"user: {}",
self.user_name
.as_ref()
.or(self.user_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/compute/v2/server/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct ComputeServerDelete {

impl fmt::Display for ComputeServerDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/compute/v2/server/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ pub struct ComputeServerShow {

impl fmt::Display for ComputeServerShow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pub struct ComputeInstanceActionShow {
impl fmt::Display for ComputeInstanceActionShow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
parts.push(format!(
"server: {}",
self.server_name.clone().unwrap_or(self.server_id.clone())
Expand Down
22 changes: 16 additions & 6 deletions openstack_tui/src/cloud_worker/compute/v2/server/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl fmt::Display for ComputeServerList {
self.kernel_name
.as_ref()
.or(self.kernel_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -114,7 +114,7 @@ impl fmt::Display for ComputeServerList {
self.project_name
.as_ref()
.or(self.project_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -124,7 +124,7 @@ impl fmt::Display for ComputeServerList {
self.ramdisk_name
.as_ref()
.or(self.ramdisk_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -134,7 +134,7 @@ impl fmt::Display for ComputeServerList {
self.reservation_name
.as_ref()
.or(self.reservation_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -144,7 +144,7 @@ impl fmt::Display for ComputeServerList {
self.tenant_name
.as_ref()
.or(self.tenant_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -154,7 +154,17 @@ impl fmt::Display for ComputeServerList {
self.user_name
.as_ref()
.or(self.user_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

if self.uuid.is_some() || self.uuname.is_some() {
parts.push(format!(
"u: {}",
self.uuname
.as_ref()
.or(self.uuid.as_ref())
.unwrap_or(&String::default())
));
}

Expand Down
2 changes: 1 addition & 1 deletion openstack_tui/src/cloud_worker/dns/v2/recordset/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl fmt::Display for DnsRecordsetList {
self.zone_name
.as_ref()
.or(self.zone_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/dns/v2/zone/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct DnsZoneDelete {

impl fmt::Display for DnsZoneDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pub struct DnsRecordsetDelete {
impl fmt::Display for DnsRecordsetDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
parts.push(format!(
"zone: {}",
self.zone_name.clone().unwrap_or(self.zone_id.clone())
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/identity/v3/group/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct IdentityGroupDelete {

impl fmt::Display for IdentityGroupDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
2 changes: 1 addition & 1 deletion openstack_tui/src/cloud_worker/identity/v3/group/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl fmt::Display for IdentityGroupList {
self.domain_name
.as_ref()
.or(self.domain_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ impl fmt::Display for IdentityUserDelete {
"group: {}",
self.group_name.clone().unwrap_or(self.group_id.clone())
));
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/identity/v3/project/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct IdentityProjectDelete {

impl fmt::Display for IdentityProjectDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
4 changes: 2 additions & 2 deletions openstack_tui/src/cloud_worker/identity/v3/project/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl fmt::Display for IdentityProjectList {
self.domain_name
.as_ref()
.or(self.domain_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -63,7 +63,7 @@ impl fmt::Display for IdentityProjectList {
self.parent_name
.as_ref()
.or(self.parent_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pub struct IdentityApplicationCredentialDelete {
impl fmt::Display for IdentityApplicationCredentialDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
parts.push(format!(
"user: {}",
self.user_name.clone().unwrap_or(self.user_id.clone())
Expand Down
6 changes: 5 additions & 1 deletion openstack_tui/src/cloud_worker/identity/v3/user/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct IdentityUserDelete {

impl fmt::Display for IdentityUserDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
8 changes: 4 additions & 4 deletions openstack_tui/src/cloud_worker/identity/v3/user/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl fmt::Display for IdentityUserList {
self.domain_name
.as_ref()
.or(self.domain_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -60,7 +60,7 @@ impl fmt::Display for IdentityUserList {
self.idp_name
.as_ref()
.or(self.idp_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -70,7 +70,7 @@ impl fmt::Display for IdentityUserList {
self.protocol_name
.as_ref()
.or(self.protocol_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand All @@ -80,7 +80,7 @@ impl fmt::Display for IdentityUserList {
self.unique_name
.as_ref()
.or(self.unique_id.as_ref())
.unwrap_or(&String::new())
.unwrap_or(&String::default())
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ pub struct LoadBalancerHealthmonitorDelete {

impl fmt::Display for LoadBalancerHealthmonitorDelete {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let parts: Vec<String> = Vec::new();
let mut parts: Vec<String> = Vec::new();
parts.push(format!(
": {}",
self.name.clone().unwrap_or(self.id.clone())
));
write!(f, "{}", parts.join(","))
}
}
Expand Down
Loading

0 comments on commit fcb94f0

Please sign in to comment.