Skip to content

feat: Implement azdo pipelines variable-group list command #121

Description

@tmeckel

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

Command Description

List every variable group defined in a project with optional filtering. The CLI must fetch all pages automatically so that users never have to provide continuation tokens manually.

azdo Command Signature

azdo pipelines variable-group list [ORGANIZATION/]PROJECT [flags]

Flags:

  • --name: Wildcard pattern applied to the variable group name (groupName in the SDK).
  • --action: Action filter string (e.g., manage, use).
  • --top: Server-side page size hint (positive integer).
  • --order: asc or desc; map to idAscending / idDescending.
  • --max-items: Optional client-side cap on results; stop fetching once reached.
  • --continuation-token: Manual pagination token for debugging or partial results.
  • --group-type: Filter by variable group type (e.g., AzureKeyVault, Generic).
  • --include-details: Include additional details like variables, provider data, and project references. (By default only summary columns are shown.)
  • JSON export flags registering the same fields as the show/update commands (id, name, type, description, isShared, authorized, variables, variableGroupProjectReferences, providerData, etc.).

Behavior

  • Parse the scope argument using existing helpers so [ORGANIZATION/]PROJECT resolves the default organization when omitted.
  • Acquire IO streams, start the progress indicator, and ensure it stops before printing output.
  • Build taskagent.GetVariableGroupsArgs with the supplied filters (GroupName, ActionFilter, Top, QueryOrder, ContinuationToken).
  • Call a loader helper (e.g., azdo.GetVariableGroups) that mirrors azdo.GetProjects and loops through continuation tokens until the server stops issuing them. This makes --continuation-token unnecessary for end users; the command must return the complete set by default.
  • Respect --max-items by truncating the collected slice after pagination completes; log via zap.L().Debug when truncation happens.
  • Render default table columns: ID, NAME, TYPE, VARIABLE COUNT, DESCRIPTION. When --include-details is provided, add VARIABLE KEYS, AUTHORIZED, PROJECT REFERENCES, and PROVIDER DATA columns. Mask secret values.
  • For JSON export, emit { "variableGroups": [...] } with the view struct used by show, filtering fields according to the --include-details flag unless the user explicitly selects them via --json.
  • Validate --top and --max-items are positive integers and return an error for unknown --order or --group-type values.

Supporting Helpers

  • Add func GetVariableGroups(ctx context.Context, client taskagent.Client, args taskagent.GetVariableGroupsArgs) ([]taskagent.VariableGroup, string, error) to internal/azdo/loader.go. The helper should:
    • Invoke the client, append Value results when non-nil, and surface the last ContinuationToken for debugging (also returned when the user supplies --continuation-token).
    • Reissue requests with the server ContinuationToken until it is empty.
    • Handle numeric tokens similarly to GetProjects, returning wrapped errors when parsing fails.
  • Write focused unit tests for the helper using mocks to cover multi-page responses, token parsing failures, and error propagation.

Command Wiring

  • Implement the command in internal/cmd/pipelines/variablegroup/list/list.go with NewCmd(ctx util.CmdContext) *cobra.Command.
  • Register it from internal/cmd/pipelines/variablegroup/variablegroup.go so azdo pipelines variable-group list is reachable.
  • Regenerate documentation (make docs) after wiring.

SDK / Client Requirements

  • Requires the Task Agent client (ClientFactory().TaskAgent(...)) for listing variable groups. If the client is not yet exposed, follow “Handling Missing Azure DevOps SDK Clients” in AGENTS.md.

Tooling & Validation

  • Format new Go files with gofmt/goimports.
  • Run go build ./cmd/azdo/... (or make lint) to ensure imports and types are correct.
  • Add/update hermetic tests using mocks and run go test ./....

Testing

  • Unit tests verifying:
    1. Listing with a single page via the loader helper.
    2. Multi-page pagination without user-supplied continuation tokens.
    3. --max-items truncation.
    4. Invalid flag handling (--order, --top, --max-items, --group-type).
    5. JSON export structure.
    6. --include-details output with masked secrets.

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