Skip to content

Commit 030b081

Browse files
jaypipeschaptersix
andauthored
error if both --build-id and --unversioned used (#991)
The CLI documentation for the `--build-id` and `--unversioned` flags for the `temporal worker deployment set-current-version` command indicate that these flags are mutually exclusive: ``` > ./temporal worker deployment set-current-version --help <snip> --build-id string Build ID of the Worker Deployment Version. Required unless --unversioned is specified. --deployment-name string Name of the Worker Deployment. Required. -h, --help help for set-current-version --ignore-missing-task-queues Override protection to accidentally remove task queues. --unversioned Set unversioned workers as the target version. Cannot be used with --build-id. ``` However, there was no error returned if both `--build-id` and `--unversioned` were supplied on the command line. This commit returns an error indicating that the flags are mutually exclusive and adds a simple unit test verifying the behaviour. Signed-off-by: Jay Pipes <jay.pipes@temporal.io> Co-authored-by: Alex Stanfield <13949480+chaptersix@users.noreply.github.com>
1 parent c3447af commit 030b081

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

internal/temporalcli/commands.worker.deployment.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@ func (c *TemporalWorkerDeploymentSetCurrentVersionCommand) run(cctx *CommandCont
832832
}
833833
defer cl.Close()
834834

835+
if c.BuildId != "" && c.Unversioned {
836+
return fmt.Errorf("specify either --build-id or --unversioned, not both")
837+
}
838+
835839
token, err := c.Parent.getConflictToken(cctx, &getDeploymentConflictTokenOptions{
836840
safeMode: !c.Yes,
837841
safeModeMessage: "Current",

internal/temporalcli/commands.worker.deployment_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ func (s *SharedServerSuite) TestDeployment_Set_Current_Version() {
186186
s.NoError(res.Err)
187187
s.NoError(json.Unmarshal(res.Stdout.Bytes(), &jsonVersionOut))
188188
s.Nil(jsonVersionOut.Metadata)
189+
190+
// --build-id and --unversioned are either/or. there should be an error if
191+
// the user specifies both flags.
192+
res = s.Execute(
193+
"worker", "deployment", "set-current-version",
194+
"--address", s.Address(),
195+
"--deployment-name", version.DeploymentName, "--build-id", version.BuildID,
196+
"--unversioned",
197+
)
198+
s.Error(res.Err)
199+
s.ErrorContains(res.Err, "specify either --build-id or --unversioned")
189200
}
190201

191202
func (s *SharedServerSuite) TestDeployment_Set_Current_Version_AllowNoPollers() {

0 commit comments

Comments
 (0)