feat: toggle the enabled state of workers - #731
Draft
NickJosevski wants to merge 2 commits into
Draft
NickJosevski wants to merge 2 commits into
NickJosevski wants to merge 2 commits into
Conversation
This was referenced Sep 15, 2026
NickJosevski
force-pushed
the
nj/issue-311
branch
from
September 15, 2026 07:25
3c53db2 to
db73ca7
Compare
Moves the shared enable/disable logic out of pkg/cmd/target/shared and into pkg/machinescommon, behind a Machine interface and a MachineKind describing one machine repository. Deployment targets keep the behaviour and output they had; workers can now reuse it. The noun in the prompt, the "already enabled" message and the "no ... to disable were found" error all come from the kind, so there is one copy of the flow rather than one per machine type. Also parameterises the --disabled help text by noun, the way RegisterCreateTargetProxyFlags already does. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Adds `octopus worker enable|disable [<name> | <id>]` and a `--disabled` flag on `worker listening-tentacle create` and `worker ssh create`, mirroring the deployment-target commands exactly: same prompt when no identifier is given, same short circuit when the worker is already in the requested state, and the flag is included in the generated automation command. Test support: a worker fixture, and the Workers link on the fake root resource so command tests can reach the workers endpoints. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
NickJosevski
force-pushed
the
nj/issue-311-workers
branch
from
September 15, 2026 07:27
cdf0737 to
bf83e07
Compare
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.
Stacked on #694 — merges into
nj/issue-311, notmain. Review #694 first.Answers the "should workers get the same treatment?" question on #694: yes.
What changed
Refactor first — the enable/disable flow moves from
pkg/cmd/target/shared/disabledstate.gointopkg/machinescommon, behind aMachineinterface and aMachineKindthat describes one machine repository. The noun in the prompt, the "already enabled" message and the "no ... to disable were found" error all come from the kind, so there is one copy of the flow instead of one per machine type. Deployment targets keep exactly the behaviour and output they had.New commands —
octopus worker enable [<name> | <id>]andoctopus worker disable [<name> | <id>], mirroring the deployment-target pair: prompts when no identifier is given (offering only workers not already in the requested state), short circuits without an update call when the worker is already in that state, errors under--no-promptwhen no identifier is supplied.New create flag —
--disabledonworker listening-tentacle createandworker ssh create(the two worker types with acreatecommand), included in the generated automation command. Flag-only, no prompt — same as the target side.--disabled's help text is now parameterised by noun, the wayRegisterCreateTargetProxyFlagsalready is.Test evidence
pkg/machinescommon/disabledstate_test.go— the prompt flow against a fakeMachine, covering both nouns; replaces the oldpkg/cmd/target/shared/disabledstate_test.go.pkg/cmd/worker/enable/enable_test.go,pkg/cmd/worker/disable/disable_test.go— end-to-end through the root command against the mock HTTP server: named worker, already-in-state short circuit, interactive prompt. The PUT body is asserted to carry the flippedIsDisabled.pkg/cmd/worker/worker_test.go—enable/disableregistered, and both workercreatecommands expose--disabled.test/integration/worker_test.go— mirrors the deployment-target integration test, including that a toggle leaves the worker's other settings untouched.go build ./...clean;go test ./pkg/...all pass. Both integration tests (TestWorkerEnableDisableand the existingTestDeploymentTargetEnableDisable, to check the refactor) run green against a local Octopus instance.gofmt/go vetreport only pre-existing issues in files this PR does not touch.🤖 Generated with Claude Code