Skip to content

Cover every sg-sdk-go operation in the Go CLI - #41

Open
arunim2405 wants to merge 2 commits into
mainfrom
f/full-sdk-coverage
Open

Cover every sg-sdk-go operation in the Go CLI#41
arunim2405 wants to merge 2 commits into
mainfrom
f/full-sdk-coverage

Conversation

@arunim2405

Copy link
Copy Markdown
Member

Summary

Extends the Go CLI in go/ from the original workflow, stack and artifacts groups to every operation exposed by sg-sdk-go: 30 command groups, 230 leaf commands, 226 SDK methods covered. Existing commands, flags and output are unchanged apart from the two behaviour fixes below.

New groups: organization, user, role, role-binding, api-access, api-token, audit-log, benchmark-report, billing, secret, policy, connector, connector-group, runner-group, state-backend, resource, chat, workflow-group, workflow-run, stack-run, stack-workflow, stack-workflow-run, template, workflow-template, workflow-step-template, stack-template. workflow, stack and artifacts gain the operations that were missing (compare, outputs, update, VCS triggers, upload URLs, artifact read/create/delete/versions/rollback/locks).

Conventions follow the existing commands: --org (and --workflow-group/--workflow-id where relevant) as persistent flags, identifiers as flags, the JSON payload as the single argument after -- (or - for stdin), --patch-payload, --preview, --dry-run, --output-json. Shared plumbing lives in cmd/common (client construction, payload loading, raw-response JSON output, flag helpers).

Behaviour fixes

  • Command output now goes to stdout. cobra's cmd.Println defaults to stderr, so --output-json | jq never worked.
  • workflow create --bulk no longer dereferences a nil pointer when a workflow already exists and is updated instead.

Dependency: sg-sdk-go is bumped to the API-parity branch (StackGuardian/sg-sdk-go#36, commit 674afe6). Two SDK bugs found while validating this CLI were fixed there: retries after a 5xx were sent with an empty body (surfacing as an HTML 400 from the proxy), and connector-group create/update declared a form content type while sending JSON. This PR should be merged after that one and re-pointed at the tagged SDK release.

Docs

go/README.md documents the build, conventions, every command group, examples and the payload rules the API enforces (for example PolicyType on policy updates, OwnerOrg: /orgs/<org> and SourceConfigKind on template creates, Statefiles and StateBackendConfig.type on state backends). The top-level README links to it.

Test plan

  • go build ./..., go vet ./..., gofmt clean
  • Offline unit tests: go test ./tests/ -run 'TestCommandTree|TestMatrix|...' — 185 request/response matrix cases covering every new command (method, path, query, body, auth header, output), a pinned command-tree test (230 leaves) and the 13 pre-existing unit tests
  • Live read sweep on autotesting-org across all groups (org, users, roles, policies, API accesses, audit log, secrets, connectors, workflow groups, workflows, runs, logs, artifacts, templates and revisions, chats, billing, resource tags/search)
  • Live create → read → update → delete cycles with temporary sg-cli-validate-* resources: workflow group and child group, workflow, secret, role, policy, API access, connector, connector group, state backend, chat, workflow template, stack template, workflow step template and their revisions. All temporary resources were removed
  • Not exercised live: runner groups (disabled for the org), billing writes, workflow run triggers/approvals, chat PR creation, user invites, and endpoints that need a Cognito user token

🤖 Generated with Claude Code

https://claude.ai/code/session_01QFnDMC1JV9J4Hpk2oxwnAM

arunim2405 and others added 2 commits September 4, 2026 17:21
Extend the CLI from workflow/stack/artifacts to all 30 resource groups
exposed by the StackGuardian Go SDK (226 SDK methods, 230 leaf commands).

- Bump sg-sdk-go to the API-parity branch (commit e8047d5) and adapt the
  existing workflow commands to its type changes.
- Add cmd/common with shared client construction, raw-response JSON
  output, payload loading (--patch-payload/--preview/--dry-run), and flag
  helpers used by every new command.
- Add command groups: organization, user, role, role-binding, api-access,
  api-token, audit-log, benchmark-report, secret, policy, connector,
  connector-group, runner-group, state-backend, resource, billing, chat,
  workflow-group, stack-run, stack-workflow, workflow-run,
  stack-workflow-run, template, workflow-template,
  workflow-step-template, stack-template; extra subcommands attached to
  workflow, stack and artifacts.
- Add offline unit tests: a request/response matrix for every new
  command and a pinned command-tree test.
- Bump version to 2.2.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QFnDMC1JV9J4Hpk2oxwnAM
- Route command output to stdout so read commands and --output-json can
  be piped; cobra's default was stderr.
- Print the response for query-style commands (resource search, workflow
  and stack compare, connector list-accounts) instead of a message.
- Bump sg-sdk-go to 674afe6, which resends the request body on retries
  and sends connector groups as JSON; both were found while validating
  the CLI against a live organization.
- Document the Go CLI in go/README.md and link it from the top-level
  README, including the payload rules learned from the live run.
- Fix a pre-existing go vet warning in workflow create.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QFnDMC1JV9J4Hpk2oxwnAM
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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