feat(go): the remaining platform API areas as commands - #60
Merged
Merged
Conversation
…w-steps Interrupting `run --wait` (Ctrl-C, or a CI runner's SIGTERM) now cancels the run it started before exiting with 130 or 143, so an aborted pipeline no longer leaves an attack running; --keep-running-on-interrupt keeps the previous behaviour. --timeout cancels a run that takes too long. --report writes JUnit (or JSON) with a test case per step, and a Markdown summary goes to $GITHUB_STEP_SUMMARY in GitHub Actions.
Listings print the platform's items, in its order, with -t json or yaml instead of a table. --jq filters whatever JSON a command prints, strings raw and values as JSON like gh --jq; jq itself is not needed.
`uses: steadybit/cli@v5` installs the release binary for the runner, checked against checksums.txt. Released versions are verified on Linux, macOS and Windows runners after publishing. The README shows the action, a GitLab job with a JUnit report, and -t/--jq.
…es and profiles `<kind> diff -f files` prints a unified diff between each file and the platform and exits with 2 when they differ, so a pipeline can detect drift. Fields the platform fills in with defaults, and the key or id of a file matched by externalId or name, are not reported as differences. `apply --dry-run` reports what an apply would create or update.
`export --team X -d dir` writes a team's experiments, schedules and services, and the custom profiles they use, one kind per directory. `apply -d dir` applies them in dependency order (with --dry-run), and `diff -d dir` reports drift for all of them. Exporting a team from dev and diffing it straight back reports no differences for 107 files.
--profile <name> uses a configured profile for one command. Shell completion now offers experiment keys (team first, then its experiments), team keys, and template, schedule, service and profile ids with their names; without access it offers nothing and prints nothing.
`execution watch -i ID | -k KEY` follows a run live, redrawn in place on a terminal and a line per change otherwise; it never cancels the run. `experiment init` creates an experiment from a template by asking for its placeholders, team and environment, and writes it to a file. `experiment delete` had been left out of the Go port; it is back, and a test now pins every command of the TypeScript CLI. A timed-out run is reported once the platform has cancelled it, steps cut short count as errors, and table columns ignore colour codes. The fake platform prefers the most specific route and no longer paces requests.
# Conflicts: # internal/cli/experiment.go # internal/experiment/experiment_test.go
# Conflicts: # CHANGELOG.md
…t/go-api-parity # Conflicts: # CHANGELOG.md # README.md # internal/cli/root.go # internal/template/template.go
…ys and environment ids Environments, teams, their members and environments, integrations, hubs, property definitions and actions take -t json|yaml; access tokens and property associations take --output, as --type filters them already.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Adds the remaining platform API areas (group 1 of the ticket) as commands, one domain package per area under
internal/<area>, wired ininternal/cli/<area>.go. Where the API is versioned, only the latest version is used (access tokens:/api/access-tokens/v2only).Commands
template apply -f … [-R],template delete -i,template import --hub --template … [--overwrite]POST/DELETE /api/experiments/templates…,POST /api/experiments/templates/importsenvironment list|get|apply|delete,environment variable get|set [--replace]/api/environments…; variables:PUTmerges,POSTreplacesteam list|get|apply|delete,team member list|add|remove|set,team environment list|add|remove|set/api/teams…user invite --email … [--role] [--team]POST /api/users/inviteaccess-token list|create|recreate|delete/api/access-tokens/v2…integration webhook|slack|preflight|preflight-action list|get|apply|delete/api/integrations/…report users|teams|environments|experiments-executed|experiments-created|services-distribution|services-by-category|services-averagePOST /api/reports/…audit-log [--from] [--to] [-t]GET /api/audit-logkillswitch status|activate|deactivateGET/POST/DELETE /api/killswitchtarget query,target attribute keys|values,action list|get/api/targets…,/api/actions…hub list|get|apply|delete|resync/api/hubs…property definition list|get|apply|delete,property association list|get|apply|delete/api/properties/…Conventions follow the existing commands: files pass through as order-preserving documents,
getstrips what the platform does not take back (version,created*,edited*, hub sync state, team member details, ...) so thatget→applyround-trips,applygoes throughresource.ApplyFilesand writes a new id back first (not for teams and property definitions, which are named by their key), listings are tables withNo … found., paged endpoints are followed to the end.template getnow strips the same read-only fields asservice get, since templates can be applied now.Destructive commands ask on a terminal unless
--yesis given (likeexperiment run): every newdelete,killswitch activate,access-token recreate,team member set|remove,team environment set. New shared helpers ininternal/resource:Confirmed,Body,Optional,UUID,Time,Variables(the last one extracted fromservice variable set, now shared withenvironment variable set).Testing
Every group has command-level tests against
platformtestasserting method, path, query, body and output: 52 new test functions, 263 tests and subtests pass in total.gofmt -l,go vet ./...,go test ./...are clean after every commit.Live on the dev platform (tenant demo, ADM team token), only with resources named
cli-e2e-*, all deleted again and checked gone:template apply/get/deletecli-e2e-template, get → edit → apply, deletedenvironment *,environment variable *cli-e2e-environment, round trip, merge and--replace, deletedteam *,team environment *,team member *CLIE2E; environments added/set/removed; members add/set/remove only withcli-e2e@example.invalid(unknown, so skipped;--validaterefuses it); deletedaccess-token list/create/recreate/deletecli-e2e-tokenfor teamCLIE2E, expiring in 2 days; recreated, then deletedintegration webhook *cli-e2e-webhookpointing athttps://example.invalid/cli-e2e, deletedproperty definition *cli-e2e-property, created, updated, deletedreport *(all eight),killswitch status,target query/attribute,action list/get,hub list/get,integration slack/preflight/preflight-action list/get,property association list,audit-logUnit tests only, and why:
killswitch activate/deactivate: activating stops every experiment of the tenant.user invite: sends emails to real people.template import,hub apply/delete/resync: sync external repositories.property association apply/delete: the ADM token gets 403 (Missing permissions to create property associations), which needs an admin token.integration slack/preflight/preflight-action apply/delete: only a webhook integration was allowed to be created live; the code is shared by the four kinds.audit-logreturned no entries for the team token (200 with[]); a 9-month range timed out on dev. Table and JSON rendering are unit-tested.Awkward spots in the spec and the platform
GETreturns the secret masked ('****'),POSTrejects the mask (422), and leavingsecretout removes it. So a secret cannot round-trip;integration * applyrefuses a file still holding the mask and says to put the secret in or remove it.purgeIncludingExperiments=falsegets400with no body, even for a team without experiments.team deleteexplains that--purge-experimentsis needed.GET /api/environments/{id}/variablesis declared as returning astring; it returns the map of variables.GET /api/actionspages underactionsinstead ofitems, so it cannot useplatform.AllPages;GET /api/properties/associationstakes only a page number (no size), while definitions take aPageRequestAO.MONTHLYbuckets start atfrom, not at the month start.K7DcJbgf), not UUIDs;access-token createhas a--type(token type), so its output format flag is-t, --output.template importwithouttemplateIdsis not described in the spec; the CLI requires--template.schedule applyandservice applyalready do; only experiment files keep their formatting.