-
Notifications
You must be signed in to change notification settings - Fork 40
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
Use Vec instead of HashMap for firewall rules, don't paginate #668
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d9207c0
use vec of firewall rules instead of hashmap
david-crespo b71b40a
don't paginate rules endpoint, use same response view for GET and PUT
david-crespo 6990c11
don't need the FromIterator, nexus things should return models
david-crespo b288b9a
Merge branch 'main' into firewall-rule-tweaks
david-crespo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,6 @@ use omicron_common::api::external::RouterRouteKind; | |
use omicron_common::api::external::RouterRouteUpdateParams; | ||
use omicron_common::api::external::UpdateResult; | ||
use omicron_common::api::external::VpcFirewallRuleUpdateParams; | ||
use omicron_common::api::external::VpcFirewallRuleUpdateResult; | ||
use omicron_common::api::external::VpcRouterKind; | ||
use omicron_common::api::internal::nexus; | ||
use omicron_common::api::internal::nexus::DiskRuntimeState; | ||
|
@@ -1736,16 +1735,13 @@ impl Nexus { | |
organization_name: &Name, | ||
project_name: &Name, | ||
vpc_name: &Name, | ||
pagparams: &DataPageParams<'_, Name>, | ||
) -> ListResultVec<db::model::VpcFirewallRule> { | ||
let vpc = self | ||
.project_lookup_vpc(organization_name, project_name, vpc_name) | ||
.await?; | ||
let subnets = self | ||
.db_datastore | ||
.vpc_list_firewall_rules(&vpc.id(), pagparams) | ||
.await?; | ||
Ok(subnets) | ||
let rules = | ||
self.db_datastore.vpc_list_firewall_rules(&vpc.id()).await?; | ||
Ok(rules) | ||
} | ||
|
||
pub async fn vpc_update_firewall_rules( | ||
|
@@ -1754,22 +1750,15 @@ impl Nexus { | |
project_name: &Name, | ||
vpc_name: &Name, | ||
params: &VpcFirewallRuleUpdateParams, | ||
) -> UpdateResult<VpcFirewallRuleUpdateResult> { | ||
) -> UpdateResult<Vec<db::model::VpcFirewallRule>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. functions in this file should return models |
||
let vpc = self | ||
.project_lookup_vpc(organization_name, project_name, vpc_name) | ||
.await?; | ||
let rules = db::model::VpcFirewallRule::vec_from_params( | ||
vpc.id(), | ||
params.clone(), | ||
); | ||
let result = self | ||
.db_datastore | ||
.vpc_update_firewall_rules(&vpc.id(), rules) | ||
.await? | ||
.into_iter() | ||
.map(|rule| rule.into()) | ||
.collect(); | ||
Ok(result) | ||
self.db_datastore.vpc_update_firewall_rules(&vpc.id(), rules).await | ||
} | ||
|
||
pub async fn vpc_list_subnets( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be called a
VpcFirewall
and the endpoint should simply be/firewall
. That way aFirewall
is essentially the name for a collection of rules. I don't see why we would want to have multiple firewalls per VPC, but we don't have to support that. It could just be/vpc/:vpcName/firewall
and there is exactly one firewall.