Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion tvc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ impl Cli {

match args.command {
Commands::Deploy { command } => match command {
DeployCommands::Approve(args) => commands::deploy::approve::run(args).await,
DeployCommands::Approve(args) => {
commands::deploy::approve::run(args, no_input).await
}
DeployCommands::Status(args) => commands::deploy::status::run(args).await,
DeployCommands::Create(args) => commands::deploy::create::run(args).await,
DeployCommands::Init(args) => commands::deploy::init::run(args).await,
Expand Down
9 changes: 3 additions & 6 deletions tvc/src/commands/deploy/approve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ pub struct Args {
#[arg(long)]
pub dry_run: bool,

/// DANGEROUS: skip interactive prompts for approving each aspect of manifest.
#[arg(long)]
pub dangerous_skip_interactive: bool,

/// Write approval to file instead of stdout.
#[arg(short, long, value_name = "PATH")]
pub output: Option<PathBuf>,
Expand All @@ -75,7 +71,7 @@ pub struct Args {
}

/// Run the approve deploy command.
pub async fn run(args: Args) -> anyhow::Result<()> {
pub async fn run(args: Args, no_input: bool) -> anyhow::Result<()> {
// Fetch manifest - track manifest_id if fetched from API
let (manifest, fetched_manifest_id) = match (&args.manifest, &args.deploy_id) {
(Some(path), _) => (read_manifest_from_path(path).await?, None),
Expand All @@ -86,7 +82,8 @@ pub async fn run(args: Args) -> anyhow::Result<()> {
(None, None) => bail!("a manifest source is required"),
};

if !args.dangerous_skip_interactive {
// Skip interactive approval in non-interactive mode
if !no_input {
interactive_approve(&manifest)?;
}

Expand Down
13 changes: 7 additions & 6 deletions tvc/tests/deploy_approve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ use predicates::prelude::*;
#[test]
fn approve_requires_source() {
cargo_bin_cmd!("tvc")
.arg("--no-input")
.arg("deploy")
.arg("approve")
.arg("--dry-run")
.arg("--dangerous-skip-interactive")
.assert()
.failure()
.stderr(predicate::str::contains("manifest source is required"));
}

#[test]
fn dangerous_approve_with_file() {
fn approve_no_input_skips_interactive() {
cargo_bin_cmd!("tvc")
.arg("--no-input")
.arg("deploy")
.arg("approve")
.arg("--manifest")
.arg("fixtures/manifest.json")
.arg("--operator-seed")
.arg("fixtures/seed.hex")
.arg("--dangerous-skip-interactive")
.arg("--skip-post")
.assert()
.success();
.success()
.stdout(predicate::str::contains("\"signature\""))
.stdout(predicate::str::contains("MANIFEST APPROVAL").not());
}

#[test]
Expand Down Expand Up @@ -84,7 +86,6 @@ fn manifest_and_deploy_id_are_mutually_exclusive() {
.arg("fixtures/manifest.json")
.arg("--deploy-id")
.arg("some-deploy-id")
.arg("--dangerous-skip-interactive")
.assert()
.failure()
.stderr(predicate::str::contains(
Expand All @@ -96,13 +97,13 @@ fn manifest_and_deploy_id_are_mutually_exclusive() {
#[test]
fn approve_requires_manifest_id_or_skip_post() {
cargo_bin_cmd!("tvc")
.arg("--no-input")
.arg("deploy")
.arg("approve")
.arg("--manifest")
.arg("fixtures/manifest.json")
.arg("--operator-seed")
.arg("fixtures/seed.hex")
.arg("--dangerous-skip-interactive")
.assert()
.failure()
.stderr(predicate::str::contains(
Expand Down
1 change: 0 additions & 1 deletion tvc/tests/global_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fn no_input_flag_recognized() {
.arg("deploy")
.arg("approve")
.arg("--dry-run")
.arg("--dangerous-skip-interactive")
.assert()
.failure()
.stderr(predicate::str::contains("manifest source is required"));
Expand Down