Cover every sg-sdk-go operation in the Go CLI - #41
Open
arunim2405 wants to merge 2 commits into
Open
Conversation
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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Extends the Go CLI in
go/from the originalworkflow,stackandartifactsgroups to every operation exposed bysg-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,stackandartifactsgain 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-idwhere 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 incmd/common(client construction, payload loading, raw-response JSON output, flag helpers).Behaviour fixes
cmd.Printlndefaults to stderr, so--output-json | jqnever worked.workflow create --bulkno longer dereferences a nil pointer when a workflow already exists and is updated instead.Dependency:
sg-sdk-gois bumped to the API-parity branch (StackGuardian/sg-sdk-go#36, commit674afe6). 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.mddocuments the build, conventions, every command group, examples and the payload rules the API enforces (for examplePolicyTypeon policy updates,OwnerOrg: /orgs/<org>andSourceConfigKindon template creates,StatefilesandStateBackendConfig.typeon state backends). The top-level README links to it.Test plan
go build ./...,go vet ./...,gofmtcleango 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 testsautotesting-orgacross 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)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🤖 Generated with Claude Code
https://claude.ai/code/session_01QFnDMC1JV9J4Hpk2oxwnAM