-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
P1Priority 1Priority 1
Description
This issue tracks the implementation of the azdo service-endpoint delete command.
Command Description
Delete a service endpoint from the target project, optionally cleaning up the associated Azure AD application (for AzureRM endpoints) and any additional project shares. The command should mirror the capabilities of az devops service-endpoint delete while following the repository's conventions for positional scope parsing, prompting, and output.
azdo Command Signature
azdo service-endpoint delete [ORGANIZATION/]PROJECT/ID [flags]
Arguments:
[ORGANIZATION/]PROJECT/ID(required): Project scope followingISSUE-TRIAGE.md. Resolve viautil.ParseProjectNameAndOrganization, falling back to the configured default organization when possible.ID(required): UUID of the service endpoint to delete. Validate format before issuing API calls.
Flags
--deep: When set, passdeep=trueto the REST API so the backing service principal/app registration is also removed (supported for AzureRM endpoints per REST doc).--additional-project: Repeatable flag supplying extra project IDs as [ORGANIZATION/]PROJECT when the endpoint is shared across multiple projects. Combine with the primary project ID from the positional argument to build theprojectIdslist sent to the API. If omitted, only the positional project will be affected. The names of the additional projects must resolved into their respective GUIDs. An error resolving the GUID for a project returns an error.--yes,-y: Skip the confirmation prompt.
Behavior
- Acquire IO streams and prompter via
ctx.IOStreams()/ctx.Prompter(); startios.StartProgressIndicator()immediately and stop it before any CLI output. - Parse a stable list of project IDs: always include the resolved project GUID (use
serviceEndpointClient.GetServiceEndpointDetailsor the share references to retrieve the GUID if only the name was supplied) plus any--additional-project-idvalues. Deduplicate GUIDs to avoid REST errors. - Confirm the endpoint exists before deletion by issuing
ServiceEndpointClient.GetServiceEndpointDetails(orGetServiceEndpoint) to provide better error messages and to retrieve metadata for confirmation text (e.g., endpoint name/type). If the lookup fails, return the wrapped error without attempting deletion. - Unless
--yesis supplied, prompt the user:Delete service endpoint <name> (<id>) from project <projectName>?and includedeepor additional project warnings when relevant. Declining should returnutil.ErrCancel. - Perform the deletion via
ServiceEndpointClient.DeleteServiceEndpoint(ctx, serviceendpoint.DeleteServiceEndpointArgs{ EndpointId: &id, ProjectIds: &[]string{...}, Deep: &deepFlag })using the vendored Azure DevOps client (azuredevops/v7/serviceendpoint). - Treat a non-204 response or returned error as a failure; wrap with context (mention endpoint ID and project).
- Add
zap.L().Debugstatements for parsed scope, project ID list, deep flag, and REST call outcomes (excluding secrets).
Error Handling & Edge Cases
- Validate
IDand all--additional-project-idvalues as UUIDs before calling the API; return descriptive flag errors if parsing fails. - If the endpoint is shared with multiple projects and the caller omits additional project IDs, document (in help text) that the endpoint will only be removed from the specified project and remain in others. Consider warning via debug log.
- Handle the case where the endpoint is already deleted or not found by surfacing a user-facing error from the lookup step.
- Ensure progress indicator is stopped even on errors or cancellations.
Testing
- Add table-driven unit tests in
internal/cmd/serviceendpoint/delete/delete_test.gousing gomock:- Successful delete with single project (asserts prompt, REST call args, output, progress stop).
--yesbypasses prompt.- Deep delete sends
deep=true. - Additional project IDs combine with positional project (deduping).
- Invalid UUID for ID or additional project ID returns flag error before REST.
- Lookup failure (GetServiceEndpoint returns error) surfaces error and skips delete call.
- Delete call failure returns wrapped error message.
- JSON exporter output structure.
- Prompt decline returns
util.ErrCancel.
- Mock out IO streams to assert no extraneous output on errors.
References
- Azure CLI parity:
az devops service-endpoint delete - Azure CLI implementation:
service_endpoint.delete_service_endpoint - Azure DevOps REST API: Endpoints - Delete
- Example flows for shared endpoints and service principal cleanup: Automate service connections
- Project/organization parsing & progress indicator patterns: existing commands under
internal/cmd/*/delete.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1Priority 1Priority 1