Add restore-from-testing endpoint #11

Merged
benvin merged 1 commits from benvin/testing-restore into main 2026-11-08 17:39:29 +11:00
Member

Testing-scoped tokens can move a node to testing but nothing can move it back without a full-scope token or a terragrunt apply, because the prior environment is never stored.

  • add nullable nodes.previous_environment (FK to statuses, set null on delete)
  • record the old environment on entering testing via set-env or PutNode; clear it on any move to a non-testing env
  • add DELETE /api/v1/nodes/{certname}/environment/testing (testing tokens allowed): restores and returns the node, 409 if not in testing or nothing recorded
  • add client.RestoreFromTesting and encapi-cli node restore-env
Testing-scoped tokens can move a node to `testing` but nothing can move it back without a full-scope token or a terragrunt apply, because the prior environment is never stored. - add nullable `nodes.previous_environment` (FK to statuses, set null on delete) - record the old environment on entering testing via set-env or PutNode; clear it on any move to a non-testing env - add `DELETE /api/v1/nodes/{certname}/environment/testing` (testing tokens allowed): restores and returns the node, 409 if not in testing or nothing recorded - add `client.RestoreFromTesting` and `encapi-cli node restore-env`
unkin-agent added 1 commit 2026-11-08 17:28:59 +11:00
Add restore-from-testing endpoint using a recorded previous environment
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
519088b9ba
Author
Member
  • nit: internal/cli/cli_test.go:105 — memStore RestoreFromTesting has no ErrNoPreviousEnvironment branch (restores to ""), and SetNodeEnvironment (line 98) never clears on leaving testing; the fake diverges from the real rules → mirror the fakeStore switch in internal/server/server_test.go.
- nit: internal/cli/cli_test.go:105 — memStore `RestoreFromTesting` has no `ErrNoPreviousEnvironment` branch (restores to `""`), and `SetNodeEnvironment` (line 98) never clears on leaving testing; the fake diverges from the real rules → mirror the `fakeStore` switch in internal/server/server_test.go.
benvin merged commit 6302091323 into main 2026-11-08 17:39:29 +11:00
benvin deleted branch benvin/testing-restore 2026-11-08 17:39:29 +11:00
This repo is archived. You cannot comment on pull requests.