Skip to content
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

Exit early if no interfaces are exported from the component #5

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl ComponentSource {

if let Ok((name, version)) = package_name_ver(source) {
if version.is_none() {
bail!("Version needs to specified for regitry sources.")
bail!("Version needs to specified for registry sources.")
}
return Ok(Self::Registry(RegistryAddCommand {
package: name,
Expand Down Expand Up @@ -96,6 +96,8 @@ impl AddCommand {

let (mut resolve, main) = parse_component_bytes(component)?;

let selected_interfaces = self.select_interfaces(&mut resolve, main)?;

let mut manifest = manifest_from_file(get_spin_manifest_path()?)?;
let component_ids = get_component_ids(&manifest);
let selected_component_index = select_prompt(
Expand All @@ -105,8 +107,6 @@ impl AddCommand {
)?;
let selected_component = &component_ids[selected_component_index];

let selected_interfaces = self.select_interfaces(&mut resolve, main)?;

resolve.importize(
resolve.select_world(main, None)?,
Some("dependency-world".to_string()),
Expand Down Expand Up @@ -143,6 +143,10 @@ impl AddCommand {
let world_id = resolve.select_world(main, None)?;
let exported_interfaces = get_exported_interfaces(resolve, world_id);

if exported_interfaces.is_empty() {
bail!("No exported interfaces found in the component")
};

let mut package_interface_map: HashMap<String, Vec<String>> = HashMap::new();
let mut selected_interfaces: Vec<String> = Vec::new();

Expand Down
Loading