Skip to content

feat: Implement azdo pipelines variable-group variable delete command #127

Description

@tmeckel

This issue tracks the implementation of the azdo pipelines variable-group variable delete command.

Command Description

Remove a variable from a variable group. The Azure CLI locates the key case-insensitively, removes it from the variables map, and updates the group (source). azdo should provide the same behavior with confirmation support and consistent resolver helpers.

Important REST constraint:

  • Azure DevOps REST never returns secret variable values. This command must never attempt to print variable values (delete should not print values). Other variable commands must always treat secret values as unavailable and redact them.

azdo Command Signature

azdo pipelines variable-group variable delete [ORGANIZATION/]PROJECT/VARIABLE_GROUP_ID_OR_NAME --name VARIABLE_NAME [--yes]

Flags:

  • --yes: Skip the confirmation prompt.

Behavior

  • Parse [ORGANIZATION/]PROJECT/VARIABLE_GROUP_ID_OR_NAME using util.ParseProjectTargetWithDefaultOrganization.
  • Resolve the variable group ID-or-name using the shared helper shared.ResolveVariableGroup (do not re-implement ID/name resolution).
  • Fetch the variable group; error if it does not exist.
  • Locate the variable case-insensitively; return an error if missing.
  • Prompt for confirmation unless --yes is set (Delete variable 'VARIABLE_NAME' from group 'VARIABLE_GROUP'?). Return util.ErrCancel on decline.
  • Remove the entry, call UpdateVariableGroup, stop progress.
  • Output:
    • If stdout is connected to a TTY: print Variable deleted..
    • If stdout is not a TTY: emit no output on success.
  • No JSON output (delete is a side-effect command and only prints a success message on TTY).

Implementation Notes (filled checklist)

  • Implement command: internal/cmd/pipelines/variablegroup/variable/delete/delete.go (type opts struct, NewCmd(ctx), run(ctx, opts)).
  • Wire command: internal/cmd/pipelines/variablegroup/variable/variable.go must AddCommand(delete.NewCmd(ctx)) and be reachable from azdo pipelines variable-group variable.
  • Parse scope: util.ParseProjectTargetWithDefaultOrganization(ctx, targetArg) for [ORGANIZATION/]PROJECT/VARIABLE_GROUP_ID_OR_NAME; wrap parse errors with util.FlagErrorWrap.
  • Client: Task Agent via ctx.ClientFactory().TaskAgent(ctx.Context(), scope.Organization).
  • Resolve group: shared.ResolveVariableGroup(ctx, taskClient, scope.Project, scope.Target) where ctx is the injected util.CmdContext passed into NewCmd/run (do not use a differently-named context variable unless you define it explicitly).
  • Delete algorithm:
    • Locate variable key case-insensitively in the group variables map.
    • Confirm unless --yes; return util.ErrCancel on decline.
    • Remove key and call TaskAgent.UpdateVariableGroup.
  • Output:
    • If stdout is a TTY: print Variable deleted..
    • If stdout is not a TTY: no output on success.
  • Tests:
    • Add unit tests at internal/cmd/pipelines/variablegroup/variable/delete/delete_test.go.
    • Hermetic mocks: Task Agent client + prompter.
    • Table-driven cases: delete with --yes, prompt decline -> util.ErrCancel, variable not found, group not found, stdout TTY vs non-TTY output behavior.

Command Wiring

  • Implement the command in internal/cmd/pipelines/variablegroup/variable/delete/delete.go exposing NewCmd(ctx util.CmdContext) *cobra.Command.
  • Register it from internal/cmd/pipelines/variablegroup/variable/variable.go so azdo pipelines variable-group variable delete is discoverable.

SDK / Client Requirements

  • Requires the Task Agent client (ClientFactory().TaskAgent(...)). If the client is missing, follow "Handling Missing Azure DevOps SDK Clients" in AGENTS.md.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions