Skip to content

Commit

Permalink
tsparser: fix bucket usage mapping (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
eandre authored Nov 21, 2024
1 parent c2c351f commit 7589d7f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tsparser/src/legacymeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,8 @@ impl<'a> MetaBuilder<'a> {

let idx = svc_index.get(&svc.name).unwrap();
bucket_perms
.entry(*idx)
.or_insert(v1::BucketUsage {
bucket: access.bucket.name.clone(),
operations: vec![],
})
.operations
.entry((*idx, &access.bucket.name))
.or_insert(vec![])
.extend(ops);
}

Expand Down Expand Up @@ -448,11 +444,14 @@ impl<'a> MetaBuilder<'a> {
}

// Add the computed bucket permissions to the services.
for (svc_idx, mut bucket_perm) in bucket_perms {
for ((svc_idx, bucket), mut operations) in bucket_perms {
// Make the bucket perms sorted and unique.
bucket_perm.operations.sort();
bucket_perm.operations.dedup();
self.data.svcs[svc_idx].buckets.push(bucket_perm);
operations.sort();
operations.dedup();
self.data.svcs[svc_idx].buckets.push(v1::BucketUsage {
bucket: bucket.clone(),
operations,
});
}

// Sort the packages for deterministic output.
Expand All @@ -469,6 +468,9 @@ impl<'a> MetaBuilder<'a> {
svc.databases.sort();
svc.databases.dedup();

// Sort buckets by name for deterministic output.
svc.buckets.sort_by(|a, b| a.bucket.cmp(&b.bucket));

// Sort the endpoints for deterministic output.
svc.rpcs.sort_by(|a, b| a.name.cmp(&b.name));
}
Expand Down

0 comments on commit 7589d7f

Please sign in to comment.