Skip to content

Commit

Permalink
feat: switch --remote workflows to reuse an existing ID (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante authored Sep 11, 2024
1 parent 8a83b0f commit 83154ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
9 changes: 2 additions & 7 deletions crates/cli/src/commands/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,8 @@ pub(crate) async fn run_apply(

#[cfg(feature = "remote_workflows")]
if args.apply_migration_args.remote {
return crate::workflows::run_remote_workflow(
args.pattern_or_workflow,
args.apply_migration_args,
ranges,
flags,
)
.await;
return crate::workflows::run_remote_workflow(args.apply_migration_args, ranges, flags)
.await;
}

let paths = args.paths.clone();
Expand Down
6 changes: 5 additions & 1 deletion crates/cli/src/commands/apply_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ pub struct ApplyMigrationArgs {
#[clap(
long,
help_heading = "Workflow options",
help = "Run the workflow remotely on Grit Cloud"
help = "Run the workflow remotely on Grit Cloud",
requires = "workflow_id"
)]
pub(crate) remote: bool,
/// Workflow ID to set, only applicable when running remotely
#[clap(long, help_heading = "Workflow options", requires = "remote")]
pub(crate) workflow_id: Option<String>,
/// Watch the workflow for updates (only applicable when running remotely)
#[clap(long, help_heading = "Workflow options")]
pub(crate) watch: bool,
Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/commands/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ pub(crate) async fn run_plumbing(
super::apply_migration::ApplyMigrationArgs {
input: Some(buffer),
remote: false,
workflow_id: None,
verbose: true,
watch: false,
},
Expand Down
7 changes: 5 additions & 2 deletions crates/cli/src/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ where

#[cfg(feature = "remote_workflows")]
pub async fn run_remote_workflow(
workflow_name: String,
args: crate::commands::apply_migration::ApplyMigrationArgs,
ranges: Option<Vec<FileDiff>>,
flags: &crate::flags::GlobalFormatFlags,
Expand Down Expand Up @@ -297,8 +296,12 @@ pub async fn run_remote_workflow(
}
}

let Some(workflow_id) = args.workflow_id else {
anyhow::bail!("No workflow ID provided");
};

let settings =
grit_cloud_client::RemoteWorkflowSettings::new(workflow_name, &repo, input.into());
grit_cloud_client::RemoteWorkflowSettings::new(&workflow_id, &repo, input.into());
let result = grit_cloud_client::run_remote_workflow(settings, &auth).await?;

pb.finish_and_clear();
Expand Down

0 comments on commit 83154ca

Please sign in to comment.