Skip to content

Phase 6: ADO API client + all ado2gh commands (Go port)#1537

Draft
offbyone wants to merge 4 commits intoo1/golang-port/5from
o1/golang-port/6
Draft

Phase 6: ADO API client + all ado2gh commands (Go port)#1537
offbyone wants to merge 4 commits intoo1/golang-port/5from
o1/golang-port/6

Conversation

@offbyone
Copy link
Copy Markdown
Contributor

@offbyone offbyone commented Apr 1, 2026

Complete port of all ado2gh functionality from C# to Go. The ado2gh binary now has full feature parity with 19 commands (11 ADO-specific + 8 shared).

  • ADO REST API client (pkg/ado/) with ~35 methods covering orgs, team projects, repos, pipelines, service connections, identity, and permissions

  • Three pagination patterns: continuation-token, top/skip, binary-search count

  • Cooperative Retry-After throttle with exponential backoff, PAT-based auth

  • AdoInspectorService with caching, org/project/repo/pipeline discovery, PR counts, CSV loading

  • Commands: migrate-repo, generate-script, inventory-report, plus 8 simpler commands (lock-ado-repo, disable-ado-repo, add-team-to-repo, configure-autolink, share-service-connection, integrate-boards, rewire-pipeline, test-pipelines)

  • Extracted 8 shared commands into internal/sharedcmd/ for reuse between gei, ado2gh, and bbs2gh

  • All tests passing, 0 lint issues

  • Did you write/update appropriate tests

  • Release notes updated (if appropriate) — not user-facing yet (parallel Go port)

  • Appropriate logging output

  • Issue linked — tracking via PR stack

  • Docs updated (or issue created) — internal packages, covered by godoc

  • New package licenses are added to ThirdPartyNotices.txt (if applicable) — no new deps


PR Stack (Go port)

offbyone added 4 commits April 1, 2026 08:58
ADO Client (pkg/ado/client.go):
- Complete ADO REST API client with ~35 methods covering orgs, team projects,
  repos, pipelines, service connections, identity, and permissions
- Three pagination patterns: continuation-token, top/skip, binary-search count
- Cooperative Retry-After throttle with exponential backoff
- PAT-based auth (base64-encoded), configurable base URL for ADO Server
- 1559 lines implementation, 1431 lines tests, 74 lines models

ado2gh migrate-repo (cmd/ado2gh/migrate_repo.go):
- Full port of C# MigrateRepoCommandHandler with identical flag set
- Token validation, org existence checks, permission verification
- Queue-only mode support, wait-for-migration integration
- Consumer-defined interfaces, two-constructor pattern (test/live)
- 369 lines implementation, 414 lines tests (9 tests)

Also:
- Wired all remaining gei commands with live constructors (cmd/gei/wiring.go)
- Fixed permissions error message quoting (backticks) in gei + ado2gh
- Added gh-gei/, gh-ado2gh/, gh-bbs2gh/ to .gitignore
…t command

- Port AdoInspectorService to pkg/ado/inspector.go with caching, org/project/repo/pipeline discovery, PR counts, CSV loading, and ReplaceInvalidCharactersWithDash
- Port ado2gh generate-script command with all 17 flags, sequential and parallel script generation modes
- Three-level iteration (orgs → team projects → repos) with conditional team creation, service connection sharing, pipeline rewiring
- Two-phase parallel script: queue phase with ExecAndGetMigrationID + wait/post-migration phase with ExecBatch
- Add ExecBatchFunctionBlock and ValidateADOEnvVars to pkg/scriptgen/templates.go
- Wire generate-script into cmd/ado2gh/main.go
- 20+ inspector tests, 28 generate-script tests, all passing
- 0 lint issues in ado packages
…raction

Port all 8 ado2gh simple commands (Tasks 23a-f):
- lock-ado-repo, disable-ado-repo
- add-team-to-repo, configure-autolink
- share-service-connection, integrate-boards
- rewire-pipeline (with PipelineTriggerService ~557 lines)
- test-pipelines (with PipelineTestService ~274 lines)

Extract shared commands into internal/sharedcmd/ (Task 23g):
- Created 8 files in internal/sharedcmd/ with exported interfaces,
  Run*, Validate*, types, and constants for all commands shared
  between gei and ado2gh (wait-for-migration, abort-migration,
  download-logs, grant/revoke-migrator-role, create-team,
  generate-mannequin-csv, reclaim-mannequin)
- Updated cmd/gei/ files to be thin wrappers calling sharedcmd.*
- Created cmd/ado2gh/wiring.go with 8 Live constructors
- Wired all 18 commands into cmd/ado2gh/main.go

Lint fixes (Task 23h):
- Renamed AdoBranchPolicy* types to BranchPolicy* (revive stutter)
- Extracted "unknown" constant (goconst)
- Tagged switch and TrimPrefix (staticcheck)
- File permissions 0o600 (gosec)
- Removed dead code from cmd/gei/ after sharedcmd extraction
- Fixed misspelling in test comment
…ators

Add inventory-report command for ado2gh that generates CSV reports for ADO
orgs, team projects, repos, and pipelines. Includes:

- pkg/ado/csvgen.go: 4 CSV generator functions (orgs, team projects, repos,
  pipelines) with thousand-separator formatting, C#-compatible date/boolean
  formatting, and minimal mode support
- pkg/ado/csvgen_test.go: 15+ tests covering all generators and edge cases
- cmd/ado2gh/inventory_report.go: Command handler with proper flag validation,
  inspector setup, and sequential CSV generation
- cmd/ado2gh/inventory_report_test.go: 3+ handler tests
- pkg/ado/inspector.go: Added SetOrgFilter/GetOrgFilter methods for
  single-org inventory scoping
- Wired into cmd/ado2gh/main.go

All ADO-specific commands now complete (11 + 8 shared = 19 total).
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.

1 participant