Skip to content

Add --force flag to connection delete and scope delete#107

Merged
ewega merged 4 commits intomainfrom
copilot/add-force-flag-to-delete-commands
Mar 4, 2026
Merged

Add --force flag to connection delete and scope delete#107
ewega merged 4 commits intomainfrom
copilot/add-force-flag-to-delete-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

configure connection delete and configure scope delete always invoke prompt.Confirm, making them hang in non-interactive environments (CI/CD, scripts).

Changes

  • configure_connection_delete.go — adds connDeleteForce bool package-level var, registers --force flag, short-circuits confirmation when set; Long description updated with --force example
  • configure_scope_delete.go — same pattern: scopeDeleteForce bool, --force flag, skips prompt.Confirm when true; Long description updated with --force example
  • docs/configure-connection.md--force added to flags table and examples block
  • docs/configure-scope.md--force added to flags table and examples block
  • cmd/configure_connection_delete_test.go — added TestRunDeleteConnection_ForceSkipsConfirm to verify the force path proceeds past confirmation
  • cmd/configure_scope_delete_test.go — added TestRunScopeDelete_ForceSkipsConfirm to verify the scope delete force path proceeds past confirmation to DevLake discovery

Follows the existing cleanupForce pattern from cleanup.go.

gh devlake configure connection delete --plugin github --id 1 --force
gh devlake configure scope delete --plugin github --connection-id 1 --scope-id 123 --force

Without --force, both commands behave exactly as before.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add --force flag to connection delete and scope delete</issue_title>
<issue_description>## Problem

connection delete and scope delete always call prompt.Confirm() for confirmation, with no way to skip it. This makes both commands unusable in CI/CD pipelines or automation scripts — they hang waiting for stdin input that never arrives.

The cleanup command already supports a --force flag (cleanupForce in cleanup.go:16) that skips confirmation. These two commands should have parity.

Scope of Changes

configure_connection_delete.go

  • Add connDeleteForce bool flag: --force
  • Skip prompt.Confirm when connDeleteForce is true

configure_scope_delete.go

  • Add scopeDeleteForce bool flag: --force
  • Skip prompt.Confirm when scopeDeleteForce is true

Acceptance Criteria

  • gh devlake configure connection delete --plugin github --id 1 --force deletes without prompting
  • gh devlake configure scope delete --plugin github --connection-id 1 --scope-id 123 --force deletes without prompting
  • Without --force, both commands still prompt for confirmation (no behavior change)
  • go build ./... and go test ./... pass</issue_description>

<agent_instructions>Follow the existing --force pattern from cleanup.go (cleanupForce flag at cleanup.go:16). Add package-level bool vars (connDeleteForce, scopeDeleteForce), register with cmd.Flags().BoolVar(), and skip prompt.Confirm() when true. Terminal output must follow .github/instructions/terminal-output.instructions.md — blank line before emoji steps, 3-space indent for sub-items. Build with go build ./... and test with go test ./....</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copilot AI changed the title [WIP] Add --force flag to connection delete and scope delete Add --force flag to connection delete and scope delete Mar 4, 2026
Copilot finished work on behalf of ewega March 4, 2026 12:03
@ewega ewega marked this pull request as ready for review March 4, 2026 12:10
Copilot AI review requested due to automatic review settings March 4, 2026 12:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a --force flag to configure connection delete and configure scope delete commands to allow skipping the interactive confirmation prompt in CI/CD or scripted environments. It follows the identical pattern already established by cleanup.go's cleanupForce flag.

Changes:

  • configure_connection_delete.go — adds connDeleteForce bool package-level var, registers --force flag via init(), and short-circuits prompt.Confirm when set.
  • configure_scope_delete.go — same pattern: scopeDeleteForce bool, --force flag, confirmation bypassed when true.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
cmd/configure_connection_delete.go Adds connDeleteForce flag variable, registers --force with Cobra, and short-circuits prompt.Confirm when the flag is set
cmd/configure_scope_delete.go Adds scopeDeleteForce flag variable, registers --force with Cobra, and short-circuits prompt.Confirm when the flag is set

cmd.Flags().StringVar(&scopeDeletePlugin, "plugin", "", fmt.Sprintf("Plugin of the connection (%s)", strings.Join(availablePluginSlugs(), ", ")))
cmd.Flags().IntVar(&scopeDeleteConnID, "connection-id", 0, "Connection ID")
cmd.Flags().StringVar(&scopeDeleteScopeID, "scope-id", "", "Scope ID to delete")
cmd.Flags().BoolVar(&scopeDeleteForce, "force", false, "Skip confirmation prompt")
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --force flag is not reflected anywhere the command is documented. Two places need updating: (1) The Long description's examples block (lines 28–30) should include a --force example (e.g., gh devlake configure scope delete --plugin github --connection-id 1 --scope-id 12345678 --force), consistent with how cleanup.go shows gh devlake cleanup --azure --force in its own Long string. (2) docs/configure-scope.md (lines 163–167) lists the flags table for this command but --force is absent; it should be added with description "Skip confirmation prompt", and a matching --force example should appear in the examples block.

Copilot uses AI. Check for mistakes.
func init() {
deleteConnectionCmd.Flags().StringVar(&connDeletePlugin, "plugin", "", "Plugin of the connection to delete")
deleteConnectionCmd.Flags().IntVar(&connDeleteID, "id", 0, "ID of the connection to delete")
deleteConnectionCmd.Flags().BoolVar(&connDeleteForce, "force", false, "Skip confirmation prompt")
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --force flag is not reflected anywhere the command is documented. Two places need updating: (1) The Long description's examples block should include a --force example (e.g., gh devlake configure connection delete --plugin github --id 3 --force), consistent with how cleanup.go shows gh devlake cleanup --azure --force in its Long string. (2) docs/configure-connection.md (lines 211–214) lists the flags table for this command but --force is absent; it should be added with description "Skip confirmation prompt", and an example with --force should appear in the examples block.

Copilot uses AI. Check for mistakes.
fmt.Println(" Any scopes and blueprint references for this connection will also be lost.")
fmt.Println()
if !prompt.Confirm("Are you sure you want to delete this connection?") {
if !connDeleteForce && !prompt.Confirm("Are you sure you want to delete this connection?") {
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing test file cmd/configure_connection_delete_test.go already covers related runDeleteConnection behaviours (unknown plugin, partial flags). It does not include a test verifying that when connDeleteForce is set to true the function skips the confirmation prompt. Given the other tests in this file directly exercise runDeleteConnection with specific flag combinations, a test like TestRunDeleteConnection_ForceSkipsConfirm is missing. Without it, a regression that re-introduces the blocking prompt in the --force path would go undetected.

Copilot uses AI. Check for mistakes.
@ewega
Copy link
Copy Markdown
Contributor

ewega commented Mar 4, 2026

@copilot Please address all 3 review comments:

  1. configure_scope_delete.go — Add --force to the Long description examples block (e.g., gh devlake configure scope delete --plugin github --connection-id 1 --scope-id 12345678 --force). Also update docs/configure-scope.md flags table to include --force with description "Skip confirmation prompt".

  2. configure_connection_delete.go — Same: add --force example to Long description, and update docs/configure-connection.md flags table to include --force with description "Skip confirmation prompt".

  3. configure_connection_delete.go:92 — Add a test TestRunDeleteConnection_ForceSkipsConfirm in cmd/configure_connection_delete_test.go that sets connDeleteForce = true and verifies the function skips the confirmation prompt.

…dd force test

Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot Please address all 3 review comments:

  1. configure_scope_delete.go — Add --force to the Long description examples block (e.g., `gh devlake configure scope delete --plugin github --...

All three addressed in b245519:

  1. configure_scope_delete.go Long examples updated; docs/configure-scope.md flags table now includes --force | false | Skip confirmation prompt with a --force example.
  2. configure_connection_delete.go Long examples updated; docs/configure-connection.md flags table and examples block similarly updated.
  3. Added TestRunDeleteConnection_ForceSkipsConfirm to cmd/configure_connection_delete_test.go — sets connDeleteForce = true with valid plugin/id flags and verifies execution proceeds past validation and the confirm step (reaching DevLake discovery rather than returning a validation or prompt error).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


fmt.Println()
if !prompt.Confirm("Are you sure you want to delete this scope?") {
if !scopeDeleteForce && !prompt.Confirm("Are you sure you want to delete this scope?") {
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR adds --force support to runScopeDelete but provides no test coverage for that path. A parallel test to TestRunDeleteConnection_ForceSkipsConfirm — which verifies that with scopeDeleteForce = true and all three flags set, the function proceeds past confirmation to DevLake discovery (returning a discovery error, not nil, and not a validation error) — is missing. Since configure_connection_delete_test.go already tests the analogous path, a configure_scope_delete_test.go (or tests within configure_scopes_test.go) should cover the same behavior for scope delete.

Copilot uses AI. Check for mistakes.
@ewega
Copy link
Copy Markdown
Contributor

ewega commented Mar 4, 2026

@copilot One more fix: add a parallel test TestRunScopeDelete_ForceSkipsConfirm in a new cmd/configure_scope_delete_test.go file that sets scopeDeleteForce = true and verifies the function proceeds past confirmation (returns a discovery error, not a validation error). Same pattern as the TestRunDeleteConnection_ForceSkipsConfirm test.

…e path

Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot One more fix: add a parallel test TestRunScopeDelete_ForceSkipsConfirm in a new cmd/configure_scope_delete_test.go file that sets scopeDeleteForce = true and verifies the function proce...

Added TestRunScopeDelete_ForceSkipsConfirm in the new cmd/configure_scope_delete_test.go in commit 79fc556. It sets scopeDeleteForce = true with all three flags (--plugin github, --connection-id 1, --scope-id 12345678), calls runScopeDelete, and asserts the function proceeds past validation and confirmation — returning a DevLake discovery error rather than a validation or prompt error.

Copilot finished work on behalf of ewega March 4, 2026 12:30
@ewega ewega merged commit 7596325 into main Mar 4, 2026
7 checks passed
@ewega ewega deleted the copilot/add-force-flag-to-delete-commands branch March 4, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --force flag to connection delete and scope delete

3 participants