Skip to content

Commit

Permalink
Change flag to --component-id and add support for invoking it from 'b…
Browse files Browse the repository at this point in the history
…uild --up'

Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
  • Loading branch information
kate-goldenring committed Sep 18, 2024
1 parent 6c5a825 commit ff7feef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl BuildCommand {
)))
.chain(self.up_args),
);
cmd.components = self.component_id.iter().map(String::from).collect();
cmd.file_source = Some(manifest_file);
cmd.run().await
} else {
Expand Down
29 changes: 14 additions & 15 deletions src/commands/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ pub struct UpCommand {
#[clap(long, takes_value = false, env = ALWAYS_BUILD_ENV)]
pub build: bool,

/// Specific component to run. Can specify multiple. If omitted, all
/// components are run.
#[clap(hide = true, long = "component")]
pub components: Option<Vec<String>>,
/// Component ID to run. This can be specified multiple times. The default is all components.
#[clap(hide = true, short = 'c', long = "component-id")]
pub components: Vec<String>,

/// All other args, to be passed through to the trigger
#[clap(hide = true)]
Expand Down Expand Up @@ -198,8 +197,8 @@ impl UpCommand {
.load_resolved_app_source(resolved_app_source, &working_dir)
.await
.context("Failed to load application")?;
if let Some(components) = &self.components {
retain_components(&mut locked_app, components)?;
if !self.components.is_empty() {
retain_components(&mut locked_app, &self.components)?;
}

let trigger_types: HashSet<&str> = locked_app
Expand Down Expand Up @@ -700,18 +699,18 @@ fn validate_retained_components_service_chaining(
allowed_hosts.iter().try_for_each(|host| {
// Templated URLs are not resolved at this point, so ignore unresolvable URIs
if let Ok(uri) = host.parse::<http::Uri>() {
if let Some(local_component) = parse_service_chaining_target(&uri) {
if !retained_components.contains(&local_component) {
if local_component == "*" {
bail!("Component selected with '--component {}' cannot use wildcard service chaining: allowed_outbound_hosts = [\"http://*.spin.internal\"]", component.id());
if let Some(chaining_target) = parse_service_chaining_target(&uri) {
if !retained_components.contains(&chaining_target) {
if chaining_target == "*" {
bail!("Component selected with '--component {}' cannot use wildcard service chaining: allowed_outbound_hosts = [\"http://*.spin.internal\"]", component.id());
}
bail!(
"Component selected with '--component {}' cannot use service chaining to unselected component: allowed_outbound_hosts = [\"http://{}.spin.internal\"]",
component.id(), chaining_target
);
}
bail!(
"Component selected with '--component {}' cannot use service chaining to unselected component: allowed_outbound_hosts = [\"http://{}.spin.internal\"]",
component.id(), local_component
);
}
}
}
Ok(())
})?;
}}
Expand Down

0 comments on commit ff7feef

Please sign in to comment.