Skip to content

Commit

Permalink
fmt, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Aug 29, 2024
1 parent ff1a6e8 commit 6f715d7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
16 changes: 8 additions & 8 deletions nexus/types/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ impl Blueprint {
})
.collect();


BlueprintDiff::new(
DiffBeforeMetadata::Collection { id: before.id },
before_zones,
Expand Down Expand Up @@ -1156,10 +1155,14 @@ impl BlueprintOrCollectionDatasetsConfig {

pub fn datasets(&self) -> BTreeSet<CollectionDatasetIdentifier> {
match self {
BlueprintOrCollectionDatasetsConfig::Collection(c) => c.datasets.clone(),
BlueprintOrCollectionDatasetsConfig::Blueprint(c) => {
c.datasets.values().map(CollectionDatasetIdentifier::from).collect()
BlueprintOrCollectionDatasetsConfig::Collection(c) => {
c.datasets.clone()
}
BlueprintOrCollectionDatasetsConfig::Blueprint(c) => c
.datasets
.values()
.map(CollectionDatasetIdentifier::from)
.collect(),
}
}
}
Expand All @@ -1186,10 +1189,7 @@ impl From<&BlueprintDatasetConfig> for CollectionDatasetIdentifier {

impl From<&crate::inventory::Dataset> for CollectionDatasetIdentifier {
fn from(d: &crate::inventory::Dataset) -> Self {
Self {
id: d.id,
name: d.name.clone(),
}
Self { id: d.id, name: d.name.clone() }
}
}

Expand Down
50 changes: 33 additions & 17 deletions nexus/types/src/deployment/blueprint_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
//! Types helpful for diffing blueprints.
use super::blueprint_display::{
constants::*, linear_table_modified, linear_table_unchanged, BpDiffState,
BpGeneration, BpDatasetsSubtableSchema, BpOmicronZonesSubtableSchema,
BpPhysicalDisksSubtableSchema, BpSledSubtable, BpSledSubtableColumn,
BpSledSubtableData, BpSledSubtableRow, KvListWithHeading, KvPair,
constants::*, linear_table_modified, linear_table_unchanged,
BpDatasetsSubtableSchema, BpDiffState, BpGeneration,
BpOmicronZonesSubtableSchema, BpPhysicalDisksSubtableSchema,
BpSledSubtable, BpSledSubtableColumn, BpSledSubtableData,
BpSledSubtableRow, KvListWithHeading, KvPair,
};
use super::{zone_sort_key, CockroachDbPreserveDowngrade};
use nexus_sled_agent_shared::inventory::ZoneKind;
Expand All @@ -20,11 +21,12 @@ use std::collections::{BTreeMap, BTreeSet};
use std::fmt;

use crate::deployment::{
CollectionDatasetIdentifier, BlueprintDatasetsConfig, BlueprintMetadata,
BlueprintDatasetsConfig, BlueprintMetadata,
BlueprintOrCollectionDatasetsConfig, BlueprintOrCollectionDisksConfig,
BlueprintOrCollectionZoneConfig, BlueprintOrCollectionZonesConfig,
BlueprintPhysicalDisksConfig, BlueprintZoneConfig, BlueprintZoneDisposition,
BlueprintZonesConfig, DiffBeforeMetadata, ZoneSortKey,
BlueprintPhysicalDisksConfig, BlueprintZoneConfig,
BlueprintZoneDisposition, BlueprintZonesConfig,
CollectionDatasetIdentifier, DiffBeforeMetadata, ZoneSortKey,
};

/// Diffs for omicron zones on a given sled with a given `BpDiffState`
Expand Down Expand Up @@ -579,7 +581,11 @@ impl BpSledSubtableData for DiffDatasetsDetails {
self.datasets.iter().map(move |d| {
BpSledSubtableRow::from_strings(
state,
vec![d.id.map(|id| id.to_string()).unwrap_or_else(|| "none".to_string()), d.name.clone()],
vec![
d.id.map(|id| id.to_string())
.unwrap_or_else(|| "none".to_string()),
d.name.clone(),
],
)
})
}
Expand Down Expand Up @@ -648,7 +654,10 @@ impl BpDiffDatasets {
DiffDatasetsDetails {
before_generation,
after_generation: None,
datasets: before_datasets.datasets().into_iter().collect(),
datasets: before_datasets
.datasets()
.into_iter()
.collect(),
},
);
}
Expand All @@ -657,8 +666,11 @@ impl BpDiffDatasets {
// Any sleds remaining in `after` have just been added, since we remove
// sleds from `after`, that were also in `before`, in the above loop.
for (sled_id, after_datasets) in after {
let added: BTreeSet<CollectionDatasetIdentifier> =
after_datasets.datasets.values().map(CollectionDatasetIdentifier::from).collect();
let added: BTreeSet<CollectionDatasetIdentifier> = after_datasets
.datasets
.values()
.map(CollectionDatasetIdentifier::from)
.collect();
if !added.is_empty() {
diffs.added.insert(
sled_id,
Expand Down Expand Up @@ -726,21 +738,27 @@ pub struct BlueprintDiff {
impl BlueprintDiff {
/// Build a diff with the provided contents, verifying that the provided
/// data is valid.
#[allow(clippy::too_many_arguments)]
pub fn new(
before_meta: DiffBeforeMetadata,
before_zones: BTreeMap<SledUuid, BlueprintOrCollectionZonesConfig>,
before_disks: BTreeMap<SledUuid, BlueprintOrCollectionDisksConfig>,
before_datasets: BTreeMap<SledUuid, BlueprintOrCollectionDatasetsConfig>,
before_datasets: BTreeMap<
SledUuid,
BlueprintOrCollectionDatasetsConfig,
>,
after_meta: BlueprintMetadata,
after_zones: BTreeMap<SledUuid, BlueprintZonesConfig>,
after_disks: BTreeMap<SledUuid, BlueprintPhysicalDisksConfig>,
after_datasets: BTreeMap<SledUuid, BlueprintDatasetsConfig>,
) -> Self {
let before_sleds: BTreeSet<_> = before_zones.keys()
let before_sleds: BTreeSet<_> = before_zones
.keys()
.chain(before_disks.keys())
.chain(before_datasets.keys())
.collect();
let after_sleds: BTreeSet<_> = after_zones.keys()
let after_sleds: BTreeSet<_> = after_zones
.keys()
.chain(after_disks.keys())
.chain(after_datasets.keys())
.collect();
Expand Down Expand Up @@ -917,9 +935,7 @@ impl<'diff> BlueprintDiffDisplay<'diff> {
}

// Write the datasets table if it exists
if let Some(table) =
self.diff.datasets.to_bp_sled_subtable(sled_id)
{
if let Some(table) = self.diff.datasets.to_bp_sled_subtable(sled_id) {
writeln!(f, "{table}\n")?;
}

Expand Down

0 comments on commit 6f715d7

Please sign in to comment.