Skip to content

feat: Implement azdo service-endpoint create command #63

@tmeckel

Description

@tmeckel

This issue tracks the implementation of the azdo service-endpoint create command.

Command Description

Create a service endpoint from a configuration file, allowing users to import pre-defined connections.

azdo Command Signature

azdo service-endpoint create [ORGANIZATION/]PROJECT --from-file PATH [--encoding ENCODING]

Arguments & Flags:

  • [ORGANIZATION/]PROJECT: Required project scope. When the organization segment is omitted, fall back to the configured default organization.
  • --from-file: Path to a JSON file containing the service endpoint definition (required).
  • --encoding: Optional file encoding (utf-8 default, allow ascii, utf-16be, utf-16le).
  • JSON exporter flags (optional) to emit the created endpoint.

Behavior

  • Resolve scope using the shared helper; open the file using the specified encoding.
  • Validate that the JSON payload matches serviceendpoint.ServiceEndpoint expectations; rewrite organization/project fields as needed before sending to Azure DevOps.
  • Use ServiceEndpointClient.CreateServiceEndpoint to create the connection.
  • Stop the progress indicator before output; render a concise summary (ID, name, type) and support JSON output.
  • Add debug logging for file resolution and payload validation (avoid logging secrets).

Command Wiring

  • Implement the command in internal/cmd/serviceendpoint/create/create.go (or similar) with NewCmd(ctx util.CmdContext) *cobra_Command.
  • Register it from internal/cmd/serviceendpoint/serviceendpoint.go so azdo service-endpoint create is accessible from the root CLI.
  • Regenerate documentation (make docs) once wiring is complete.

SDK / Client Requirements

  • Uses the Service Endpoint client (ClientFactory().ServiceEndpoint(...)). If any additional Azure DevOps client is required, follow "Handling Missing Azure DevOps SDK Clients" in AGENTS.md (extend ClientFactory, run go mod tidy and go mod vendor, update scripts/generate_mocks.sh, and implement the factory method) before implementing the command.

Tooling & Validation

  • Format new Go files with gofmt/goimports.
  • Run go build ./cmd/azdo/... to ensure the CLI compiles.
  • Add/update hermetic tests using mocks (Service Endpoint client, file loading) and execute go test ./....

Testing

  • Unit tests covering:
    1. Successful creation with UTF-8 file.
    2. Alternate encoding handling.
    3. Invalid JSON structure raising a descriptive error.
    4. Service Endpoint SDK error propagation.
    5. JSON export structure.

References

Sub-issues

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