-
Notifications
You must be signed in to change notification settings - Fork 42
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
[ls-apis] support APIs exposed by multiple servers #7843
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ use anyhow::{Context, Result, bail}; | |
use camino::Utf8PathBuf; | ||
use clap::{Args, Parser, Subcommand}; | ||
use omicron_ls_apis::{ | ||
AllApiMetadata, ApiDependencyFilter, LoadArgs, ServerComponentName, | ||
SystemApis, VersionedHow, | ||
AllApiMetadata, ApiDependencyFilter, ApiMetadata, LoadArgs, | ||
ServerComponentName, SystemApis, VersionedHow, | ||
}; | ||
use parse_display::{Display, FromStr}; | ||
|
||
|
@@ -108,17 +108,15 @@ fn run_adoc(apis: &SystemApis) -> Result<()> { | |
|
||
let metadata = apis.api_metadata(); | ||
for api in metadata.apis() { | ||
let Some(server_component) = | ||
apis.api_producer(&api.client_package_name) | ||
else { | ||
continue; | ||
}; | ||
println!("// DO NOT EDIT. This table is auto-generated. See above."); | ||
println!("|{}", api.label); | ||
println!("|{}", apis.adoc_label(server_component)?); | ||
println!("|{}", apis.adoc_label(&api.client_package_name)?); | ||
|
||
println!("|"); | ||
for server_component in apis.api_producers(&api.client_package_name) { | ||
println!("* {}", apis.adoc_label(server_component)?); | ||
} | ||
|
||
println!("|"); | ||
for (c, _) in apis.api_consumers( | ||
&api.client_package_name, | ||
ApiDependencyFilter::default(), | ||
|
@@ -214,12 +212,10 @@ fn print_server_components<'a>( | |
for s in server_components.into_iter() { | ||
let (repo_name, pkg_path) = apis.package_label(s)?; | ||
println!("{}{} ({}/{})", prefix, s, repo_name, pkg_path); | ||
for api in metadata.apis().filter(|a| { | ||
matches!( | ||
apis.api_producer(&a.client_package_name), | ||
Some (name) if name == s | ||
) | ||
}) { | ||
for api in metadata | ||
.apis() | ||
.filter(|a| apis.is_producer_of(s, &a.client_package_name)) | ||
{ | ||
println!( | ||
"{} exposes: {} (client = {})", | ||
prefix, api.label, api.client_package_name | ||
|
@@ -301,31 +297,33 @@ fn run_check(apis: &SystemApis) -> Result<()> { | |
); | ||
} | ||
|
||
fn print_api_and_producers(api: &ApiMetadata, apis: &SystemApis) { | ||
print!(" {} ({}", api.label, api.client_package_name,); | ||
let mut producers = apis.api_producers(&api.client_package_name); | ||
if let Some(producer) = producers.next() { | ||
print!(", exposed by {producer}"); | ||
for producer in producers { | ||
print!(", {producer}") | ||
} | ||
} | ||
println!(")"); | ||
} | ||
|
||
println!("\n"); | ||
println!("Server-managed APIs:\n"); | ||
for api in apis | ||
.api_metadata() | ||
.apis() | ||
.filter(|f| f.deployed() && f.versioned_how == VersionedHow::Server) | ||
{ | ||
println!( | ||
" {} ({}, exposed by {})", | ||
api.label, | ||
api.client_package_name, | ||
apis.api_producer(&api.client_package_name).unwrap() | ||
); | ||
print_api_and_producers(api, apis); | ||
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. Same -- would love to see the change in output for this. 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. I included the output from
|
||
} | ||
|
||
println!("\n"); | ||
println!("Client-managed API:\n"); | ||
for api in apis.api_metadata().apis().filter(|f| f.deployed()) { | ||
if let VersionedHow::Client(reason) = &api.versioned_how { | ||
println!( | ||
" {} ({}, exposed by {})", | ||
api.label, | ||
api.client_package_name, | ||
apis.api_producer(&api.client_package_name).unwrap() | ||
); | ||
print_api_and_producers(api, apis); | ||
println!(" reason: {}", reason); | ||
} | ||
} | ||
|
@@ -342,12 +340,7 @@ fn run_check(apis: &SystemApis) -> Result<()> { | |
} else { | ||
println!("\n"); | ||
for api in unknown { | ||
println!( | ||
" {} ({}, exposed by {})", | ||
api.label, | ||
api.client_package_name, | ||
apis.api_producer(&api.client_package_name).unwrap() | ||
); | ||
print_api_and_producers(api, apis); | ||
} | ||
bail!("at least one API has unknown version strategy (see above)"); | ||
} | ||
|
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.
Could you post to the PR the output of this when there are multiple producers of an API?
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.
I've added the output for
ls-apis servers
to the PR description. Here's the relevant bits (omicron-gateway
andomicron-sled-agent
both include the ereporter API):