From 96d0cbc00cdcdbd2f835ec9bcf18fd30b1e9183b Mon Sep 17 00:00:00 2001 From: Antonio Lain Date: Mon, 6 Jan 2025 15:19:19 +0000 Subject: [PATCH 1/4] Add Deployment API support --- go.mod | 2 +- go.sum | 4 +- temporalcli/commands.deployment.go | 382 +++++++++++++++++++++ temporalcli/commands.deployment_test.go | 191 +++++++++++ temporalcli/commands.gen.go | 211 +++++++++++- temporalcli/commands.workflow.go | 115 +++++++ temporalcli/commands.workflow_test.go | 188 ++++++++++ temporalcli/commands.workflow_view.go | 26 ++ temporalcli/commands.workflow_view_test.go | 75 ++++ temporalcli/commands_test.go | 1 + temporalcli/commandsgen/commands.yml | 305 ++++++++++++++-- 11 files changed, 1470 insertions(+), 30 deletions(-) create mode 100644 temporalcli/commands.deployment.go create mode 100644 temporalcli/commands.deployment_test.go diff --git a/go.mod b/go.mod index 9427b3a56..304c7d09f 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/temporalio/ui-server/v2 v2.32.0 go.temporal.io/api v1.43.0 go.temporal.io/sdk v1.31.1-0.20241212214416-ccb28ef56de8 - go.temporal.io/server v1.26.2-124.0.0.20241213230717-4f9d034f1379 + go.temporal.io/server v1.26.2 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 57a0e5782..a82669f81 100644 --- a/go.sum +++ b/go.sum @@ -361,8 +361,8 @@ go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg= go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis= go.temporal.io/sdk v1.31.1-0.20241212214416-ccb28ef56de8 h1:In+R+QZqd4sm9XUmEPpaTz6xe0n2NTPoEhtgsjOFXUk= go.temporal.io/sdk v1.31.1-0.20241212214416-ccb28ef56de8/go.mod h1:8U8H7rF9u4Hyb4Ry9yiEls5716DHPNvVITPNkgWUwE8= -go.temporal.io/server v1.26.2-124.0.0.20241213230717-4f9d034f1379 h1:bswOZj8b5y8bb/v4mVYcrOU2jjIsIgPZN0WIzOKVWnc= -go.temporal.io/server v1.26.2-124.0.0.20241213230717-4f9d034f1379/go.mod h1:tgY+4z/PuIdqs6ouV1bT90RWSWfEioWkzmrNrLYLUrk= +go.temporal.io/server v1.26.2 h1:vDW11lxslYPlGDbQklWi/tqbkVZ2ExtRO1jNjvZmUUI= +go.temporal.io/server v1.26.2/go.mod h1:tgY+4z/PuIdqs6ouV1bT90RWSWfEioWkzmrNrLYLUrk= go.temporal.io/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig= go.temporal.io/version v0.3.0/go.mod h1:UA9S8/1LaKYae6TyD9NaPMJTZb911JcbqghI2CBSP78= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= diff --git a/temporalcli/commands.deployment.go b/temporalcli/commands.deployment.go new file mode 100644 index 000000000..859154903 --- /dev/null +++ b/temporalcli/commands.deployment.go @@ -0,0 +1,382 @@ +package temporalcli + +import ( + "fmt" + "time" + + "github.com/fatih/color" + "github.com/temporalio/cli/temporalcli/internal/printer" + "go.temporal.io/sdk/client" + "go.temporal.io/api/common/v1" + +) + +type taskQueuesInfosRowType struct { + Name string `json:"name"` + Type string `json:"type"` + FirstPollerTime time.Time `json:"firstPollerTime"` +} + +type deploymentType struct { + SeriesName string `json:"seriesName"` + BuildID string `json:"buildId"` +} + +type formattedDeploymentInfoType struct { + Deployment deploymentType `json:"deployment"` + CreateTime time.Time `json:"createTime"` + IsCurrent bool `json:"isCurrent"` + TaskQueuesInfos []taskQueuesInfosRowType `json:"taskQueuesInfos,omitempty"` + Metadata map[string]*common.Payload `json:"metadata,omitempty"` +} + +type formattedDeploymentReachabilityInfoType struct { + DeploymentInfo formattedDeploymentInfoType `json:"deploymentInfo"` + Reachability string `json:"reachability"` + LastUpdateTime time.Time `json:"lastUpdateTime"` +} + +type formattedDeploymentListEntryType struct { + SeriesName string + BuildID string + CreateTime time.Time + IsCurrent bool +} + +type formattedDualDeploymentInfoType struct { + Previous formattedDeploymentInfoType `json:"previous"` + Current formattedDeploymentInfoType `json:"current"` +} + + +func formatTaskQueuesInfos(tqis []client.DeploymentTaskQueueInfo) ([]taskQueuesInfosRowType, error) { + var tqiRows []taskQueuesInfosRowType + for _, tqi := range tqis { + tqTypeStr, err := taskQueueTypeToStr(tqi.Type) + if err != nil { + return tqiRows, err + } + tqiRows = append(tqiRows, taskQueuesInfosRowType{ + Name: tqi.Name, + Type: tqTypeStr, + FirstPollerTime: tqi.FirstPollerTime, + }) + } + return tqiRows, nil +} + +func deploymentInfoToRows(deploymentInfo client.DeploymentInfo) (formattedDeploymentInfoType, error) { + tqi, err := formatTaskQueuesInfos(deploymentInfo.TaskQueuesInfos) + if err != nil { + return formattedDeploymentInfoType{}, err + } + + return formattedDeploymentInfoType{ + Deployment: deploymentType{ + SeriesName: deploymentInfo.Deployment.SeriesName, + BuildID: deploymentInfo.Deployment.BuildID, + }, + CreateTime: deploymentInfo.CreateTime, + IsCurrent: deploymentInfo.IsCurrent, + TaskQueuesInfos: tqi, + Metadata: deploymentInfo.Metadata, + }, nil +} + +func printDeploymentInfo(cctx *CommandContext, deploymentInfo client.DeploymentInfo, msg string) error { + + fDeploymentInfo, err := deploymentInfoToRows(deploymentInfo) + if err != nil { + return err + } + + if !cctx.JSONOutput { + cctx.Printer.Println(color.MagentaString(msg)) + printMe := struct { + SeriesName string + BuildID string + CreateTime time.Time + IsCurrent bool + Metadata map[string]*common.Payload `cli:",cardOmitEmpty"` + }{ + SeriesName: deploymentInfo.Deployment.SeriesName, + BuildID: deploymentInfo.Deployment.BuildID, + CreateTime: deploymentInfo.CreateTime, + IsCurrent: deploymentInfo.IsCurrent, + Metadata: deploymentInfo.Metadata, + } + err := cctx.Printer.PrintStructured(printMe, printer.StructuredOptions{}) + if err != nil { + return fmt.Errorf("displaying deployment info failed: %w", err) + } + + if len(deploymentInfo.TaskQueuesInfos) > 0 { + cctx.Printer.Println() + cctx.Printer.Println(color.MagentaString("Task Queues:")) + err := cctx.Printer.PrintStructured( + deploymentInfo.TaskQueuesInfos, + printer.StructuredOptions{Table: &printer.TableOptions{}}, + ) + if err != nil { + return fmt.Errorf("displaying task queues info failed: %w", err) + } + } + + return nil + } + + // json output + return cctx.Printer.PrintStructured(fDeploymentInfo, printer.StructuredOptions{}) +} + +func deploymentReachabilityTypeToStr(reachabilityType client.DeploymentReachability) (string, error) { + switch reachabilityType { + case client.DeploymentReachabilityUnspecified: + return "unspecified", nil + case client.DeploymentReachabilityReachable: + return "reachable", nil + case client.DeploymentReachabilityClosedWorkflows: + return "closed", nil + case client.DeploymentReachabilityUnreachable: + return "unreachable", nil + default: + return "", fmt.Errorf("unrecognized deployment reachability type: %d", reachabilityType) + } +} + +func printDeploymentReachabilityInfo(cctx *CommandContext, reachability client.DeploymentReachabilityInfo) error { + fDeploymentInfo, err := deploymentInfoToRows(reachability.DeploymentInfo) + if err != nil { + return err + } + + rTypeStr, err := deploymentReachabilityTypeToStr(reachability.Reachability) + if err != nil { + return err + } + + fReachabilityInfo := formattedDeploymentReachabilityInfoType{ + DeploymentInfo: fDeploymentInfo, + LastUpdateTime: reachability.LastUpdateTime, + Reachability: rTypeStr, + } + + if !cctx.JSONOutput { + err := printDeploymentInfo(cctx, reachability.DeploymentInfo, "Deployment:") + if err != nil { + return err + } + + cctx.Printer.Println() + cctx.Printer.Println(color.MagentaString("Reachability:")) + printMe := struct { + LastUpdateTime time.Time + Reachability string + }{ + LastUpdateTime: fReachabilityInfo.LastUpdateTime, + Reachability: fReachabilityInfo.Reachability, + } + return cctx.Printer.PrintStructured(printMe, printer.StructuredOptions{}) + } + + // json output + return cctx.Printer.PrintStructured(fReachabilityInfo, printer.StructuredOptions{}) +} + +func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.DeploymentSetCurrentResponse) error { + + if !cctx.JSONOutput { + err := printDeploymentInfo(cctx, response.Previous, "Previous Deployment:") + if err != nil { + return fmt.Errorf("displaying previous deployment info failed: %w", err) + } + + err = printDeploymentInfo(cctx, response.Current, "Current Deployment:") + if err != nil { + return fmt.Errorf("displaying current deployment info failed: %w", err) + } + + return nil + } + + previous, err := deploymentInfoToRows(response.Previous) + if err != nil { + return fmt.Errorf("displaying previous deployment info failed: %w", err) + } + current, err := deploymentInfoToRows(response.Current) + if err != nil { + return fmt.Errorf("displaying current deployment info failed: %w", err) + } + + return cctx.Printer.PrintStructured(formattedDualDeploymentInfoType{ + Previous: previous, + Current: current, + }, printer.StructuredOptions{}) +} + +func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []string) error { + cl, err := c.Parent.ClientOptions.dialClient(cctx) + if err != nil { + return err + } + defer cl.Close() + + if c.ReportReachability { + // Expensive call, rate-limited by target method + resp, err := cl.DeploymentClient().GetReachability(cctx, client.DeploymentGetReachabilityOptions{ + Deployment: client.Deployment{ + SeriesName: c.DeploymentSeriesName, + BuildID: c.DeploymentBuildId, + }, + }) + if err != nil { + return fmt.Errorf("error describing deployment with reachability: %w", err) + } + + err = printDeploymentReachabilityInfo(cctx, resp) + if err != nil { + return err + } + } else { + resp, err := cl.DeploymentClient().Describe(cctx, client.DeploymentDescribeOptions{ + Deployment: client.Deployment{ + SeriesName: c.DeploymentSeriesName, + BuildID: c.DeploymentBuildId, + }, + }) + if err != nil { + return fmt.Errorf("error describing deployment: %w", err) + } + err = printDeploymentInfo(cctx, resp.DeploymentInfo, "Deployment:") + if err != nil { + return err + } + + } + + return nil +} + + +func (c *TemporalDeploymentGetCurrentCommand) run(cctx *CommandContext, args []string) error { + cl, err := c.Parent.ClientOptions.dialClient(cctx) + if err != nil { + return err + } + defer cl.Close() + + resp, err := cl.DeploymentClient().GetCurrent(cctx, client.DeploymentGetCurrentOptions{ + SeriesName: c.DeploymentSeriesName, + }) + if err != nil { + return fmt.Errorf("error getting the current deployment: %w", err) + } + + err = printDeploymentInfo(cctx, resp.DeploymentInfo, "Current Deployment:") + if err != nil { + return err + } + + return nil +} + + +func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) error { + cl, err := c.Parent.dialClient(cctx) + if err != nil { + return err + } + defer cl.Close() + + res, err := cl.DeploymentClient().List(cctx, client.DeploymentListOptions{ + SeriesName: c.DeploymentSeriesName, + }) + if err != nil { + return err + } + + // This is a listing command subject to json vs jsonl rules + cctx.Printer.StartList() + defer cctx.Printer.EndList() + + printTableOpts := printer.StructuredOptions{ + Table: &printer.TableOptions{}, + } + + // make artificial "pages" so we get better aligned columns + page := make([]*formattedDeploymentListEntryType, 0, 100) + + for res.HasNext() { + entry, err := res.Next() + if err != nil { + return err + } + listEntry := formattedDeploymentInfoType{ + Deployment: deploymentType{ + SeriesName: entry.Deployment.SeriesName, + BuildID: entry.Deployment.BuildID, + }, + CreateTime: entry.CreateTime, + IsCurrent: entry.IsCurrent, + } + if cctx.JSONOutput { + // For JSON dump one line of JSON per deployment + _ = cctx.Printer.PrintStructured(listEntry, printer.StructuredOptions{}) + } else { + // For non-JSON, we are doing a table for each page + page = append(page, &formattedDeploymentListEntryType{ + SeriesName: listEntry.Deployment.SeriesName, + BuildID: listEntry.Deployment.BuildID, + CreateTime: listEntry.CreateTime, + IsCurrent: listEntry.IsCurrent, + }) + if len(page) == cap(page) { + _ = cctx.Printer.PrintStructured(page, printTableOpts) + page = page[:0] + printTableOpts.Table.NoHeader = true + } + } + } + + if !cctx.JSONOutput { + // Last partial page for non-JSON + _ = cctx.Printer.PrintStructured(page, printTableOpts) + } + + return nil +} + + +func (c *TemporalDeploymentUpdateCurrentCommand) run(cctx *CommandContext, args []string) error { + cl, err := c.Parent.dialClient(cctx) + if err != nil { + return err + } + defer cl.Close() + + metadata, err := stringKeysJSONValues(c.DeploymentMetadata, false); + if err != nil { + return fmt.Errorf("invalid metadata values: %w", err) + } + + resp, err := cl.DeploymentClient().SetCurrent(cctx, client.DeploymentSetCurrentOptions{ + Deployment: client.Deployment{ + SeriesName: c.DeploymentSeriesName, + BuildID: c.DeploymentBuildId, + }, + MetadataUpdate: client.DeploymentMetadataUpdate{ + UpsertEntries: metadata, + }, + }) + if err != nil { + return fmt.Errorf("error updating the current deployment: %w", err) + } + + err = printDeploymentSetCurrentResponse(cctx, resp) + if err != nil { + return err + } + + cctx.Printer.Println("Successfully updating the current deployment") + return nil +} diff --git a/temporalcli/commands.deployment_test.go b/temporalcli/commands.deployment_test.go new file mode 100644 index 000000000..ff273f242 --- /dev/null +++ b/temporalcli/commands.deployment_test.go @@ -0,0 +1,191 @@ +package temporalcli_test + +import ( + "encoding/base64" + "encoding/json" + "sort" + "time" + + "github.com/google/uuid" + "go.temporal.io/api/common/v1" +) + +type jsonTaskQueuesInfosRowType struct { + Name string `json:"name"` + Type string `json:"type"` + FirstPollerTime time.Time `json:"firstPollerTime"` +} + +type jsonDeploymentType struct { + SeriesName string `json:"seriesName"` + BuildID string `json:"buildId"` +} + +type jsonDeploymentInfoType struct { + Deployment jsonDeploymentType `json:"deployment"` + CreateTime time.Time `json:"createTime"` + IsCurrent bool `json:"isCurrent"` + TaskQueuesInfos []jsonTaskQueuesInfosRowType `json:"taskQueuesInfos,omitempty"` + Metadata map[string]*common.Payload `json:"metadata,omitempty"` +} + +type jsonDeploymentReachabilityInfoType struct { + DeploymentInfo jsonDeploymentInfoType `json:"deploymentInfo"` + Reachability string `json:"reachability"` + LastUpdateTime time.Time `json:"lastUpdateTime"` +} + +type jsonDeploymentListEntryType struct { + Deployment jsonDeploymentType `json:"deployment"` + CreateTime time.Time `json:"createTime"` + IsCurrent bool `json:"isCurrent"` +} + +func (s *SharedServerSuite) TestDeployment_Update_Current() { + seriesName := uuid.NewString() + buildId := uuid.NewString() + + res := s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId, + "--deployment-metadata", "bar=1", + ) + s.NoError(res.Err) + + res = s.Execute( + "deployment", "get-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + ) + s.NoError(res.Err) + + s.ContainsOnSameLine(res.Stdout.String(), "SeriesName", seriesName) + s.ContainsOnSameLine(res.Stdout.String(), "BuildID", buildId) + s.ContainsOnSameLine(res.Stdout.String(), "IsCurrent", "true") + s.ContainsOnSameLine(res.Stdout.String(), "Metadata", "data:\"1\"") + + // json + res = s.Execute( + "deployment", "get-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--output", "json", + ) + s.NoError(res.Err) + + var jsonOut jsonDeploymentInfoType + s.NoError(json.Unmarshal(res.Stdout.Bytes(), &jsonOut)) + s.Equal(jsonDeploymentType{SeriesName: seriesName, BuildID: buildId}, jsonOut.Deployment) + s.True(jsonOut.IsCurrent) + // "1" is "MQ==" + s.Equal("MQ==", base64.StdEncoding.EncodeToString(jsonOut.Metadata["bar"].GetData())) + // "json/plain" is "anNvbi9wbGFpbg==" + s.Equal("anNvbi9wbGFpbg==", base64.StdEncoding.EncodeToString(jsonOut.Metadata["bar"].GetMetadata()["encoding"])) +} + +func (s *SharedServerSuite) TestDeployment_List() { + seriesName := uuid.NewString() + buildId1 := uuid.NewString() + buildId2 := uuid.NewString() + + res := s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId1, + ) + s.NoError(res.Err) + + res = s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId2, + ) + s.NoError(res.Err) + + res = s.Execute( + "deployment", "list", + "--address", s.Address(), + "--deployment-series-name", seriesName, + ) + s.NoError(res.Err) + + s.ContainsOnSameLine(res.Stdout.String(), seriesName, buildId1, "now", "false") + s.ContainsOnSameLine(res.Stdout.String(), seriesName, buildId2, "now", "true") + + // json + res = s.Execute( + "deployment", "list", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--output", "json", + ) + s.NoError(res.Err) + + var jsonOut []jsonDeploymentListEntryType + s.NoError(json.Unmarshal(res.Stdout.Bytes(), &jsonOut)) + sort.Slice(jsonOut, func(i, j int) bool { + return jsonOut[i].CreateTime.Before(jsonOut[j].CreateTime) + }) + s.Equal(len(jsonOut), 2) + s.Equal(jsonDeploymentType{SeriesName: seriesName, BuildID: buildId1}, jsonOut[0].Deployment) + s.True(!jsonOut[0].IsCurrent) + s.Equal(jsonDeploymentType{SeriesName: seriesName, BuildID: buildId2}, jsonOut[1].Deployment) + s.True(jsonOut[1].IsCurrent) +} + +func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { + seriesName := uuid.NewString() + buildId1 := uuid.NewString() + buildId2 := uuid.NewString() + + res := s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId1, + ) + s.NoError(res.Err) + + res = s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId2, + ) + s.NoError(res.Err) + + res = s.Execute( + "deployment", "describe", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId1, + "--report-reachability", + ) + s.NoError(res.Err) + + s.ContainsOnSameLine(res.Stdout.String(), "SeriesName", seriesName) + s.ContainsOnSameLine(res.Stdout.String(), "BuildID", buildId1) + s.ContainsOnSameLine(res.Stdout.String(), "IsCurrent", "false") + s.ContainsOnSameLine(res.Stdout.String(), "Reachability", "unreachable") + + // json + res = s.Execute( + "deployment", "describe", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId2, + "--report-reachability", + "--output", "json", + ) + s.NoError(res.Err) + + var jsonOut jsonDeploymentReachabilityInfoType + s.NoError(json.Unmarshal(res.Stdout.Bytes(), &jsonOut)) + s.Equal(jsonDeploymentType{SeriesName: seriesName, BuildID: buildId2}, jsonOut.DeploymentInfo.Deployment) + s.True(jsonOut.DeploymentInfo.IsCurrent) + s.Equal(jsonOut.Reachability, "reachable") +} diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index c01963a0d..23fd5dfd6 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -131,6 +131,18 @@ func (v *WorkflowReferenceOptions) buildFlags(cctx *CommandContext, f *pflag.Fla f.StringVarP(&v.RunId, "run-id", "r", "", "Run ID.") } +type DeploymentReferenceOptions struct { + DeploymentSeriesName string + DeploymentBuildId string +} + +func (v *DeploymentReferenceOptions) buildFlags(cctx *CommandContext, f *pflag.FlagSet) { + f.StringVar(&v.DeploymentSeriesName, "deployment-series-name", "", "Series Name for a Deployment. Required.") + _ = cobra.MarkFlagRequired(f, "deployment-series-name") + f.StringVar(&v.DeploymentBuildId, "deployment-build-id", "", "Build ID for a Deployment. Required.") + _ = cobra.MarkFlagRequired(f, "deployment-build-id") +} + type SingleWorkflowOrBatchOptions struct { WorkflowId string Query string @@ -291,6 +303,7 @@ func NewTemporalCommand(cctx *CommandContext) *TemporalCommand { s.Command.Args = cobra.NoArgs s.Command.AddCommand(&NewTemporalActivityCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalBatchCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalDeploymentCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalEnvCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalOperatorCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalScheduleCommand(cctx, &s).Command) @@ -521,6 +534,144 @@ func NewTemporalBatchTerminateCommand(cctx *CommandContext, parent *TemporalBatc return &s } +type TemporalDeploymentCommand struct { + Parent *TemporalCommand + Command cobra.Command + ClientOptions +} + +func NewTemporalDeploymentCommand(cctx *CommandContext, parent *TemporalCommand) *TemporalDeploymentCommand { + var s TemporalDeploymentCommand + s.Parent = parent + s.Command.Use = "deployment" + s.Command.Short = "Describe, list, and operate on Deployments" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n\x1b[1mtemporal deployment [command] [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal deployment list\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n```\ntemporal deployment [command] [options]\n```\n\nFor example:\n\n```\ntemporal deployment list\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.AddCommand(&NewTemporalDeploymentDescribeCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalDeploymentGetCurrentCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalDeploymentListCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalDeploymentUpdateCurrentCommand(cctx, &s).Command) + s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags()) + return &s +} + +type TemporalDeploymentDescribeCommand struct { + Parent *TemporalDeploymentCommand + Command cobra.Command + DeploymentReferenceOptions + ReportReachability bool +} + +func NewTemporalDeploymentDescribeCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentDescribeCommand { + var s TemporalDeploymentDescribeCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "describe [flags]" + s.Command.Short = "Show properties of a Deployment" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Deployment, such as whether it is current,\nsome custom metadata, or a list of its task queues.\n\n\x1b[1mtemporal deployment describe [options]\x1b[0m\n\nFor example, to also include reachability information:\n\n\x1b[1mtemporal deployment describe \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId \\\n --report-reachability\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Deployment, such as whether it is current,\nsome custom metadata, or a list of its task queues.\n\n```\ntemporal deployment describe [options]\n```\n\nFor example, to also include reachability information:\n\n```\ntemporal deployment describe \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId \\\n --report-reachability\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().BoolVar(&s.ReportReachability, "report-reachability", false, "Flag to include reachability information of a Deployment.") + s.DeploymentReferenceOptions.buildFlags(cctx, s.Command.Flags()) + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + +type TemporalDeploymentGetCurrentCommand struct { + Parent *TemporalDeploymentCommand + Command cobra.Command + DeploymentSeriesName string +} + +func NewTemporalDeploymentGetCurrentCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentGetCurrentCommand { + var s TemporalDeploymentGetCurrentCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "get-current [flags]" + s.Command.Short = "Show the current Deployment" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Deployment for a Deployment Series Name. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n\n\x1b[1mtemporal deployment get-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal deployment get-current \\\n --deployment-series-name YourDeploymentSeriesName\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Deployment for a Deployment Series Name. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n\n```\ntemporal deployment get-current [options]\n```\n\nFor example:\n\n```\ntemporal deployment get-current \\\n --deployment-series-name YourDeploymentSeriesName\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().StringVar(&s.DeploymentSeriesName, "deployment-series-name", "", "Series Name for the current Deployment. Required.") + _ = cobra.MarkFlagRequired(s.Command.Flags(), "deployment-series-name") + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + +type TemporalDeploymentListCommand struct { + Parent *TemporalDeploymentCommand + Command cobra.Command + DeploymentSeriesName string +} + +func NewTemporalDeploymentListCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentListCommand { + var s TemporalDeploymentListCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "list [flags]" + s.Command.Short = "Enumerate Deployments in the client's namespace" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n\x1b[1mtemporal deployment list [options]\x1b[0m\n\nFor example, adding an optional filter:\n\n\x1b[1mtemporal deployment list \\\n --deployment-series-name YourDeploymentSeriesName\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n```\ntemporal deployment list [options]\n```\n\nFor example, adding an optional filter:\n\n```\ntemporal deployment list \\\n --deployment-series-name YourDeploymentSeriesName\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().StringVar(&s.DeploymentSeriesName, "deployment-series-name", "", "Series Name to filter Deployments.") + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + +type TemporalDeploymentUpdateCurrentCommand struct { + Parent *TemporalDeploymentCommand + Command cobra.Command + DeploymentReferenceOptions + DeploymentMetadata []string +} + +func NewTemporalDeploymentUpdateCurrentCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentUpdateCurrentCommand { + var s TemporalDeploymentUpdateCurrentCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "update-current [flags]" + s.Command.Short = "Change the current Deployment" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n\x1b[1mtemporal deployment update-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal deployment update-current \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n```\ntemporal deployment update-current [options]\n```\n\nFor example:\n\n```\ntemporal deployment update-current \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().StringArrayVar(&s.DeploymentMetadata, "deployment-metadata", nil, "Set deployment metadata using `KEY=\"VALUE\"` pairs. Keys must be identifiers, and values must be JSON values. For example: 'YourKey={\"your\": \"value\"}'. Can be passed multiple times.") + s.DeploymentReferenceOptions.buildFlags(cctx, s.Command.Flags()) + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + type TemporalEnvCommand struct { Parent *TemporalCommand Command cobra.Command @@ -1772,9 +1923,9 @@ func NewTemporalTaskQueueDescribeCommand(cctx *CommandContext, parent *TemporalT s.Command.Use = "describe [flags]" s.Command.Short = "Show active Workers" if hasHighlighting { - s.Command.Long = "Display a list of active Workers that have recently polled a Task Queue. The\nTemporal Server records each poll request time. A \x1b[1mLastAccessTime\x1b[0m over one\nminute may indicate the Worker is at capacity or has shut down. Temporal\nWorkers are removed if 5 minutes have passed since the last poll request.\n\n\x1b[1mtemporal task-queue describe \\\n --task-queue YourTaskQueue\x1b[0m\n\nThis command provides poller information for a given Task Queue.\nWorkflow and Activity polling use separate Task Queues:\n\n\x1b[1mtemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --task-queue-type \"activity\"\x1b[0m\n\nThis command provides the following task queue statistics:\n- \x1b[1mApproximateBacklogCount\x1b[0m: The approximate number of tasks backlogged in this\n task queue. May count expired tasks but eventually converges to the right\n value.\n- \x1b[1mApproximateBacklogAge\x1b[0m: Approximate age of the oldest task in the backlog,\n based on its creation time, measured in seconds.\n- \x1b[1mTasksAddRate\x1b[0m: Approximate rate at which tasks are being added to the task\n queue, measured in tasks per second, averaged over the last 30 seconds.\n Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- \x1b[1mTasksDispatchRate\x1b[0m: Approximate rate at which tasks are being dispatched from\n the task queue, measured in tasks per second, averaged over the last 30\n seconds. Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- \x1b[1mBacklogIncreaseRate\x1b[0m: Approximate rate at which the backlog size is\n increasing (if positive) or decreasing (if negative), measured in tasks per\n second, averaged over the last 30 seconds. This is roughly equivalent to:\n \x1b[1mTasksAddRate\x1b[0m - \x1b[1mTasksDispatchRate\x1b[0m.\n\nNOTE: The \x1b[1mTasksAddRate\x1b[0m and \x1b[1mTasksDispatchRate\x1b[0m metrics may differ from the\nactual rate of add/dispatch, because tasks may be dispatched eagerly to an\navailable worker, or may apply only to specific workers (they are \"sticky\").\nSuch tasks are not counted by these metrics. Despite the inaccuracy of \nthese two metrics, the derived metric of \x1b[1mBacklogIncreaseRate\x1b[0m is accurate\nfor backlogs older than a few seconds.\n\nSafely retire Workers assigned a Build ID by checking reachability across\nall task types. Use the flag \x1b[1m--report-reachability\x1b[0m:\n\n\x1b[1mtemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --build-id \"YourBuildId\" \\\n --report-reachability\x1b[0m\n\nTask reachability information is returned for the requested versions and all\ntask types, which can be used to safely retire Workers with old code versions,\nprovided that they were assigned a Build ID.\n\nNote that task reachability status is experimental and may significantly change\nor be removed in a future release. Also, determining task reachability incurs a\nnon-trivial computing cost.\n\nTask reachability states are reported per build ID. The state may be one of the\nfollowing:\n\n- \x1b[1mReachable\x1b[0m: using the current versioning rules, the Build ID may be used\n by new Workflow Executions or Activities OR there are currently open\n Workflow or backlogged Activity tasks assigned to the queue.\n- \x1b[1mClosedWorkflowsOnly\x1b[0m: the Build ID does not have open Workflow Executions\n and can't be reached by new Workflow Executions. It MAY have closed\n Workflow Executions within the Namespace retention period.\n- \x1b[1mUnreachable\x1b[0m: this Build ID is not used for new Workflow Executions and\n isn't used by any existing Workflow Execution within the retention period.\n\nTask reachability is eventually consistent. You may experience a delay until\nreachability converges to the most accurate value. This is designed to act\nin the most conservative way until convergence. For example, \x1b[1mReachable\x1b[0m is\nmore conservative than \x1b[1mClosedWorkflowsOnly\x1b[0m." + s.Command.Long = "Display a list of active Workers that have recently polled a Task Queue. The\nTemporal Server records each poll request time. A \x1b[1mLastAccessTime\x1b[0m over one\nminute may indicate the Worker is at capacity or has shut down. Temporal\nWorkers are removed if 5 minutes have passed since the last poll request.\n\n\x1b[1mtemporal task-queue describe \\\n --task-queue YourTaskQueue\x1b[0m\n\nThis command provides poller information for a given Task Queue.\nWorkflow and Activity polling use separate Task Queues:\n\n\x1b[1mtemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --task-queue-type \"activity\"\x1b[0m\n\nThis command provides the following task queue statistics:\n- \x1b[1mApproximateBacklogCount\x1b[0m: The approximate number of tasks backlogged in this\n task queue. May count expired tasks but eventually converges to the right\n value.\n- \x1b[1mApproximateBacklogAge\x1b[0m: Approximate age of the oldest task in the backlog,\n based on its creation time, measured in seconds.\n- \x1b[1mTasksAddRate\x1b[0m: Approximate rate at which tasks are being added to the task\n queue, measured in tasks per second, averaged over the last 30 seconds.\n Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- \x1b[1mTasksDispatchRate\x1b[0m: Approximate rate at which tasks are being dispatched from\n the task queue, measured in tasks per second, averaged over the last 30\n seconds. Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- \x1b[1mBacklogIncreaseRate\x1b[0m: Approximate rate at which the backlog size is\n increasing (if positive) or decreasing (if negative), measured in tasks per\n second, averaged over the last 30 seconds. This is roughly equivalent to:\n \x1b[1mTasksAddRate\x1b[0m - \x1b[1mTasksDispatchRate\x1b[0m.\n\nNOTE: The \x1b[1mTasksAddRate\x1b[0m and \x1b[1mTasksDispatchRate\x1b[0m metrics may differ from the\nactual rate of add/dispatch, because tasks may be dispatched eagerly to an\navailable worker, or may apply only to specific workers (they are \"sticky\").\nSuch tasks are not counted by these metrics. Despite the inaccuracy of\nthese two metrics, the derived metric of \x1b[1mBacklogIncreaseRate\x1b[0m is accurate\nfor backlogs older than a few seconds.\n\nSafely retire Workers assigned a Build ID by checking reachability across\nall task types. Use the flag \x1b[1m--report-reachability\x1b[0m:\n\n\x1b[1mtemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --build-id \"YourBuildId\" \\\n --report-reachability\x1b[0m\n\nTask reachability information is returned for the requested versions and all\ntask types, which can be used to safely retire Workers with old code versions,\nprovided that they were assigned a Build ID.\n\nNote that task reachability status is experimental and may significantly change\nor be removed in a future release. Also, determining task reachability incurs a\nnon-trivial computing cost.\n\nTask reachability states are reported per build ID. The state may be one of the\nfollowing:\n\n- \x1b[1mReachable\x1b[0m: using the current versioning rules, the Build ID may be used\n by new Workflow Executions or Activities OR there are currently open\n Workflow or backlogged Activity tasks assigned to the queue.\n- \x1b[1mClosedWorkflowsOnly\x1b[0m: the Build ID does not have open Workflow Executions\n and can't be reached by new Workflow Executions. It MAY have closed\n Workflow Executions within the Namespace retention period.\n- \x1b[1mUnreachable\x1b[0m: this Build ID is not used for new Workflow Executions and\n isn't used by any existing Workflow Execution within the retention period.\n\nTask reachability is eventually consistent. You may experience a delay until\nreachability converges to the most accurate value. This is designed to act\nin the most conservative way until convergence. For example, \x1b[1mReachable\x1b[0m is\nmore conservative than \x1b[1mClosedWorkflowsOnly\x1b[0m." } else { - s.Command.Long = "Display a list of active Workers that have recently polled a Task Queue. The\nTemporal Server records each poll request time. A `LastAccessTime` over one\nminute may indicate the Worker is at capacity or has shut down. Temporal\nWorkers are removed if 5 minutes have passed since the last poll request.\n\n```\ntemporal task-queue describe \\\n --task-queue YourTaskQueue\n```\n\nThis command provides poller information for a given Task Queue.\nWorkflow and Activity polling use separate Task Queues:\n\n```\ntemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --task-queue-type \"activity\"\n```\n\nThis command provides the following task queue statistics:\n- `ApproximateBacklogCount`: The approximate number of tasks backlogged in this\n task queue. May count expired tasks but eventually converges to the right\n value.\n- `ApproximateBacklogAge`: Approximate age of the oldest task in the backlog,\n based on its creation time, measured in seconds.\n- `TasksAddRate`: Approximate rate at which tasks are being added to the task\n queue, measured in tasks per second, averaged over the last 30 seconds.\n Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- `TasksDispatchRate`: Approximate rate at which tasks are being dispatched from\n the task queue, measured in tasks per second, averaged over the last 30\n seconds. Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- `BacklogIncreaseRate`: Approximate rate at which the backlog size is\n increasing (if positive) or decreasing (if negative), measured in tasks per\n second, averaged over the last 30 seconds. This is roughly equivalent to:\n `TasksAddRate` - `TasksDispatchRate`.\n\nNOTE: The `TasksAddRate` and `TasksDispatchRate` metrics may differ from the\nactual rate of add/dispatch, because tasks may be dispatched eagerly to an\navailable worker, or may apply only to specific workers (they are \"sticky\").\nSuch tasks are not counted by these metrics. Despite the inaccuracy of \nthese two metrics, the derived metric of `BacklogIncreaseRate` is accurate\nfor backlogs older than a few seconds.\n\nSafely retire Workers assigned a Build ID by checking reachability across\nall task types. Use the flag `--report-reachability`:\n\n```\ntemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --build-id \"YourBuildId\" \\\n --report-reachability\n```\n\nTask reachability information is returned for the requested versions and all\ntask types, which can be used to safely retire Workers with old code versions,\nprovided that they were assigned a Build ID.\n\nNote that task reachability status is experimental and may significantly change\nor be removed in a future release. Also, determining task reachability incurs a\nnon-trivial computing cost.\n\nTask reachability states are reported per build ID. The state may be one of the\nfollowing:\n\n- `Reachable`: using the current versioning rules, the Build ID may be used\n by new Workflow Executions or Activities OR there are currently open\n Workflow or backlogged Activity tasks assigned to the queue.\n- `ClosedWorkflowsOnly`: the Build ID does not have open Workflow Executions\n and can't be reached by new Workflow Executions. It MAY have closed\n Workflow Executions within the Namespace retention period.\n- `Unreachable`: this Build ID is not used for new Workflow Executions and\n isn't used by any existing Workflow Execution within the retention period.\n\nTask reachability is eventually consistent. You may experience a delay until\nreachability converges to the most accurate value. This is designed to act\nin the most conservative way until convergence. For example, `Reachable` is\nmore conservative than `ClosedWorkflowsOnly`." + s.Command.Long = "Display a list of active Workers that have recently polled a Task Queue. The\nTemporal Server records each poll request time. A `LastAccessTime` over one\nminute may indicate the Worker is at capacity or has shut down. Temporal\nWorkers are removed if 5 minutes have passed since the last poll request.\n\n```\ntemporal task-queue describe \\\n --task-queue YourTaskQueue\n```\n\nThis command provides poller information for a given Task Queue.\nWorkflow and Activity polling use separate Task Queues:\n\n```\ntemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --task-queue-type \"activity\"\n```\n\nThis command provides the following task queue statistics:\n- `ApproximateBacklogCount`: The approximate number of tasks backlogged in this\n task queue. May count expired tasks but eventually converges to the right\n value.\n- `ApproximateBacklogAge`: Approximate age of the oldest task in the backlog,\n based on its creation time, measured in seconds.\n- `TasksAddRate`: Approximate rate at which tasks are being added to the task\n queue, measured in tasks per second, averaged over the last 30 seconds.\n Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- `TasksDispatchRate`: Approximate rate at which tasks are being dispatched from\n the task queue, measured in tasks per second, averaged over the last 30\n seconds. Includes tasks dispatched immediately without going to the backlog\n (sync-matched tasks), as well as tasks added to the backlog. (See note below.)\n- `BacklogIncreaseRate`: Approximate rate at which the backlog size is\n increasing (if positive) or decreasing (if negative), measured in tasks per\n second, averaged over the last 30 seconds. This is roughly equivalent to:\n `TasksAddRate` - `TasksDispatchRate`.\n\nNOTE: The `TasksAddRate` and `TasksDispatchRate` metrics may differ from the\nactual rate of add/dispatch, because tasks may be dispatched eagerly to an\navailable worker, or may apply only to specific workers (they are \"sticky\").\nSuch tasks are not counted by these metrics. Despite the inaccuracy of\nthese two metrics, the derived metric of `BacklogIncreaseRate` is accurate\nfor backlogs older than a few seconds.\n\nSafely retire Workers assigned a Build ID by checking reachability across\nall task types. Use the flag `--report-reachability`:\n\n```\ntemporal task-queue describe \\\n --task-queue YourTaskQueue \\\n --build-id \"YourBuildId\" \\\n --report-reachability\n```\n\nTask reachability information is returned for the requested versions and all\ntask types, which can be used to safely retire Workers with old code versions,\nprovided that they were assigned a Build ID.\n\nNote that task reachability status is experimental and may significantly change\nor be removed in a future release. Also, determining task reachability incurs a\nnon-trivial computing cost.\n\nTask reachability states are reported per build ID. The state may be one of the\nfollowing:\n\n- `Reachable`: using the current versioning rules, the Build ID may be used\n by new Workflow Executions or Activities OR there are currently open\n Workflow or backlogged Activity tasks assigned to the queue.\n- `ClosedWorkflowsOnly`: the Build ID does not have open Workflow Executions\n and can't be reached by new Workflow Executions. It MAY have closed\n Workflow Executions within the Namespace retention period.\n- `Unreachable`: this Build ID is not used for new Workflow Executions and\n isn't used by any existing Workflow Execution within the retention period.\n\nTask reachability is eventually consistent. You may experience a delay until\nreachability converges to the most accurate value. This is designed to act\nin the most conservative way until convergence. For example, `Reachable` is\nmore conservative than `ClosedWorkflowsOnly`." } s.Command.Args = cobra.NoArgs s.Command.Flags().StringVarP(&s.TaskQueue, "task-queue", "t", "", "Task Queue name. Required.") @@ -2350,6 +2501,7 @@ func NewTemporalWorkflowCommand(cctx *CommandContext, parent *TemporalCommand) * s.Command.AddCommand(&NewTemporalWorkflowExecuteCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowFixHistoryJsonCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowListCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkflowModifyOptionsCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowQueryCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowResetCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowResultCommand(cctx, &s).Command) @@ -2573,6 +2725,61 @@ func NewTemporalWorkflowListCommand(cctx *CommandContext, parent *TemporalWorkfl return &s } +type TemporalWorkflowModifyOptionsCommand struct { + Parent *TemporalWorkflowCommand + Command cobra.Command + SingleWorkflowOrBatchOptions +} + +func NewTemporalWorkflowModifyOptionsCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowModifyOptionsCommand { + var s TemporalWorkflowModifyOptionsCommand + s.Parent = parent + s.Command.Use = "modify-options" + s.Command.Short = "Change Workflow Execution Options" + if hasHighlighting { + s.Command.Long = "Modify properties of Workflow Executions:\n\n\x1b[1mtemporal workflow modify-options [command] [options]\x1b[0m\n\nFor example, properties that control Worker Versioning:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\x1b[0m" + } else { + s.Command.Long = "Modify properties of Workflow Executions:\n\n```\ntemporal workflow modify-options [command] [options]\n```\n\nFor example, properties that control Worker Versioning:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.AddCommand(&NewTemporalWorkflowModifyOptionsVersioningOverrideCommand(cctx, &s).Command) + s.SingleWorkflowOrBatchOptions.buildFlags(cctx, s.Command.PersistentFlags()) + return &s +} + +type TemporalWorkflowModifyOptionsVersioningOverrideCommand struct { + Parent *TemporalWorkflowModifyOptionsCommand + Command cobra.Command + DeploymentBehavior StringEnum + DeploymentSeriesName string + DeploymentBuildId string +} + +func NewTemporalWorkflowModifyOptionsVersioningOverrideCommand(cctx *CommandContext, parent *TemporalWorkflowModifyOptionsCommand) *TemporalWorkflowModifyOptionsVersioningOverrideCommand { + var s TemporalWorkflowModifyOptionsVersioningOverrideCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "versioning-override [flags]" + s.Command.Short = "Overrides the Deployment options of a Workflow Execution" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker versioning is experimental. Versioning commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nOverrides the Deployment configuration of a Workflow Execution, which\ncontrols Worker Versioning.\n\n\x1b[1mtemporal workflow modify-options versioning-override [options]\x1b[0m\n\nFor example, to force Workers in the current Deployment execute the\nnext Workflow Task:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\x1b[0m\n\nor to pin the workflow execution to a Deployment:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior pinned \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\x1b[0m\n\nTo remove any previous overrides, set the behavior to\nunspecified:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior unspecified\x1b[0m\n\nTo see the current override use \x1b[1mtemporal workflow describe\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker versioning is experimental. Versioning commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nOverrides the Deployment configuration of a Workflow Execution, which\ncontrols Worker Versioning.\n\n```\ntemporal workflow modify-options versioning-override [options]\n```\n\nFor example, to force Workers in the current Deployment execute the\nnext Workflow Task:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\n```\n\nor to pin the workflow execution to a Deployment:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior pinned \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\n```\n\nTo remove any previous overrides, set the behavior to\nunspecified:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior unspecified\n```\n\nTo see the current override use `temporal workflow describe`" + } + s.Command.Args = cobra.NoArgs + s.DeploymentBehavior = NewStringEnum([]string{"unspecified", "pinned", "auto_upgrade"}, "") + s.Command.Flags().Var(&s.DeploymentBehavior, "deployment-behavior", "Flag to describe the versioning behavior of a Workflow. Accepted values: unspecified, pinned, auto_upgrade. Required.") + _ = cobra.MarkFlagRequired(s.Command.Flags(), "deployment-behavior") + s.Command.Flags().StringVar(&s.DeploymentSeriesName, "deployment-series-name", "", "Series Name for a Deployment (Only for pinned).") + s.Command.Flags().StringVar(&s.DeploymentBuildId, "deployment-build-id", "", "Build ID for a Deployment (Only for pinned).") + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + type TemporalWorkflowQueryCommand struct { Parent *TemporalWorkflowCommand Command cobra.Command diff --git a/temporalcli/commands.workflow.go b/temporalcli/commands.workflow.go index 02316aad0..9592f2908 100644 --- a/temporalcli/commands.workflow.go +++ b/temporalcli/commands.workflow.go @@ -8,18 +8,22 @@ import ( "os/user" "go.temporal.io/sdk/converter" + "go.temporal.io/sdk/workflow" "github.com/fatih/color" "github.com/google/uuid" "github.com/temporalio/cli/temporalcli/internal/printer" "go.temporal.io/api/batch/v1" "go.temporal.io/api/common/v1" + deploymentpb "go.temporal.io/api/deployment/v1" "go.temporal.io/api/enums/v1" "go.temporal.io/api/query/v1" "go.temporal.io/api/update/v1" + workflowpb "go.temporal.io/api/workflow/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" "go.temporal.io/sdk/temporal" + "google.golang.org/protobuf/types/known/fieldmaskpb" ) func (c *TemporalWorkflowCancelCommand) run(cctx *CommandContext, args []string) error { @@ -88,6 +92,117 @@ func (c *TemporalWorkflowDeleteCommand) run(cctx *CommandContext, args []string) return nil } +func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *CommandContext, args []string) error { + cl, err := c.Parent.Parent.ClientOptions.dialClient(cctx) + if err != nil { + return err + } + defer cl.Close() + + if c.DeploymentBehavior.Value == "unspecified" || c.DeploymentBehavior.Value == "auto_upgrade" { + if c.DeploymentSeriesName != "" { + return fmt.Errorf("cannot set deployment series name with %v behavior", c.DeploymentBehavior) + } + if c.DeploymentBuildId != "" { + return fmt.Errorf("cannot set deployment build ID with %v behavior", c.DeploymentBehavior) + } + } + + if c.DeploymentBehavior.Value == "pinned" { + if c.DeploymentSeriesName == "" { + return fmt.Errorf("missing deployment series name with 'pinned' behavior") + } + if c.DeploymentBuildId == "" { + return fmt.Errorf("missing deployment build ID with 'pinned' behavior") + } + } + + exec, batchReq, err := c.Parent.workflowExecOrBatch(cctx, c.Parent.Parent.Namespace, cl, singleOrBatchOverrides{}) + + // Run single or batch + if err != nil { + return err + } else if exec != nil { + behavior := workflow.VersioningBehaviorUnspecified + switch c.DeploymentBehavior.Value { + case "unspecified": + case "pinned": + behavior = workflow.VersioningBehaviorPinned + case "auto_upgrade": + behavior = workflow.VersioningBehaviorAutoUpgrade + default: + return fmt.Errorf( + "invalid deployment behavior: %v, valid values are: 'unspecified', 'pinned', and 'auto_upgrade'", + c.DeploymentBehavior, + ) + } + + _, err := cl.UpdateWorkflowExecutionOptions(cctx, client.UpdateWorkflowExecutionOptionsRequest{ + WorkflowId: exec.WorkflowId, + RunId: exec.RunId, + WorkflowExecutionOptionsChanges: client.WorkflowExecutionOptionsChanges{ + VersioningOverride: &client.VersioningOverride{ + Behavior: behavior, + Deployment: client.Deployment{ + SeriesName: c.DeploymentSeriesName, + BuildID: c.DeploymentBuildId, + }, + }, + }, + }) + if err != nil { + return fmt.Errorf("failed to override workflow versioning options: %w", err) + } + cctx.Printer.Println("Override workflow versioning options succeeded") + } else { // Run batch + var workflowExecutionOptions *workflowpb.WorkflowExecutionOptions + protoMask, err := fieldmaskpb.New(workflowExecutionOptions, "versioning_override") + if err != nil { + panic("invalid field mask") + } + + behavior := enums.VERSIONING_BEHAVIOR_UNSPECIFIED + switch c.DeploymentBehavior.Value { + case "unspecified": + case "pinned": + behavior = enums.VERSIONING_BEHAVIOR_PINNED + case "auto_upgrade": + behavior = enums.VERSIONING_BEHAVIOR_AUTO_UPGRADE + default: + return fmt.Errorf( + "invalid deployment behavior: %v, valid values are: 'unspecified', 'pinned', and 'auto_upgrade'", + c.DeploymentBehavior, + ) + } + + deployment := &deploymentpb.Deployment{ + SeriesName: c.DeploymentSeriesName, + BuildId: c.DeploymentBuildId, + } + if c.DeploymentSeriesName == "" && c.DeploymentBuildId == "" { + // auto_upgrade needs a `nil` pointer + deployment = nil + } + + batchReq.Operation = &workflowservice.StartBatchOperationRequest_UpdateWorkflowOptionsOperation{ + UpdateWorkflowOptionsOperation: &batch.BatchOperationUpdateWorkflowExecutionOptions{ + Identity: clientIdentity(), + WorkflowExecutionOptions: &workflowpb.WorkflowExecutionOptions{ + VersioningOverride: &workflowpb.VersioningOverride{ + Behavior: behavior, + Deployment: deployment, + }, + }, + UpdateMask: protoMask, + }, + } + if err := startBatchJob(cctx, cl, batchReq); err != nil { + return err + } + } + return nil +} + func (c *TemporalWorkflowQueryCommand) run(cctx *CommandContext, args []string) error { return queryHelper(cctx, c.Parent, c.PayloadInputOptions, c.Name, c.RejectCondition, c.WorkflowReferenceOptions) diff --git a/temporalcli/commands.workflow_test.go b/temporalcli/commands.workflow_test.go index 8ee07293a..1ad15d44c 100644 --- a/temporalcli/commands.workflow_test.go +++ b/temporalcli/commands.workflow_test.go @@ -11,9 +11,12 @@ import ( "time" "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "github.com/temporalio/cli/temporalcli" "go.temporal.io/api/enums/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" + "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" "google.golang.org/grpc" ) @@ -418,6 +421,191 @@ func (s *SharedServerSuite) TestWorkflow_Cancel_SingleWorkflowSuccess() { s.Error(workflow.ErrCanceled, run.Get(s.Context, nil)) } +func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Override() { + buildId1 := uuid.NewString() + buildId2 := uuid.NewString() + seriesName := uuid.NewString() + // Workflow that waits to be canceled. + waitingWorkflow := func(ctx workflow.Context) error { + ctx.Done().Receive(ctx, nil) + return ctx.Err() + } + w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{ + Worker: worker.Options{ + BuildID: buildId1, + UseBuildIDForVersioning: true, + DeploymentOptions: worker.DeploymentOptions{ + DeploymentSeriesName: seriesName, + DefaultVersioningBehavior: workflow.VersioningBehaviorPinned, + }, + }, + Workflows: []any{waitingWorkflow}, + }) + defer w.Stop() + + res := s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId1, + ) + s.NoError(res.Err) + + // Start workflows + numWorkflows := 5 + runs := make([]client.WorkflowRun, numWorkflows) + searchAttr := "keyword-" + uuid.NewString() + for i := range runs { + run, err := s.Client.ExecuteWorkflow( + s.Context, + client.StartWorkflowOptions{ + TaskQueue: w.Options.TaskQueue, + SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, + }, + waitingWorkflow, + ) + s.NoError(err) + runs[i] = run + } + + s.EventuallyWithT(func(t *assert.CollectT) { + for _, run := range runs { + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + ) + assert.NoError(t, res.Err) + assert.Contains(t, res.Stdout.String(), buildId1) + assert.Contains(t, res.Stdout.String(), "Pinned") + } + }, 30*time.Second, 100*time.Millisecond) + + s.CommandHarness.Stdin.WriteString("y\n") + res = s.Execute( + "workflow", "modify-options", "versioning-override", + "--address", s.Address(), + "--query", "CustomKeywordField = '" + searchAttr + "'", + "--deployment-behavior", "pinned", + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId2, + ) + s.NoError(res.Err) + + s.EventuallyWithT(func(t *assert.CollectT) { + for _, run := range runs { + // json + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + "--output", "json", + ) + assert.NoError(t, res.Err) + + var jsonResp workflowservice.DescribeWorkflowExecutionResponse + assert.NoError(t, temporalcli.UnmarshalProtoJSONWithOptions(res.Stdout.Bytes(), &jsonResp, true)) + versioningInfo := jsonResp.WorkflowExecutionInfo.VersioningInfo + assert.NotNil(t, versioningInfo.VersioningOverride) + assert.Equal(t, buildId2, versioningInfo.VersioningOverride.Deployment.BuildId) + } + }, 30*time.Second, 100*time.Millisecond) +} + +func (s *SharedServerSuite) TestWorkflow_Modify_Options_Versioning_Override() { + buildId1 := uuid.NewString() + buildId2 := uuid.NewString() + seriesName := uuid.NewString() + // Workflow that waits to be canceled. + waitingWorkflow := func(ctx workflow.Context) error { + ctx.Done().Receive(ctx, nil) + return ctx.Err() + } + w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{ + Worker: worker.Options{ + BuildID: buildId1, + UseBuildIDForVersioning: true, + DeploymentOptions: worker.DeploymentOptions{ + DeploymentSeriesName: seriesName, + DefaultVersioningBehavior: workflow.VersioningBehaviorPinned, + }, + }, + Workflows: []any{waitingWorkflow}, + }) + defer w.Stop() + + res := s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId1, + ) + s.NoError(res.Err) + + // Start the workflow and wait until the operation is started. + run, err := s.Client.ExecuteWorkflow( + s.Context, + client.StartWorkflowOptions{TaskQueue: w.Options.TaskQueue}, + waitingWorkflow, + ) + s.NoError(err) + + s.EventuallyWithT(func(t *assert.CollectT) { + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + ) + assert.NoError(t, res.Err) + assert.Contains(t, res.Stdout.String(), buildId1) + assert.Contains(t, res.Stdout.String(), "Pinned") + }, 30*time.Second, 100*time.Millisecond) + + res = s.Execute( + "workflow", "modify-options", "versioning-override", + "--address", s.Address(), + "-w", run.GetID(), + "--deployment-behavior", "pinned", + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId2, + ) + s.NoError(res.Err) + + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + ) + s.NoError(res.Err) + + s.ContainsOnSameLine(res.Stdout.String(), "OverrideBehavior", "Pinned") + s.ContainsOnSameLine(res.Stdout.String(), "OverrideDeploymentSeriesName", seriesName) + s.ContainsOnSameLine(res.Stdout.String(), "OverrideDeploymentBuildID", buildId2) + + // remove override + res = s.Execute( + "workflow", "modify-options", "versioning-override", + "--address", s.Address(), + "-w", run.GetID(), + "--deployment-behavior", "unspecified", + ) + s.NoError(res.Err) + + // json + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + "--output", "json", + ) + s.NoError(res.Err) + + var jsonResp workflowservice.DescribeWorkflowExecutionResponse + s.NoError(temporalcli.UnmarshalProtoJSONWithOptions(res.Stdout.Bytes(), &jsonResp, true)) + versioningInfo := jsonResp.WorkflowExecutionInfo.VersioningInfo + s.Nil(versioningInfo.VersioningOverride) +} + func (s *SharedServerSuite) TestWorkflow_Update_Execute() { workflowUpdateTest{ s: s, diff --git a/temporalcli/commands.workflow_view.go b/temporalcli/commands.workflow_view.go index ca7ea19d6..760f58bf6 100644 --- a/temporalcli/commands.workflow_view.go +++ b/temporalcli/commands.workflow_view.go @@ -134,6 +134,32 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin HistorySize: info.HistorySizeBytes, }, printer.StructuredOptions{}) + if info.VersioningInfo != nil { + cctx.Printer.Println() + cctx.Printer.Println(color.MagentaString("Versioning Info:")) + cctx.Printer.Println() + vInfo := info.VersioningInfo + _ = cctx.Printer.PrintStructured(struct { + Behavior string + DeploymentSeriesName string + DeploymentBuildID string + OverrideBehavior string `cli:",cardOmitEmpty"` + OverrideDeploymentSeriesName string `cli:",cardOmitEmpty"` + OverrideDeploymentBuildID string `cli:",cardOmitEmpty"` + TransitionDeploymentSeriesName string `cli:",cardOmitEmpty"` + TransitionDeploymentBuildID string `cli:",cardOmitEmpty"` + }{ + Behavior: vInfo.Behavior.String(), + DeploymentSeriesName: vInfo.Deployment.GetSeriesName(), + DeploymentBuildID: vInfo.Deployment.GetBuildId(), + OverrideBehavior: vInfo.VersioningOverride.GetBehavior().String(), + OverrideDeploymentSeriesName: vInfo.VersioningOverride.GetDeployment().GetSeriesName(), + OverrideDeploymentBuildID: vInfo.VersioningOverride.GetDeployment().GetBuildId(), + TransitionDeploymentSeriesName: vInfo.DeploymentTransition.GetDeployment().GetSeriesName(), + TransitionDeploymentBuildID: vInfo.DeploymentTransition.GetDeployment().GetBuildId(), + }, printer.StructuredOptions{}) + } + if len(resp.Callbacks) > 0 { cctx.Printer.Println() cctx.Printer.Println(color.MagentaString("Callbacks: %v", len(resp.Callbacks))) diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index e0c99e90f..a1e1112fb 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -13,12 +13,14 @@ import ( "github.com/google/uuid" "github.com/nexus-rpc/sdk-go/nexus" + "github.com/stretchr/testify/assert" "github.com/temporalio/cli/temporalcli" "go.temporal.io/api/enums/v1" nexuspb "go.temporal.io/api/nexus/v1" "go.temporal.io/api/operatorservice/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" + "go.temporal.io/sdk/worker" "go.temporal.io/sdk/temporal" "go.temporal.io/sdk/temporalnexus" "go.temporal.io/sdk/workflow" @@ -546,6 +548,79 @@ func (s *SharedServerSuite) TestWorkflow_Count() { s.Contains(out, `{"groupValues":["Completed"],"count":"3"}`) } +func (s *SharedServerSuite) TestWorkflow_Describe_Deployment() { + buildId := uuid.NewString() + seriesName := uuid.NewString() + // Workflow that waits to be canceled. + waitingWorkflow := func(ctx workflow.Context) error { + ctx.Done().Receive(ctx, nil) + return ctx.Err() + } + w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{ + Worker: worker.Options{ + BuildID: buildId, + UseBuildIDForVersioning: true, + DeploymentOptions: worker.DeploymentOptions{ + DeploymentSeriesName: seriesName, + DefaultVersioningBehavior: workflow.VersioningBehaviorPinned, + }, + }, + Workflows: []any{waitingWorkflow}, + }) + defer w.Stop() + + res := s.Execute( + "deployment", "update-current", + "--address", s.Address(), + "--deployment-series-name", seriesName, + "--deployment-build-id", buildId, + ) + s.NoError(res.Err) + + // Start the workflow and wait until the operation is started. + run, err := s.Client.ExecuteWorkflow( + s.Context, + client.StartWorkflowOptions{TaskQueue: w.Options.TaskQueue}, + waitingWorkflow, + ) + s.NoError(err) + + s.EventuallyWithT(func(t *assert.CollectT) { + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + ) + assert.NoError(t, res.Err) + assert.Contains(t, res.Stdout.String(), buildId) + assert.Contains(t, res.Stdout.String(), "Pinned") + }, 30*time.Second, 100*time.Millisecond) + + out := res.Stdout.String() + s.ContainsOnSameLine(out, "Behavior", "Pinned") + s.ContainsOnSameLine(out, "DeploymentBuildID", buildId) + s.ContainsOnSameLine(out, "DeploymentSeriesName", seriesName) + s.ContainsOnSameLine(out, "OverrideBehavior", "Unspecified") + + // json + res = s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", run.GetID(), + "--output", "json", + ) + s.NoError(res.Err) + + var jsonResp workflowservice.DescribeWorkflowExecutionResponse + s.NoError(temporalcli.UnmarshalProtoJSONWithOptions(res.Stdout.Bytes(), &jsonResp, true)) + versioningInfo := jsonResp.WorkflowExecutionInfo.VersioningInfo + s.Equal("Pinned", versioningInfo.Behavior.String()) + s.Equal(buildId, versioningInfo.Deployment.BuildId) + s.Equal(seriesName, versioningInfo.Deployment.SeriesName) + s.Nil(versioningInfo.VersioningOverride) + s.Nil(versioningInfo.DeploymentTransition) +} + func (s *SharedServerSuite) TestWorkflow_Describe_NexusOperationAndCallback() { handlerWorkflowID := uuid.NewString() endpointName := validEndpointName(s.T()) diff --git a/temporalcli/commands_test.go b/temporalcli/commands_test.go index 5f8f1e882..010db086a 100644 --- a/temporalcli/commands_test.go +++ b/temporalcli/commands_test.go @@ -364,6 +364,7 @@ func StartDevServer(t *testing.T, options DevServerOptions) *DevServer { d.Options.DynamicConfigValues["frontend.workerVersioningRuleAPIs"] = true d.Options.DynamicConfigValues["frontend.workerVersioningDataAPIs"] = true d.Options.DynamicConfigValues["frontend.workerVersioningWorkflowAPIs"] = true + d.Options.DynamicConfigValues["system.enableDeployments"] = true d.Options.DynamicConfigValues["worker.buildIdScavengerEnabled"] = true d.Options.DynamicConfigValues["frontend.enableUpdateWorkflowExecution"] = true d.Options.DynamicConfigValues["system.enableNexus"] = true diff --git a/temporalcli/commandsgen/commands.yml b/temporalcli/commandsgen/commands.yml index 5340be8b6..07e3dd8e4 100644 --- a/temporalcli/commandsgen/commands.yml +++ b/temporalcli/commandsgen/commands.yml @@ -12,7 +12,7 @@ # * Re-use and adapt existing wording and phrases wherever possible. # * Word command summaries as if they began "This command will..." # Use sentence casing for the summary. -# * ID is fully capitalized in text ("the Workflow ID") and Id in +# * ID is fully capitalized in text ("the Workflow ID") and Id in # [metasyntax](https://en.wikipedia.org/wiki/Metasyntactic_variable) (YourWorkflowId). # * Avoid parentheticals unless absolutely necessary. @@ -30,7 +30,7 @@ # * Code, flags, and keys: # * Demonstrate at least one example invocation of the command in every long description. -# * Include the most commonly used patterns in long descriptions so users don't +# * Include the most commonly used patterns in long descriptions so users don't # have to call help at multiple invocation levels. # * Avoid deprecated period-delineated versions of environment-specific keys. # * Yes: @@ -53,10 +53,10 @@ # * Yes: temporal operator [command] [subcommand] [options] # Commands with subcommands can't be run on their own. # Because of this, always use full command examples. -# * Use square brackets to highlight optional elements, especially when long +# * Use square brackets to highlight optional elements, especially when long # descriptions would suffer from two very similar command invocations. # * Yes: temporal operator cluster describe [--detail] -# * Use YourEnvironment, YourNamespace, etc. as unquoted metasyntactic variable +# * Use YourEnvironment, YourNamespace, etc. as unquoted metasyntactic variable # stand-ins. # Respectful metasyntax describes the role of the stand-in. # * Yes: --workflow-id YourWorkflowId @@ -67,7 +67,7 @@ # This is more universally supported and consistent with POSIX guidelines. # * Yes: `temporal command --namespace YourNamespace`. # * No: `temporal command --namespace=YourNamespace`. -# Note: in this utility's current incarnation, Boolean options must be +# Note: in this utility's current incarnation, Boolean options must be # set with an equal sign. # Since Booleans can be treated like flags, avoid using assigned values in samples. # * Yes: `--detail` @@ -75,11 +75,11 @@ # For options and flags: -# * When options and flags can be passed multiple times, say so explicitly in +# * When options and flags can be passed multiple times, say so explicitly in # the usage text: "Can be passed multiple times." # * Never rely on the flag type (e.g. `string`, `bool`, etc.) being shown to the user. # It is replaced/hidden when a `META-VARIABLE` is used. -# * Where possible, use a `META-VARIABLE` (all caps and wrapped in `\``s) to +# * Where possible, use a `META-VARIABLE` (all caps and wrapped in `\``s) to # describe/reference content passed to an option. # * Limit `code spans` to meta-variables. # To reference other options or specify literal values, use double quotes. @@ -107,13 +107,13 @@ # option-sets: A list of option sets. (string[]) # * name, summary, and descrption are required fields. All other fields are optional. -# * Available option types are `bool`, `duration`, `int`, `float`, `string`, `string[]`, +# * Available option types are `bool`, `duration`, `int`, `float`, `string`, `string[]`, # `string-enum`, string-enum[], or `timestamp`. # * Include a new-line after each command entry. # OPTION SET OVERVIEW -# An options set declaration is the equivalent of pasting those options into the +# An options set declaration is the equivalent of pasting those options into the # bulleted options list. # - name: The name of the option set. (string) @@ -151,7 +151,7 @@ commands: - name: log-level type: string-enum enum-values: - - debug + - debug - info - warn - error @@ -225,7 +225,7 @@ commands: keywords: - activity - activity complete - - activity execution + - activity execution - activity fail - cli reference - cli-feature @@ -394,6 +394,160 @@ commands: description: Reason for terminating the batch job. required: true + - name: temporal deployment + summary: Describe, list, and operate on Deployments + description: | + +---------------------------------------------------------------------+ + | CAUTION: Worker Deployment is experimental. Deployment commands are | + | subject to change. | + +---------------------------------------------------------------------+ + + Deployment commands perform operations on Worker Deployments: + + ``` + temporal deployment [command] [options] + ``` + + For example: + + ``` + temporal deployment list + ``` + option-sets: + - client + docs: + description-header: >- + Temporal Deployment commands enable operations on Worker Deployments, + such as describe, list, update-current, and get-current, simplifying + versioning and management of workers. + keywords: + - deployment + - deployment describe + - deployment list + - deployment get-current + - deployment update-current + + - name: temporal deployment describe + summary: Show properties of a Deployment + description: | + +---------------------------------------------------------------------+ + | CAUTION: Worker Deployment is experimental. Deployment commands are | + | subject to change. | + +---------------------------------------------------------------------+ + + Describes properties of a Deployment, such as whether it is current, + some custom metadata, or a list of its task queues. + + ``` + temporal deployment describe [options] + ``` + + For example, to also include reachability information: + + ``` + temporal deployment describe \ + --deployment-series-name YourDeploymentSeriesName \ + --deployment-build-id YourDeploymentBuildId \ + --report-reachability + ``` + option-sets: + - deployment-reference + options: + - name: report-reachability + type: bool + description: | + Flag to include reachability information of a Deployment. + + - name: temporal deployment get-current + summary: Show the current Deployment + description: | + +---------------------------------------------------------------------+ + | CAUTION: Worker Deployment is experimental. Deployment commands are | + | subject to change. | + +---------------------------------------------------------------------+ + + Gets the current Deployment for a Deployment Series Name. Whether a + Deployment is current or not can affect which Workers will execute + Tasks of an existing or new Workflow. + + + ``` + temporal deployment get-current [options] + ``` + + For example: + + ``` + temporal deployment get-current \ + --deployment-series-name YourDeploymentSeriesName + ``` + options: + - name: deployment-series-name + type: string + description: Series Name for the current Deployment. + required: true + + - name: temporal deployment list + summary: Enumerate Deployments in the client's namespace + description: | + +---------------------------------------------------------------------+ + | CAUTION: Worker Deployment is experimental. Deployment commands are | + | subject to change. | + +---------------------------------------------------------------------+ + + List existing Deployments in the client's namespace, optionally + filtering them by Deployment Series Name. + + + ``` + temporal deployment list [options] + ``` + + For example, adding an optional filter: + + ``` + temporal deployment list \ + --deployment-series-name YourDeploymentSeriesName + ``` + options: + - name: deployment-series-name + type: string + description: Series Name to filter Deployments. + + - name: temporal deployment update-current + summary: Change the current Deployment + description: | + +---------------------------------------------------------------------+ + | CAUTION: Worker deployment is experimental. Deployment commands are | + | subject to change. | + +---------------------------------------------------------------------+ + + Sets the current Deployment for a given Deployment Series. Whether a + Deployment is current or not can affect which Workers will execute + Tasks of an existing or new Workflow. + + ``` + temporal deployment update-current [options] + ``` + + For example: + + ``` + temporal deployment update-current \ + --deployment-series-name YourDeploymentSeriesName \ + --deployment-build-id YourDeploymentBuildId + ``` + option-sets: + - deployment-reference + options: + - name: deployment-metadata + type: string[] + description: | + Set deployment metadata using `KEY="VALUE"` pairs. + Keys must be identifiers, and values must be JSON values. + For example: 'YourKey={"your": "value"}'. + Can be passed multiple times. + - name: temporal env summary: Manage environments description: | @@ -956,7 +1110,7 @@ commands: The endpoint target may either be a Worker, in which case `--target-namespace` and `--target-task-queue` must both be provided, or an external URL, in which case `--target-url` must be provided. - + This command will fail if an Endpoint with the same name is already registered. @@ -1005,12 +1159,12 @@ commands: summary: Update an existing Nexus Endpoint (EXPERIMENTAL) description: | Update an existing Nexus Endpoint on the Server. - + A Nexus Endpoint name is used in Workflow code to invoke Nexus Operations. The Endpoint target may either be a Worker, in which case `--target-namespace` and `--target-task-queue` must both be provided, or an external URL, in which case `--target-url` must be provided. - + The Endpoint is patched; existing fields for which flags are not provided are left as they were. @@ -1479,7 +1633,7 @@ commands: default: 7233 - name: http-port type: int - description: | + description: | Port for the HTTP API service. Default is off. - name: metrics-port @@ -1489,7 +1643,7 @@ commands: Default is off. - name: ui-port type: int - description: | + description: | Port for the Web UI. Default is '--port' value + 1000. - name: headless @@ -1613,10 +1767,10 @@ commands: NOTE: The `TasksAddRate` and `TasksDispatchRate` metrics may differ from the actual rate of add/dispatch, because tasks may be dispatched eagerly to an available worker, or may apply only to specific workers (they are "sticky"). - Such tasks are not counted by these metrics. Despite the inaccuracy of + Such tasks are not counted by these metrics. Despite the inaccuracy of these two metrics, the derived metric of `BacklogIncreaseRate` is accurate for backlogs older than a few seconds. - + Safely retire Workers assigned a Build ID by checking reachability across all task types. Use the flag `--report-reachability`: @@ -2285,9 +2439,9 @@ commands: docs: description-header: >- Temporal Workflow commands enable operations on Workflow Executions, - such as cancel, count, delete, describe, execute, list, query, reset, - reset-batch, show, signal, stack, start, terminate, trace, and update, - enhancing efficiency and control. + such as cancel, count, delete, describe, execute, list, modify-options, + query, reset, reset-batch, show, signal, stack, start, terminate, + trace, and update, enhancing efficiency and control. keywords: - call stack - cancellation @@ -2310,6 +2464,7 @@ commands: - workflow execute - workflow execution - workflow list + - workflow modify-options - workflow query - workflow reset - workflow reset-batch @@ -2437,7 +2592,7 @@ commands: options: - name: detailed type: bool - description: | + description: | Display events as sections instead of table. Does not apply to JSON output. @@ -2498,6 +2653,95 @@ commands: type: int description: Maximum number of Workflow Executions to display. + - name: temporal workflow modify-options + summary: Change Workflow Execution Options + description: | + Modify properties of Workflow Executions: + + ``` + temporal workflow modify-options [command] [options] + ``` + + For example, properties that control Worker Versioning: + + ``` + temporal workflow modify-options versioning-override \ + --workflow-id YourWorkflowId \ + --deployment-behavior auto_upgrade + ``` + option-sets: + - single-workflow-or-batch + docs: + description-header: >- + Temporal Workflow Modify Options enables + changes to properties of a Workflow Execution, such as + versioning-override. + keywords: + - workflow + - workflow modify-options + - workflow modify-options versioning-override + + - name: temporal workflow modify-options versioning-override + summary: Overrides the Deployment options of a Workflow Execution + description: | + +---------------------------------------------------------------------+ + | CAUTION: Worker versioning is experimental. Versioning commands are | + | subject to change. | + +---------------------------------------------------------------------+ + + Overrides the Deployment configuration of a Workflow Execution, which + controls Worker Versioning. + + ``` + temporal workflow modify-options versioning-override [options] + ``` + + For example, to force Workers in the current Deployment execute the + next Workflow Task: + + ``` + temporal workflow modify-options versioning-override \ + --workflow-id YourWorkflowId \ + --deployment-behavior auto_upgrade + ``` + + or to pin the workflow execution to a Deployment: + + ``` + temporal workflow modify-options versioning-override \ + --workflow-id YourWorkflowId \ + --deployment-behavior pinned \ + --deployment-series-name YourDeploymentSeriesName \ + --deployment-build-id YourDeploymentBuildId + ``` + + To remove any previous overrides, set the behavior to + unspecified: + + ``` + temporal workflow modify-options versioning-override \ + --workflow-id YourWorkflowId \ + --deployment-behavior unspecified + ``` + + To see the current override use `temporal workflow describe` + options: + - name: deployment-behavior + type: string-enum + description: | + Flag to describe the versioning behavior of a Workflow. + required: true + enum-values: + - unspecified + - pinned + - auto_upgrade + - name: deployment-series-name + type: string + description: Series Name for a Deployment (Only for pinned). + - name: deployment-build-id + type: string + description: Build ID for a Deployment (Only for pinned). + - name: temporal workflow query summary: Retrieve Workflow Execution state description: | @@ -3008,7 +3252,7 @@ option-sets: - name: overlap-policy type: string-enum description: Policy for handling overlapping Workflow Executions. # copilot updated this - enum-values: + enum-values: - Skip - BufferOne - BufferAll @@ -3103,6 +3347,17 @@ option-sets: short: r description: Run ID. + - name: deployment-reference + options: + - name: deployment-series-name + type: string + description: Series Name for a Deployment. + required: true + - name: deployment-build-id + type: string + description: Build ID for a Deployment. + required: true + - name: single-workflow-or-batch options: - name: workflow-id @@ -3154,7 +3409,7 @@ option-sets: type: string description: Workflow Type name. required: true - aliases: + aliases: - name - name: task-queue type: string @@ -3258,7 +3513,7 @@ option-sets: type: string description: Handler method name. required: true - aliases: + aliases: - type - name: first-execution-run-id type: string From e429468867dd5cfd343394124833f3d371992cc0 Mon Sep 17 00:00:00 2001 From: Antonio Lain Date: Mon, 6 Jan 2025 19:25:11 +0000 Subject: [PATCH 2/4] gofmt all files --- temporalcli/commands.deployment.go | 91 ++++++++++------------ temporalcli/commands.deployment_test.go | 24 +++--- temporalcli/commands.workflow.go | 12 +-- temporalcli/commands.workflow_test.go | 14 ++-- temporalcli/commands.workflow_view.go | 28 +++---- temporalcli/commands.workflow_view_test.go | 8 +- 6 files changed, 86 insertions(+), 91 deletions(-) diff --git a/temporalcli/commands.deployment.go b/temporalcli/commands.deployment.go index 859154903..8e3255b46 100644 --- a/temporalcli/commands.deployment.go +++ b/temporalcli/commands.deployment.go @@ -6,59 +6,57 @@ import ( "github.com/fatih/color" "github.com/temporalio/cli/temporalcli/internal/printer" - "go.temporal.io/sdk/client" "go.temporal.io/api/common/v1" - + "go.temporal.io/sdk/client" ) type taskQueuesInfosRowType struct { - Name string `json:"name"` - Type string `json:"type"` - FirstPollerTime time.Time `json:"firstPollerTime"` + Name string `json:"name"` + Type string `json:"type"` + FirstPollerTime time.Time `json:"firstPollerTime"` } type deploymentType struct { SeriesName string `json:"seriesName"` - BuildID string `json:"buildId"` + BuildID string `json:"buildId"` } type formattedDeploymentInfoType struct { - Deployment deploymentType `json:"deployment"` - CreateTime time.Time `json:"createTime"` - IsCurrent bool `json:"isCurrent"` - TaskQueuesInfos []taskQueuesInfosRowType `json:"taskQueuesInfos,omitempty"` - Metadata map[string]*common.Payload `json:"metadata,omitempty"` + Deployment deploymentType `json:"deployment"` + CreateTime time.Time `json:"createTime"` + IsCurrent bool `json:"isCurrent"` + TaskQueuesInfos []taskQueuesInfosRowType `json:"taskQueuesInfos,omitempty"` + Metadata map[string]*common.Payload `json:"metadata,omitempty"` } type formattedDeploymentReachabilityInfoType struct { DeploymentInfo formattedDeploymentInfoType `json:"deploymentInfo"` - Reachability string `json:"reachability"` - LastUpdateTime time.Time `json:"lastUpdateTime"` + Reachability string `json:"reachability"` + LastUpdateTime time.Time `json:"lastUpdateTime"` } type formattedDeploymentListEntryType struct { SeriesName string - BuildID string + BuildID string CreateTime time.Time - IsCurrent bool + IsCurrent bool } type formattedDualDeploymentInfoType struct { - Previous formattedDeploymentInfoType `json:"previous"` - Current formattedDeploymentInfoType `json:"current"` + Previous formattedDeploymentInfoType `json:"previous"` + Current formattedDeploymentInfoType `json:"current"` } - func formatTaskQueuesInfos(tqis []client.DeploymentTaskQueueInfo) ([]taskQueuesInfosRowType, error) { var tqiRows []taskQueuesInfosRowType for _, tqi := range tqis { - tqTypeStr, err := taskQueueTypeToStr(tqi.Type) + tqTypeStr, err := taskQueueTypeToStr(tqi.Type) if err != nil { return tqiRows, err } tqiRows = append(tqiRows, taskQueuesInfosRowType{ - Name: tqi.Name, - Type: tqTypeStr, + Name: tqi.Name, + Type: tqTypeStr, FirstPollerTime: tqi.FirstPollerTime, }) } @@ -74,12 +72,12 @@ func deploymentInfoToRows(deploymentInfo client.DeploymentInfo) (formattedDeploy return formattedDeploymentInfoType{ Deployment: deploymentType{ SeriesName: deploymentInfo.Deployment.SeriesName, - BuildID: deploymentInfo.Deployment.BuildID, + BuildID: deploymentInfo.Deployment.BuildID, }, - CreateTime: deploymentInfo.CreateTime, - IsCurrent: deploymentInfo.IsCurrent, + CreateTime: deploymentInfo.CreateTime, + IsCurrent: deploymentInfo.IsCurrent, TaskQueuesInfos: tqi, - Metadata: deploymentInfo.Metadata, + Metadata: deploymentInfo.Metadata, }, nil } @@ -94,16 +92,16 @@ func printDeploymentInfo(cctx *CommandContext, deploymentInfo client.DeploymentI cctx.Printer.Println(color.MagentaString(msg)) printMe := struct { SeriesName string - BuildID string + BuildID string CreateTime time.Time - IsCurrent bool - Metadata map[string]*common.Payload `cli:",cardOmitEmpty"` + IsCurrent bool + Metadata map[string]*common.Payload `cli:",cardOmitEmpty"` }{ SeriesName: deploymentInfo.Deployment.SeriesName, - BuildID: deploymentInfo.Deployment.BuildID, + BuildID: deploymentInfo.Deployment.BuildID, CreateTime: deploymentInfo.CreateTime, - IsCurrent: deploymentInfo.IsCurrent, - Metadata: deploymentInfo.Metadata, + IsCurrent: deploymentInfo.IsCurrent, + Metadata: deploymentInfo.Metadata, } err := cctx.Printer.PrintStructured(printMe, printer.StructuredOptions{}) if err != nil { @@ -158,7 +156,7 @@ func printDeploymentReachabilityInfo(cctx *CommandContext, reachability client.D fReachabilityInfo := formattedDeploymentReachabilityInfoType{ DeploymentInfo: fDeploymentInfo, LastUpdateTime: reachability.LastUpdateTime, - Reachability: rTypeStr, + Reachability: rTypeStr, } if !cctx.JSONOutput { @@ -171,10 +169,10 @@ func printDeploymentReachabilityInfo(cctx *CommandContext, reachability client.D cctx.Printer.Println(color.MagentaString("Reachability:")) printMe := struct { LastUpdateTime time.Time - Reachability string + Reachability string }{ LastUpdateTime: fReachabilityInfo.LastUpdateTime, - Reachability: fReachabilityInfo.Reachability, + Reachability: fReachabilityInfo.Reachability, } return cctx.Printer.PrintStructured(printMe, printer.StructuredOptions{}) } @@ -188,12 +186,12 @@ func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.Dep if !cctx.JSONOutput { err := printDeploymentInfo(cctx, response.Previous, "Previous Deployment:") if err != nil { - return fmt.Errorf("displaying previous deployment info failed: %w", err) + return fmt.Errorf("displaying previous deployment info failed: %w", err) } err = printDeploymentInfo(cctx, response.Current, "Current Deployment:") if err != nil { - return fmt.Errorf("displaying current deployment info failed: %w", err) + return fmt.Errorf("displaying current deployment info failed: %w", err) } return nil @@ -210,7 +208,7 @@ func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.Dep return cctx.Printer.PrintStructured(formattedDualDeploymentInfoType{ Previous: previous, - Current: current, + Current: current, }, printer.StructuredOptions{}) } @@ -226,7 +224,7 @@ func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []str resp, err := cl.DeploymentClient().GetReachability(cctx, client.DeploymentGetReachabilityOptions{ Deployment: client.Deployment{ SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + BuildID: c.DeploymentBuildId, }, }) if err != nil { @@ -241,7 +239,7 @@ func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []str resp, err := cl.DeploymentClient().Describe(cctx, client.DeploymentDescribeOptions{ Deployment: client.Deployment{ SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + BuildID: c.DeploymentBuildId, }, }) if err != nil { @@ -257,7 +255,6 @@ func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []str return nil } - func (c *TemporalDeploymentGetCurrentCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.ClientOptions.dialClient(cctx) if err != nil { @@ -280,7 +277,6 @@ func (c *TemporalDeploymentGetCurrentCommand) run(cctx *CommandContext, args []s return nil } - func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.dialClient(cctx) if err != nil { @@ -314,10 +310,10 @@ func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) listEntry := formattedDeploymentInfoType{ Deployment: deploymentType{ SeriesName: entry.Deployment.SeriesName, - BuildID: entry.Deployment.BuildID, + BuildID: entry.Deployment.BuildID, }, CreateTime: entry.CreateTime, - IsCurrent: entry.IsCurrent, + IsCurrent: entry.IsCurrent, } if cctx.JSONOutput { // For JSON dump one line of JSON per deployment @@ -326,9 +322,9 @@ func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) // For non-JSON, we are doing a table for each page page = append(page, &formattedDeploymentListEntryType{ SeriesName: listEntry.Deployment.SeriesName, - BuildID: listEntry.Deployment.BuildID, + BuildID: listEntry.Deployment.BuildID, CreateTime: listEntry.CreateTime, - IsCurrent: listEntry.IsCurrent, + IsCurrent: listEntry.IsCurrent, }) if len(page) == cap(page) { _ = cctx.Printer.PrintStructured(page, printTableOpts) @@ -346,7 +342,6 @@ func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) return nil } - func (c *TemporalDeploymentUpdateCurrentCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.dialClient(cctx) if err != nil { @@ -354,7 +349,7 @@ func (c *TemporalDeploymentUpdateCurrentCommand) run(cctx *CommandContext, args } defer cl.Close() - metadata, err := stringKeysJSONValues(c.DeploymentMetadata, false); + metadata, err := stringKeysJSONValues(c.DeploymentMetadata, false) if err != nil { return fmt.Errorf("invalid metadata values: %w", err) } @@ -362,7 +357,7 @@ func (c *TemporalDeploymentUpdateCurrentCommand) run(cctx *CommandContext, args resp, err := cl.DeploymentClient().SetCurrent(cctx, client.DeploymentSetCurrentOptions{ Deployment: client.Deployment{ SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + BuildID: c.DeploymentBuildId, }, MetadataUpdate: client.DeploymentMetadataUpdate{ UpsertEntries: metadata, diff --git a/temporalcli/commands.deployment_test.go b/temporalcli/commands.deployment_test.go index ff273f242..e3827fe1c 100644 --- a/temporalcli/commands.deployment_test.go +++ b/temporalcli/commands.deployment_test.go @@ -11,34 +11,34 @@ import ( ) type jsonTaskQueuesInfosRowType struct { - Name string `json:"name"` - Type string `json:"type"` - FirstPollerTime time.Time `json:"firstPollerTime"` + Name string `json:"name"` + Type string `json:"type"` + FirstPollerTime time.Time `json:"firstPollerTime"` } type jsonDeploymentType struct { SeriesName string `json:"seriesName"` - BuildID string `json:"buildId"` + BuildID string `json:"buildId"` } type jsonDeploymentInfoType struct { - Deployment jsonDeploymentType `json:"deployment"` - CreateTime time.Time `json:"createTime"` - IsCurrent bool `json:"isCurrent"` + Deployment jsonDeploymentType `json:"deployment"` + CreateTime time.Time `json:"createTime"` + IsCurrent bool `json:"isCurrent"` TaskQueuesInfos []jsonTaskQueuesInfosRowType `json:"taskQueuesInfos,omitempty"` - Metadata map[string]*common.Payload `json:"metadata,omitempty"` + Metadata map[string]*common.Payload `json:"metadata,omitempty"` } type jsonDeploymentReachabilityInfoType struct { DeploymentInfo jsonDeploymentInfoType `json:"deploymentInfo"` - Reachability string `json:"reachability"` - LastUpdateTime time.Time `json:"lastUpdateTime"` + Reachability string `json:"reachability"` + LastUpdateTime time.Time `json:"lastUpdateTime"` } type jsonDeploymentListEntryType struct { Deployment jsonDeploymentType `json:"deployment"` - CreateTime time.Time `json:"createTime"` - IsCurrent bool `json:"isCurrent"` + CreateTime time.Time `json:"createTime"` + IsCurrent bool `json:"isCurrent"` } func (s *SharedServerSuite) TestDeployment_Update_Current() { diff --git a/temporalcli/commands.workflow.go b/temporalcli/commands.workflow.go index 9592f2908..ee1828504 100644 --- a/temporalcli/commands.workflow.go +++ b/temporalcli/commands.workflow.go @@ -139,12 +139,12 @@ func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *Comma _, err := cl.UpdateWorkflowExecutionOptions(cctx, client.UpdateWorkflowExecutionOptionsRequest{ WorkflowId: exec.WorkflowId, - RunId: exec.RunId, + RunId: exec.RunId, WorkflowExecutionOptionsChanges: client.WorkflowExecutionOptionsChanges{ VersioningOverride: &client.VersioningOverride{ Behavior: behavior, Deployment: client.Deployment{ - SeriesName: c.DeploymentSeriesName, + SeriesName: c.DeploymentSeriesName, BuildID: c.DeploymentBuildId, }, }, @@ -176,10 +176,10 @@ func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *Comma } deployment := &deploymentpb.Deployment{ - SeriesName: c.DeploymentSeriesName, - BuildId: c.DeploymentBuildId, - } - if c.DeploymentSeriesName == "" && c.DeploymentBuildId == "" { + SeriesName: c.DeploymentSeriesName, + BuildId: c.DeploymentBuildId, + } + if c.DeploymentSeriesName == "" && c.DeploymentBuildId == "" { // auto_upgrade needs a `nil` pointer deployment = nil } diff --git a/temporalcli/commands.workflow_test.go b/temporalcli/commands.workflow_test.go index 1ad15d44c..6d75e62a6 100644 --- a/temporalcli/commands.workflow_test.go +++ b/temporalcli/commands.workflow_test.go @@ -432,14 +432,14 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Overrid } w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{ Worker: worker.Options{ - BuildID: buildId1, + BuildID: buildId1, UseBuildIDForVersioning: true, DeploymentOptions: worker.DeploymentOptions{ - DeploymentSeriesName: seriesName, + DeploymentSeriesName: seriesName, DefaultVersioningBehavior: workflow.VersioningBehaviorPinned, }, }, - Workflows: []any{waitingWorkflow}, + Workflows: []any{waitingWorkflow}, }) defer w.Stop() @@ -485,7 +485,7 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Overrid res = s.Execute( "workflow", "modify-options", "versioning-override", "--address", s.Address(), - "--query", "CustomKeywordField = '" + searchAttr + "'", + "--query", "CustomKeywordField = '"+searchAttr+"'", "--deployment-behavior", "pinned", "--deployment-series-name", seriesName, "--deployment-build-id", buildId2, @@ -523,14 +523,14 @@ func (s *SharedServerSuite) TestWorkflow_Modify_Options_Versioning_Override() { } w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{ Worker: worker.Options{ - BuildID: buildId1, + BuildID: buildId1, UseBuildIDForVersioning: true, DeploymentOptions: worker.DeploymentOptions{ - DeploymentSeriesName: seriesName, + DeploymentSeriesName: seriesName, DefaultVersioningBehavior: workflow.VersioningBehaviorPinned, }, }, - Workflows: []any{waitingWorkflow}, + Workflows: []any{waitingWorkflow}, }) defer w.Stop() diff --git a/temporalcli/commands.workflow_view.go b/temporalcli/commands.workflow_view.go index 760f58bf6..9f5e998a0 100644 --- a/temporalcli/commands.workflow_view.go +++ b/temporalcli/commands.workflow_view.go @@ -140,23 +140,23 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin cctx.Printer.Println() vInfo := info.VersioningInfo _ = cctx.Printer.PrintStructured(struct { - Behavior string - DeploymentSeriesName string - DeploymentBuildID string - OverrideBehavior string `cli:",cardOmitEmpty"` - OverrideDeploymentSeriesName string `cli:",cardOmitEmpty"` - OverrideDeploymentBuildID string `cli:",cardOmitEmpty"` + Behavior string + DeploymentSeriesName string + DeploymentBuildID string + OverrideBehavior string `cli:",cardOmitEmpty"` + OverrideDeploymentSeriesName string `cli:",cardOmitEmpty"` + OverrideDeploymentBuildID string `cli:",cardOmitEmpty"` TransitionDeploymentSeriesName string `cli:",cardOmitEmpty"` - TransitionDeploymentBuildID string `cli:",cardOmitEmpty"` + TransitionDeploymentBuildID string `cli:",cardOmitEmpty"` }{ - Behavior: vInfo.Behavior.String(), - DeploymentSeriesName: vInfo.Deployment.GetSeriesName(), - DeploymentBuildID: vInfo.Deployment.GetBuildId(), - OverrideBehavior: vInfo.VersioningOverride.GetBehavior().String(), - OverrideDeploymentSeriesName: vInfo.VersioningOverride.GetDeployment().GetSeriesName(), - OverrideDeploymentBuildID: vInfo.VersioningOverride.GetDeployment().GetBuildId(), + Behavior: vInfo.Behavior.String(), + DeploymentSeriesName: vInfo.Deployment.GetSeriesName(), + DeploymentBuildID: vInfo.Deployment.GetBuildId(), + OverrideBehavior: vInfo.VersioningOverride.GetBehavior().String(), + OverrideDeploymentSeriesName: vInfo.VersioningOverride.GetDeployment().GetSeriesName(), + OverrideDeploymentBuildID: vInfo.VersioningOverride.GetDeployment().GetBuildId(), TransitionDeploymentSeriesName: vInfo.DeploymentTransition.GetDeployment().GetSeriesName(), - TransitionDeploymentBuildID: vInfo.DeploymentTransition.GetDeployment().GetBuildId(), + TransitionDeploymentBuildID: vInfo.DeploymentTransition.GetDeployment().GetBuildId(), }, printer.StructuredOptions{}) } diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index a1e1112fb..58a67e996 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -20,9 +20,9 @@ import ( "go.temporal.io/api/operatorservice/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" - "go.temporal.io/sdk/worker" "go.temporal.io/sdk/temporal" "go.temporal.io/sdk/temporalnexus" + "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" ) @@ -558,14 +558,14 @@ func (s *SharedServerSuite) TestWorkflow_Describe_Deployment() { } w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{ Worker: worker.Options{ - BuildID: buildId, + BuildID: buildId, UseBuildIDForVersioning: true, DeploymentOptions: worker.DeploymentOptions{ - DeploymentSeriesName: seriesName, + DeploymentSeriesName: seriesName, DefaultVersioningBehavior: workflow.VersioningBehaviorPinned, }, }, - Workflows: []any{waitingWorkflow}, + Workflows: []any{waitingWorkflow}, }) defer w.Stop() From e85befe63ed2e2b1bf7df3744ead94d3e6b0d83e Mon Sep 17 00:00:00 2001 From: Antonio Lain Date: Tue, 7 Jan 2025 18:41:24 +0000 Subject: [PATCH 3/4] Rename operations and options --- temporalcli/commands.deployment.go | 54 +-- temporalcli/commands.deployment_test.go | 62 ++-- temporalcli/commands.gen.go | 382 ++++++++++----------- temporalcli/commands.workflow.go | 44 +-- temporalcli/commands.workflow_test.go | 36 +- temporalcli/commands.workflow_view_test.go | 6 +- temporalcli/commandsgen/commands.yml | 178 ++++------ 7 files changed, 358 insertions(+), 404 deletions(-) diff --git a/temporalcli/commands.deployment.go b/temporalcli/commands.deployment.go index 8e3255b46..f1bf1c0bc 100644 --- a/temporalcli/commands.deployment.go +++ b/temporalcli/commands.deployment.go @@ -105,7 +105,7 @@ func printDeploymentInfo(cctx *CommandContext, deploymentInfo client.DeploymentI } err := cctx.Printer.PrintStructured(printMe, printer.StructuredOptions{}) if err != nil { - return fmt.Errorf("displaying deployment info failed: %w", err) + return fmt.Errorf("displaying worker deployment info failed: %w", err) } if len(deploymentInfo.TaskQueuesInfos) > 0 { @@ -160,7 +160,7 @@ func printDeploymentReachabilityInfo(cctx *CommandContext, reachability client.D } if !cctx.JSONOutput { - err := printDeploymentInfo(cctx, reachability.DeploymentInfo, "Deployment:") + err := printDeploymentInfo(cctx, reachability.DeploymentInfo, "Worker Deployment:") if err != nil { return err } @@ -184,14 +184,14 @@ func printDeploymentReachabilityInfo(cctx *CommandContext, reachability client.D func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.DeploymentSetCurrentResponse) error { if !cctx.JSONOutput { - err := printDeploymentInfo(cctx, response.Previous, "Previous Deployment:") + err := printDeploymentInfo(cctx, response.Previous, "Previous Worker Deployment:") if err != nil { - return fmt.Errorf("displaying previous deployment info failed: %w", err) + return fmt.Errorf("displaying previous worker deployment info failed: %w", err) } - err = printDeploymentInfo(cctx, response.Current, "Current Deployment:") + err = printDeploymentInfo(cctx, response.Current, "Current Worker Deployment:") if err != nil { - return fmt.Errorf("displaying current deployment info failed: %w", err) + return fmt.Errorf("displaying current worker deployment info failed: %w", err) } return nil @@ -199,11 +199,11 @@ func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.Dep previous, err := deploymentInfoToRows(response.Previous) if err != nil { - return fmt.Errorf("displaying previous deployment info failed: %w", err) + return fmt.Errorf("displaying previous worker deployment info failed: %w", err) } current, err := deploymentInfoToRows(response.Current) if err != nil { - return fmt.Errorf("displaying current deployment info failed: %w", err) + return fmt.Errorf("displaying current worker deployment info failed: %w", err) } return cctx.Printer.PrintStructured(formattedDualDeploymentInfoType{ @@ -212,7 +212,7 @@ func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.Dep }, printer.StructuredOptions{}) } -func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []string) error { +func (c *TemporalWorkerDeploymentDescribeCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.ClientOptions.dialClient(cctx) if err != nil { return err @@ -223,12 +223,12 @@ func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []str // Expensive call, rate-limited by target method resp, err := cl.DeploymentClient().GetReachability(cctx, client.DeploymentGetReachabilityOptions{ Deployment: client.Deployment{ - SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + SeriesName: c.SeriesName, + BuildID: c.BuildId, }, }) if err != nil { - return fmt.Errorf("error describing deployment with reachability: %w", err) + return fmt.Errorf("error describing worker deployment with reachability: %w", err) } err = printDeploymentReachabilityInfo(cctx, resp) @@ -238,14 +238,14 @@ func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []str } else { resp, err := cl.DeploymentClient().Describe(cctx, client.DeploymentDescribeOptions{ Deployment: client.Deployment{ - SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + SeriesName: c.SeriesName, + BuildID: c.BuildId, }, }) if err != nil { - return fmt.Errorf("error describing deployment: %w", err) + return fmt.Errorf("error describing worker deployment: %w", err) } - err = printDeploymentInfo(cctx, resp.DeploymentInfo, "Deployment:") + err = printDeploymentInfo(cctx, resp.DeploymentInfo, "Worker Deployment:") if err != nil { return err } @@ -255,7 +255,7 @@ func (c *TemporalDeploymentDescribeCommand) run(cctx *CommandContext, args []str return nil } -func (c *TemporalDeploymentGetCurrentCommand) run(cctx *CommandContext, args []string) error { +func (c *TemporalWorkerDeploymentGetCurrentCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.ClientOptions.dialClient(cctx) if err != nil { return err @@ -263,13 +263,13 @@ func (c *TemporalDeploymentGetCurrentCommand) run(cctx *CommandContext, args []s defer cl.Close() resp, err := cl.DeploymentClient().GetCurrent(cctx, client.DeploymentGetCurrentOptions{ - SeriesName: c.DeploymentSeriesName, + SeriesName: c.SeriesName, }) if err != nil { return fmt.Errorf("error getting the current deployment: %w", err) } - err = printDeploymentInfo(cctx, resp.DeploymentInfo, "Current Deployment:") + err = printDeploymentInfo(cctx, resp.DeploymentInfo, "Current Worker Deployment:") if err != nil { return err } @@ -277,7 +277,7 @@ func (c *TemporalDeploymentGetCurrentCommand) run(cctx *CommandContext, args []s return nil } -func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) error { +func (c *TemporalWorkerDeploymentListCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.dialClient(cctx) if err != nil { return err @@ -285,7 +285,7 @@ func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) defer cl.Close() res, err := cl.DeploymentClient().List(cctx, client.DeploymentListOptions{ - SeriesName: c.DeploymentSeriesName, + SeriesName: c.SeriesName, }) if err != nil { return err @@ -342,29 +342,29 @@ func (c *TemporalDeploymentListCommand) run(cctx *CommandContext, args []string) return nil } -func (c *TemporalDeploymentUpdateCurrentCommand) run(cctx *CommandContext, args []string) error { +func (c *TemporalWorkerDeploymentSetCurrentCommand) run(cctx *CommandContext, args []string) error { cl, err := c.Parent.dialClient(cctx) if err != nil { return err } defer cl.Close() - metadata, err := stringKeysJSONValues(c.DeploymentMetadata, false) + metadata, err := stringKeysJSONValues(c.Metadata, false) if err != nil { return fmt.Errorf("invalid metadata values: %w", err) } resp, err := cl.DeploymentClient().SetCurrent(cctx, client.DeploymentSetCurrentOptions{ Deployment: client.Deployment{ - SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + SeriesName: c.SeriesName, + BuildID: c.BuildId, }, MetadataUpdate: client.DeploymentMetadataUpdate{ UpsertEntries: metadata, }, }) if err != nil { - return fmt.Errorf("error updating the current deployment: %w", err) + return fmt.Errorf("error setting the current worker deployment: %w", err) } err = printDeploymentSetCurrentResponse(cctx, resp) @@ -372,6 +372,6 @@ func (c *TemporalDeploymentUpdateCurrentCommand) run(cctx *CommandContext, args return err } - cctx.Printer.Println("Successfully updating the current deployment") + cctx.Printer.Println("Successfully setting the current worker deployment") return nil } diff --git a/temporalcli/commands.deployment_test.go b/temporalcli/commands.deployment_test.go index e3827fe1c..db200b501 100644 --- a/temporalcli/commands.deployment_test.go +++ b/temporalcli/commands.deployment_test.go @@ -41,23 +41,23 @@ type jsonDeploymentListEntryType struct { IsCurrent bool `json:"isCurrent"` } -func (s *SharedServerSuite) TestDeployment_Update_Current() { +func (s *SharedServerSuite) TestDeployment_Set_Current() { seriesName := uuid.NewString() buildId := uuid.NewString() res := s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId, - "--deployment-metadata", "bar=1", + "--series-name", seriesName, + "--build-id", buildId, + "--metadata", "bar=1", ) s.NoError(res.Err) res = s.Execute( - "deployment", "get-current", + "worker-deployment", "get-current", "--address", s.Address(), - "--deployment-series-name", seriesName, + "--series-name", seriesName, ) s.NoError(res.Err) @@ -68,9 +68,9 @@ func (s *SharedServerSuite) TestDeployment_Update_Current() { // json res = s.Execute( - "deployment", "get-current", + "worker-deployment", "get-current", "--address", s.Address(), - "--deployment-series-name", seriesName, + "--series-name", seriesName, "--output", "json", ) s.NoError(res.Err) @@ -91,25 +91,25 @@ func (s *SharedServerSuite) TestDeployment_List() { buildId2 := uuid.NewString() res := s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId1, + "--series-name", seriesName, + "--build-id", buildId1, ) s.NoError(res.Err) res = s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId2, + "--series-name", seriesName, + "--build-id", buildId2, ) s.NoError(res.Err) res = s.Execute( - "deployment", "list", + "worker-deployment", "list", "--address", s.Address(), - "--deployment-series-name", seriesName, + "--series-name", seriesName, ) s.NoError(res.Err) @@ -118,9 +118,9 @@ func (s *SharedServerSuite) TestDeployment_List() { // json res = s.Execute( - "deployment", "list", + "worker-deployment", "list", "--address", s.Address(), - "--deployment-series-name", seriesName, + "--series-name", seriesName, "--output", "json", ) s.NoError(res.Err) @@ -143,26 +143,26 @@ func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { buildId2 := uuid.NewString() res := s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId1, + "--series-name", seriesName, + "--build-id", buildId1, ) s.NoError(res.Err) res = s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId2, + "--series-name", seriesName, + "--build-id", buildId2, ) s.NoError(res.Err) res = s.Execute( - "deployment", "describe", + "worker-deployment", "describe", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId1, + "--series-name", seriesName, + "--build-id", buildId1, "--report-reachability", ) s.NoError(res.Err) @@ -174,10 +174,10 @@ func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { // json res = s.Execute( - "deployment", "describe", + "worker-deployment", "describe", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId2, + "--series-name", seriesName, + "--build-id", buildId2, "--report-reachability", "--output", "json", ) diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index 23fd5dfd6..27eb3caf1 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -132,15 +132,15 @@ func (v *WorkflowReferenceOptions) buildFlags(cctx *CommandContext, f *pflag.Fla } type DeploymentReferenceOptions struct { - DeploymentSeriesName string - DeploymentBuildId string + SeriesName string + BuildId string } func (v *DeploymentReferenceOptions) buildFlags(cctx *CommandContext, f *pflag.FlagSet) { - f.StringVar(&v.DeploymentSeriesName, "deployment-series-name", "", "Series Name for a Deployment. Required.") - _ = cobra.MarkFlagRequired(f, "deployment-series-name") - f.StringVar(&v.DeploymentBuildId, "deployment-build-id", "", "Build ID for a Deployment. Required.") - _ = cobra.MarkFlagRequired(f, "deployment-build-id") + f.StringVar(&v.SeriesName, "series-name", "", "Series Name for a Worker Deployment. Required.") + _ = cobra.MarkFlagRequired(f, "series-name") + f.StringVar(&v.BuildId, "build-id", "", "Build ID for a Worker Deployment. Required.") + _ = cobra.MarkFlagRequired(f, "build-id") } type SingleWorkflowOrBatchOptions struct { @@ -303,12 +303,12 @@ func NewTemporalCommand(cctx *CommandContext) *TemporalCommand { s.Command.Args = cobra.NoArgs s.Command.AddCommand(&NewTemporalActivityCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalBatchCommand(cctx, &s).Command) - s.Command.AddCommand(&NewTemporalDeploymentCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalEnvCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalOperatorCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalScheduleCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalServerCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalTaskQueueCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkerDeploymentCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowCommand(cctx, &s).Command) s.Command.PersistentFlags().StringVar(&s.Env, "env", "default", "Active environment name (`ENV`).") cctx.BindFlagEnvVar(s.Command.PersistentFlags().Lookup("env"), "TEMPORAL_ENV") @@ -534,144 +534,6 @@ func NewTemporalBatchTerminateCommand(cctx *CommandContext, parent *TemporalBatc return &s } -type TemporalDeploymentCommand struct { - Parent *TemporalCommand - Command cobra.Command - ClientOptions -} - -func NewTemporalDeploymentCommand(cctx *CommandContext, parent *TemporalCommand) *TemporalDeploymentCommand { - var s TemporalDeploymentCommand - s.Parent = parent - s.Command.Use = "deployment" - s.Command.Short = "Describe, list, and operate on Deployments" - if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n\x1b[1mtemporal deployment [command] [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal deployment list\x1b[0m" - } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n```\ntemporal deployment [command] [options]\n```\n\nFor example:\n\n```\ntemporal deployment list\n```" - } - s.Command.Args = cobra.NoArgs - s.Command.AddCommand(&NewTemporalDeploymentDescribeCommand(cctx, &s).Command) - s.Command.AddCommand(&NewTemporalDeploymentGetCurrentCommand(cctx, &s).Command) - s.Command.AddCommand(&NewTemporalDeploymentListCommand(cctx, &s).Command) - s.Command.AddCommand(&NewTemporalDeploymentUpdateCurrentCommand(cctx, &s).Command) - s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags()) - return &s -} - -type TemporalDeploymentDescribeCommand struct { - Parent *TemporalDeploymentCommand - Command cobra.Command - DeploymentReferenceOptions - ReportReachability bool -} - -func NewTemporalDeploymentDescribeCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentDescribeCommand { - var s TemporalDeploymentDescribeCommand - s.Parent = parent - s.Command.DisableFlagsInUseLine = true - s.Command.Use = "describe [flags]" - s.Command.Short = "Show properties of a Deployment" - if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Deployment, such as whether it is current,\nsome custom metadata, or a list of its task queues.\n\n\x1b[1mtemporal deployment describe [options]\x1b[0m\n\nFor example, to also include reachability information:\n\n\x1b[1mtemporal deployment describe \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId \\\n --report-reachability\x1b[0m" - } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Deployment, such as whether it is current,\nsome custom metadata, or a list of its task queues.\n\n```\ntemporal deployment describe [options]\n```\n\nFor example, to also include reachability information:\n\n```\ntemporal deployment describe \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId \\\n --report-reachability\n```" - } - s.Command.Args = cobra.NoArgs - s.Command.Flags().BoolVar(&s.ReportReachability, "report-reachability", false, "Flag to include reachability information of a Deployment.") - s.DeploymentReferenceOptions.buildFlags(cctx, s.Command.Flags()) - s.Command.Run = func(c *cobra.Command, args []string) { - if err := s.run(cctx, args); err != nil { - cctx.Options.Fail(err) - } - } - return &s -} - -type TemporalDeploymentGetCurrentCommand struct { - Parent *TemporalDeploymentCommand - Command cobra.Command - DeploymentSeriesName string -} - -func NewTemporalDeploymentGetCurrentCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentGetCurrentCommand { - var s TemporalDeploymentGetCurrentCommand - s.Parent = parent - s.Command.DisableFlagsInUseLine = true - s.Command.Use = "get-current [flags]" - s.Command.Short = "Show the current Deployment" - if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Deployment for a Deployment Series Name. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n\n\x1b[1mtemporal deployment get-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal deployment get-current \\\n --deployment-series-name YourDeploymentSeriesName\x1b[0m" - } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Deployment for a Deployment Series Name. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n\n```\ntemporal deployment get-current [options]\n```\n\nFor example:\n\n```\ntemporal deployment get-current \\\n --deployment-series-name YourDeploymentSeriesName\n```" - } - s.Command.Args = cobra.NoArgs - s.Command.Flags().StringVar(&s.DeploymentSeriesName, "deployment-series-name", "", "Series Name for the current Deployment. Required.") - _ = cobra.MarkFlagRequired(s.Command.Flags(), "deployment-series-name") - s.Command.Run = func(c *cobra.Command, args []string) { - if err := s.run(cctx, args); err != nil { - cctx.Options.Fail(err) - } - } - return &s -} - -type TemporalDeploymentListCommand struct { - Parent *TemporalDeploymentCommand - Command cobra.Command - DeploymentSeriesName string -} - -func NewTemporalDeploymentListCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentListCommand { - var s TemporalDeploymentListCommand - s.Parent = parent - s.Command.DisableFlagsInUseLine = true - s.Command.Use = "list [flags]" - s.Command.Short = "Enumerate Deployments in the client's namespace" - if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n\x1b[1mtemporal deployment list [options]\x1b[0m\n\nFor example, adding an optional filter:\n\n\x1b[1mtemporal deployment list \\\n --deployment-series-name YourDeploymentSeriesName\x1b[0m" - } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n```\ntemporal deployment list [options]\n```\n\nFor example, adding an optional filter:\n\n```\ntemporal deployment list \\\n --deployment-series-name YourDeploymentSeriesName\n```" - } - s.Command.Args = cobra.NoArgs - s.Command.Flags().StringVar(&s.DeploymentSeriesName, "deployment-series-name", "", "Series Name to filter Deployments.") - s.Command.Run = func(c *cobra.Command, args []string) { - if err := s.run(cctx, args); err != nil { - cctx.Options.Fail(err) - } - } - return &s -} - -type TemporalDeploymentUpdateCurrentCommand struct { - Parent *TemporalDeploymentCommand - Command cobra.Command - DeploymentReferenceOptions - DeploymentMetadata []string -} - -func NewTemporalDeploymentUpdateCurrentCommand(cctx *CommandContext, parent *TemporalDeploymentCommand) *TemporalDeploymentUpdateCurrentCommand { - var s TemporalDeploymentUpdateCurrentCommand - s.Parent = parent - s.Command.DisableFlagsInUseLine = true - s.Command.Use = "update-current [flags]" - s.Command.Short = "Change the current Deployment" - if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n\x1b[1mtemporal deployment update-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal deployment update-current \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\x1b[0m" - } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series. Whether a\nDeployment is current or not can affect which Workers will execute\nTasks of an existing or new Workflow.\n\n```\ntemporal deployment update-current [options]\n```\n\nFor example:\n\n```\ntemporal deployment update-current \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\n```" - } - s.Command.Args = cobra.NoArgs - s.Command.Flags().StringArrayVar(&s.DeploymentMetadata, "deployment-metadata", nil, "Set deployment metadata using `KEY=\"VALUE\"` pairs. Keys must be identifiers, and values must be JSON values. For example: 'YourKey={\"your\": \"value\"}'. Can be passed multiple times.") - s.DeploymentReferenceOptions.buildFlags(cctx, s.Command.Flags()) - s.Command.Run = func(c *cobra.Command, args []string) { - if err := s.run(cctx, args); err != nil { - cctx.Options.Fail(err) - } - } - return &s -} - type TemporalEnvCommand struct { Parent *TemporalCommand Command cobra.Command @@ -2477,6 +2339,144 @@ func NewTemporalTaskQueueVersioningReplaceRedirectRuleCommand(cctx *CommandConte return &s } +type TemporalWorkerDeploymentCommand struct { + Parent *TemporalCommand + Command cobra.Command + ClientOptions +} + +func NewTemporalWorkerDeploymentCommand(cctx *CommandContext, parent *TemporalCommand) *TemporalWorkerDeploymentCommand { + var s TemporalWorkerDeploymentCommand + s.Parent = parent + s.Command.Use = "worker-deployment" + s.Command.Short = "Describe, list, and operate on Worker Deployments" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n\x1b[1mtemporal worker-deployment [command] [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker-deployment list\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n```\ntemporal worker-deployment [command] [options]\n```\n\nFor example:\n\n```\ntemporal worker-deployment list\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.AddCommand(&NewTemporalWorkerDeploymentDescribeCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkerDeploymentGetCurrentCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkerDeploymentListCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkerDeploymentSetCurrentCommand(cctx, &s).Command) + s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags()) + return &s +} + +type TemporalWorkerDeploymentDescribeCommand struct { + Parent *TemporalWorkerDeploymentCommand + Command cobra.Command + DeploymentReferenceOptions + ReportReachability bool +} + +func NewTemporalWorkerDeploymentDescribeCommand(cctx *CommandContext, parent *TemporalWorkerDeploymentCommand) *TemporalWorkerDeploymentDescribeCommand { + var s TemporalWorkerDeploymentDescribeCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "describe [flags]" + s.Command.Short = "Show properties of a Worker Deployment" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Worker Deployment, such as whether it is\ncurrent, the non-empty list of its task queues, custom metadata if\npresent, and reachability status when requested.\n\n\x1b[1mtemporal worker-deployment describe [options]\x1b[0m\n\nFor example, to also include reachability information:\n\n\x1b[1mtemporal worker-deployment describe \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId \\\n --report-reachability\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Worker Deployment, such as whether it is\ncurrent, the non-empty list of its task queues, custom metadata if\npresent, and reachability status when requested.\n\n```\ntemporal worker-deployment describe [options]\n```\n\nFor example, to also include reachability information:\n\n```\ntemporal worker-deployment describe \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId \\\n --report-reachability\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().BoolVar(&s.ReportReachability, "report-reachability", false, "Flag to include reachability information of a Worker Deployment.") + s.DeploymentReferenceOptions.buildFlags(cctx, s.Command.Flags()) + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + +type TemporalWorkerDeploymentGetCurrentCommand struct { + Parent *TemporalWorkerDeploymentCommand + Command cobra.Command + SeriesName string +} + +func NewTemporalWorkerDeploymentGetCurrentCommand(cctx *CommandContext, parent *TemporalWorkerDeploymentCommand) *TemporalWorkerDeploymentGetCurrentCommand { + var s TemporalWorkerDeploymentGetCurrentCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "get-current [flags]" + s.Command.Short = "Show the current Worker Deployment" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Worker Deployment for a Deployment Series Name.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n\x1b[1mtemporal worker-deployment get-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker-deployment get-current \\\n --series-name YourDeploymentSeriesName\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Worker Deployment for a Deployment Series Name.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n```\ntemporal worker-deployment get-current [options]\n```\n\nFor example:\n\n```\ntemporal worker-deployment get-current \\\n --series-name YourDeploymentSeriesName\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().StringVar(&s.SeriesName, "series-name", "", "Series Name for the current Worker Deployment. Required.") + _ = cobra.MarkFlagRequired(s.Command.Flags(), "series-name") + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + +type TemporalWorkerDeploymentListCommand struct { + Parent *TemporalWorkerDeploymentCommand + Command cobra.Command + SeriesName string +} + +func NewTemporalWorkerDeploymentListCommand(cctx *CommandContext, parent *TemporalWorkerDeploymentCommand) *TemporalWorkerDeploymentListCommand { + var s TemporalWorkerDeploymentListCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "list [flags]" + s.Command.Short = "Enumerate Worker Deployments in the client's namespace" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Worker Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n\x1b[1mtemporal worker-deployment list [options]\x1b[0m\n\nFor example, adding an optional filter:\n\n\x1b[1mtemporal worker-deployment list \\\n --series-name YourDeploymentSeriesName\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Worker Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n```\ntemporal worker-deployment list [options]\n```\n\nFor example, adding an optional filter:\n\n```\ntemporal worker-deployment list \\\n --series-name YourDeploymentSeriesName\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().StringVar(&s.SeriesName, "series-name", "", "Series Name to filter Worker Deployments.") + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + +type TemporalWorkerDeploymentSetCurrentCommand struct { + Parent *TemporalWorkerDeploymentCommand + Command cobra.Command + DeploymentReferenceOptions + Metadata []string +} + +func NewTemporalWorkerDeploymentSetCurrentCommand(cctx *CommandContext, parent *TemporalWorkerDeploymentCommand) *TemporalWorkerDeploymentSetCurrentCommand { + var s TemporalWorkerDeploymentSetCurrentCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "set-current [flags]" + s.Command.Short = "Change the current Worker Deployment" + if hasHighlighting { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n\x1b[1mtemporal worker-deployment set-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker-deployment set-current \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId\x1b[0m" + } else { + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n```\ntemporal worker-deployment set-current [options]\n```\n\nFor example:\n\n```\ntemporal worker-deployment set-current \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.Flags().StringArrayVar(&s.Metadata, "metadata", nil, "Set deployment metadata using `KEY=\"VALUE\"` pairs. Keys must be identifiers, and values must be JSON values. For example: 'YourKey={\"your\": \"value\"}'. Can be passed multiple times.") + s.DeploymentReferenceOptions.buildFlags(cctx, s.Command.Flags()) + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} + type TemporalWorkflowCommand struct { Parent *TemporalCommand Command cobra.Command @@ -2501,7 +2501,6 @@ func NewTemporalWorkflowCommand(cctx *CommandContext, parent *TemporalCommand) * s.Command.AddCommand(&NewTemporalWorkflowExecuteCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowFixHistoryJsonCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowListCommand(cctx, &s).Command) - s.Command.AddCommand(&NewTemporalWorkflowModifyOptionsCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowQueryCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowResetCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowResultCommand(cctx, &s).Command) @@ -2512,6 +2511,7 @@ func NewTemporalWorkflowCommand(cctx *CommandContext, parent *TemporalCommand) * s.Command.AddCommand(&NewTemporalWorkflowTerminateCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowTraceCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowUpdateCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkflowUpdateOptionsCommand(cctx, &s).Command) s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags()) return &s } @@ -2725,61 +2725,6 @@ func NewTemporalWorkflowListCommand(cctx *CommandContext, parent *TemporalWorkfl return &s } -type TemporalWorkflowModifyOptionsCommand struct { - Parent *TemporalWorkflowCommand - Command cobra.Command - SingleWorkflowOrBatchOptions -} - -func NewTemporalWorkflowModifyOptionsCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowModifyOptionsCommand { - var s TemporalWorkflowModifyOptionsCommand - s.Parent = parent - s.Command.Use = "modify-options" - s.Command.Short = "Change Workflow Execution Options" - if hasHighlighting { - s.Command.Long = "Modify properties of Workflow Executions:\n\n\x1b[1mtemporal workflow modify-options [command] [options]\x1b[0m\n\nFor example, properties that control Worker Versioning:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\x1b[0m" - } else { - s.Command.Long = "Modify properties of Workflow Executions:\n\n```\ntemporal workflow modify-options [command] [options]\n```\n\nFor example, properties that control Worker Versioning:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\n```" - } - s.Command.Args = cobra.NoArgs - s.Command.AddCommand(&NewTemporalWorkflowModifyOptionsVersioningOverrideCommand(cctx, &s).Command) - s.SingleWorkflowOrBatchOptions.buildFlags(cctx, s.Command.PersistentFlags()) - return &s -} - -type TemporalWorkflowModifyOptionsVersioningOverrideCommand struct { - Parent *TemporalWorkflowModifyOptionsCommand - Command cobra.Command - DeploymentBehavior StringEnum - DeploymentSeriesName string - DeploymentBuildId string -} - -func NewTemporalWorkflowModifyOptionsVersioningOverrideCommand(cctx *CommandContext, parent *TemporalWorkflowModifyOptionsCommand) *TemporalWorkflowModifyOptionsVersioningOverrideCommand { - var s TemporalWorkflowModifyOptionsVersioningOverrideCommand - s.Parent = parent - s.Command.DisableFlagsInUseLine = true - s.Command.Use = "versioning-override [flags]" - s.Command.Short = "Overrides the Deployment options of a Workflow Execution" - if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker versioning is experimental. Versioning commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nOverrides the Deployment configuration of a Workflow Execution, which\ncontrols Worker Versioning.\n\n\x1b[1mtemporal workflow modify-options versioning-override [options]\x1b[0m\n\nFor example, to force Workers in the current Deployment execute the\nnext Workflow Task:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\x1b[0m\n\nor to pin the workflow execution to a Deployment:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior pinned \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\x1b[0m\n\nTo remove any previous overrides, set the behavior to\nunspecified:\n\n\x1b[1mtemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior unspecified\x1b[0m\n\nTo see the current override use \x1b[1mtemporal workflow describe\x1b[0m" - } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker versioning is experimental. Versioning commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nOverrides the Deployment configuration of a Workflow Execution, which\ncontrols Worker Versioning.\n\n```\ntemporal workflow modify-options versioning-override [options]\n```\n\nFor example, to force Workers in the current Deployment execute the\nnext Workflow Task:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior auto_upgrade\n```\n\nor to pin the workflow execution to a Deployment:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior pinned \\\n --deployment-series-name YourDeploymentSeriesName \\\n --deployment-build-id YourDeploymentBuildId\n```\n\nTo remove any previous overrides, set the behavior to\nunspecified:\n\n```\ntemporal workflow modify-options versioning-override \\\n --workflow-id YourWorkflowId \\\n --deployment-behavior unspecified\n```\n\nTo see the current override use `temporal workflow describe`" - } - s.Command.Args = cobra.NoArgs - s.DeploymentBehavior = NewStringEnum([]string{"unspecified", "pinned", "auto_upgrade"}, "") - s.Command.Flags().Var(&s.DeploymentBehavior, "deployment-behavior", "Flag to describe the versioning behavior of a Workflow. Accepted values: unspecified, pinned, auto_upgrade. Required.") - _ = cobra.MarkFlagRequired(s.Command.Flags(), "deployment-behavior") - s.Command.Flags().StringVar(&s.DeploymentSeriesName, "deployment-series-name", "", "Series Name for a Deployment (Only for pinned).") - s.Command.Flags().StringVar(&s.DeploymentBuildId, "deployment-build-id", "", "Build ID for a Deployment (Only for pinned).") - s.Command.Run = func(c *cobra.Command, args []string) { - if err := s.run(cctx, args); err != nil { - cctx.Options.Fail(err) - } - } - return &s -} - type TemporalWorkflowQueryCommand struct { Parent *TemporalWorkflowCommand Command cobra.Command @@ -3236,3 +3181,38 @@ func NewTemporalWorkflowUpdateStartCommand(cctx *CommandContext, parent *Tempora } return &s } + +type TemporalWorkflowUpdateOptionsCommand struct { + Parent *TemporalWorkflowCommand + Command cobra.Command + SingleWorkflowOrBatchOptions + VersioningOverrideBehavior StringEnum + VersioningOverrideSeriesName string + VersioningOverrideBuildId string +} + +func NewTemporalWorkflowUpdateOptionsCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowUpdateOptionsCommand { + var s TemporalWorkflowUpdateOptionsCommand + s.Parent = parent + s.Command.DisableFlagsInUseLine = true + s.Command.Use = "update-options [flags]" + s.Command.Short = "Change Workflow Execution Options" + if hasHighlighting { + s.Command.Long = "Modify properties of Workflow Executions:\n\n\x1b[1mtemporal workflow update-options [options]\x1b[0m\n\nIt can override the Worker Deployment configuration of a\nWorkflow Execution, which controls Worker Versioning.\n\nFor example, to force Workers in the current Deployment execute the\nnext Workflow Task:\n\n\x1b[1mtemporal workflow update-options \\\n --workflow-id YourWorkflowId \\\n --versioning-override-behavior auto_upgrade\x1b[0m\n\nor to pin the workflow execution to a Worker Deployment:\n\n\x1b[1mtemporal workflow update-options \\\n --workflow-id YourWorkflowId \\\n --versioning-override-behavior pinned \\\n --versioning-override-series-name YourDeploymentSeriesName \\\n --versioning-override-build-id YourDeploymentBuildId\x1b[0m\n\nTo remove any previous overrides, set the behavior to\nunspecified:\n\n\x1b[1mtemporal workflow update-options \\\n --workflow-id YourWorkflowId \\\n --versioning-override-behavior unspecified\x1b[0m\n\nTo see the current override use \x1b[1mtemporal workflow describe\x1b[0m" + } else { + s.Command.Long = "Modify properties of Workflow Executions:\n\n```\ntemporal workflow update-options [options]\n```\n\nIt can override the Worker Deployment configuration of a\nWorkflow Execution, which controls Worker Versioning.\n\nFor example, to force Workers in the current Deployment execute the\nnext Workflow Task:\n\n```\ntemporal workflow update-options \\\n --workflow-id YourWorkflowId \\\n --versioning-override-behavior auto_upgrade\n```\n\nor to pin the workflow execution to a Worker Deployment:\n\n```\ntemporal workflow update-options \\\n --workflow-id YourWorkflowId \\\n --versioning-override-behavior pinned \\\n --versioning-override-series-name YourDeploymentSeriesName \\\n --versioning-override-build-id YourDeploymentBuildId\n```\n\nTo remove any previous overrides, set the behavior to\nunspecified:\n\n```\ntemporal workflow update-options \\\n --workflow-id YourWorkflowId \\\n --versioning-override-behavior unspecified\n```\n\nTo see the current override use `temporal workflow describe`" + } + s.Command.Args = cobra.NoArgs + s.VersioningOverrideBehavior = NewStringEnum([]string{"unspecified", "pinned", "auto_upgrade"}, "") + s.Command.Flags().Var(&s.VersioningOverrideBehavior, "versioning-override-behavior", "Flag to override the versioning behavior of a Workflow. Accepted values: unspecified, pinned, auto_upgrade. Required.") + _ = cobra.MarkFlagRequired(s.Command.Flags(), "versioning-override-behavior") + s.Command.Flags().StringVar(&s.VersioningOverrideSeriesName, "versioning-override-series-name", "", "Override Series Name for a Worker Deployment (Only for pinned).") + s.Command.Flags().StringVar(&s.VersioningOverrideBuildId, "versioning-override-build-id", "", "Override Build ID for a Worker Deployment (Only for pinned).") + s.SingleWorkflowOrBatchOptions.buildFlags(cctx, s.Command.Flags()) + s.Command.Run = func(c *cobra.Command, args []string) { + if err := s.run(cctx, args); err != nil { + cctx.Options.Fail(err) + } + } + return &s +} diff --git a/temporalcli/commands.workflow.go b/temporalcli/commands.workflow.go index ee1828504..801fe2407 100644 --- a/temporalcli/commands.workflow.go +++ b/temporalcli/commands.workflow.go @@ -92,39 +92,39 @@ func (c *TemporalWorkflowDeleteCommand) run(cctx *CommandContext, args []string) return nil } -func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *CommandContext, args []string) error { - cl, err := c.Parent.Parent.ClientOptions.dialClient(cctx) +func (c *TemporalWorkflowUpdateOptionsCommand) run(cctx *CommandContext, args []string) error { + cl, err := c.Parent.ClientOptions.dialClient(cctx) if err != nil { return err } defer cl.Close() - if c.DeploymentBehavior.Value == "unspecified" || c.DeploymentBehavior.Value == "auto_upgrade" { - if c.DeploymentSeriesName != "" { - return fmt.Errorf("cannot set deployment series name with %v behavior", c.DeploymentBehavior) + if c.VersioningOverrideBehavior.Value == "unspecified" || c.VersioningOverrideBehavior.Value == "auto_upgrade" { + if c.VersioningOverrideSeriesName != "" { + return fmt.Errorf("cannot set deployment series name with %v behavior", c.VersioningOverrideBehavior) } - if c.DeploymentBuildId != "" { - return fmt.Errorf("cannot set deployment build ID with %v behavior", c.DeploymentBehavior) + if c.VersioningOverrideBuildId != "" { + return fmt.Errorf("cannot set deployment build ID with %v behavior", c.VersioningOverrideBehavior) } } - if c.DeploymentBehavior.Value == "pinned" { - if c.DeploymentSeriesName == "" { + if c.VersioningOverrideBehavior.Value == "pinned" { + if c.VersioningOverrideSeriesName == "" { return fmt.Errorf("missing deployment series name with 'pinned' behavior") } - if c.DeploymentBuildId == "" { + if c.VersioningOverrideBuildId == "" { return fmt.Errorf("missing deployment build ID with 'pinned' behavior") } } - exec, batchReq, err := c.Parent.workflowExecOrBatch(cctx, c.Parent.Parent.Namespace, cl, singleOrBatchOverrides{}) + exec, batchReq, err := c.workflowExecOrBatch(cctx, c.Parent.Namespace, cl, singleOrBatchOverrides{}) // Run single or batch if err != nil { return err } else if exec != nil { behavior := workflow.VersioningBehaviorUnspecified - switch c.DeploymentBehavior.Value { + switch c.VersioningOverrideBehavior.Value { case "unspecified": case "pinned": behavior = workflow.VersioningBehaviorPinned @@ -133,7 +133,7 @@ func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *Comma default: return fmt.Errorf( "invalid deployment behavior: %v, valid values are: 'unspecified', 'pinned', and 'auto_upgrade'", - c.DeploymentBehavior, + c.VersioningOverrideBehavior, ) } @@ -144,16 +144,16 @@ func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *Comma VersioningOverride: &client.VersioningOverride{ Behavior: behavior, Deployment: client.Deployment{ - SeriesName: c.DeploymentSeriesName, - BuildID: c.DeploymentBuildId, + SeriesName: c.VersioningOverrideSeriesName, + BuildID: c.VersioningOverrideBuildId, }, }, }, }) if err != nil { - return fmt.Errorf("failed to override workflow versioning options: %w", err) + return fmt.Errorf("failed to update workflow options: %w", err) } - cctx.Printer.Println("Override workflow versioning options succeeded") + cctx.Printer.Println("Update workflow options succeeded") } else { // Run batch var workflowExecutionOptions *workflowpb.WorkflowExecutionOptions protoMask, err := fieldmaskpb.New(workflowExecutionOptions, "versioning_override") @@ -162,7 +162,7 @@ func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *Comma } behavior := enums.VERSIONING_BEHAVIOR_UNSPECIFIED - switch c.DeploymentBehavior.Value { + switch c.VersioningOverrideBehavior.Value { case "unspecified": case "pinned": behavior = enums.VERSIONING_BEHAVIOR_PINNED @@ -171,15 +171,15 @@ func (c *TemporalWorkflowModifyOptionsVersioningOverrideCommand) run(cctx *Comma default: return fmt.Errorf( "invalid deployment behavior: %v, valid values are: 'unspecified', 'pinned', and 'auto_upgrade'", - c.DeploymentBehavior, + c.VersioningOverrideBehavior, ) } deployment := &deploymentpb.Deployment{ - SeriesName: c.DeploymentSeriesName, - BuildId: c.DeploymentBuildId, + SeriesName: c.VersioningOverrideSeriesName, + BuildId: c.VersioningOverrideBuildId, } - if c.DeploymentSeriesName == "" && c.DeploymentBuildId == "" { + if c.VersioningOverrideSeriesName == "" && c.VersioningOverrideBuildId == "" { // auto_upgrade needs a `nil` pointer deployment = nil } diff --git a/temporalcli/commands.workflow_test.go b/temporalcli/commands.workflow_test.go index 6d75e62a6..e9d4d878a 100644 --- a/temporalcli/commands.workflow_test.go +++ b/temporalcli/commands.workflow_test.go @@ -421,7 +421,7 @@ func (s *SharedServerSuite) TestWorkflow_Cancel_SingleWorkflowSuccess() { s.Error(workflow.ErrCanceled, run.Get(s.Context, nil)) } -func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Override() { +func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Override() { buildId1 := uuid.NewString() buildId2 := uuid.NewString() seriesName := uuid.NewString() @@ -444,10 +444,10 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Overrid defer w.Stop() res := s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId1, + "--series-name", seriesName, + "--build-id", buildId1, ) s.NoError(res.Err) @@ -483,12 +483,12 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Overrid s.CommandHarness.Stdin.WriteString("y\n") res = s.Execute( - "workflow", "modify-options", "versioning-override", + "workflow", "update-options", "--address", s.Address(), "--query", "CustomKeywordField = '"+searchAttr+"'", - "--deployment-behavior", "pinned", - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId2, + "--versioning-override-behavior", "pinned", + "--versioning-override-series-name", seriesName, + "--versioning-override-build-id", buildId2, ) s.NoError(res.Err) @@ -512,7 +512,7 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Modify_Options_Versioning_Overrid }, 30*time.Second, 100*time.Millisecond) } -func (s *SharedServerSuite) TestWorkflow_Modify_Options_Versioning_Override() { +func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() { buildId1 := uuid.NewString() buildId2 := uuid.NewString() seriesName := uuid.NewString() @@ -535,10 +535,10 @@ func (s *SharedServerSuite) TestWorkflow_Modify_Options_Versioning_Override() { defer w.Stop() res := s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId1, + "--series-name", seriesName, + "--build-id", buildId1, ) s.NoError(res.Err) @@ -562,12 +562,12 @@ func (s *SharedServerSuite) TestWorkflow_Modify_Options_Versioning_Override() { }, 30*time.Second, 100*time.Millisecond) res = s.Execute( - "workflow", "modify-options", "versioning-override", + "workflow", "update-options", "--address", s.Address(), "-w", run.GetID(), - "--deployment-behavior", "pinned", - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId2, + "--versioning-override-behavior", "pinned", + "--versioning-override-series-name", seriesName, + "--versioning-override-build-id", buildId2, ) s.NoError(res.Err) @@ -584,10 +584,10 @@ func (s *SharedServerSuite) TestWorkflow_Modify_Options_Versioning_Override() { // remove override res = s.Execute( - "workflow", "modify-options", "versioning-override", + "workflow", "update-options", "--address", s.Address(), "-w", run.GetID(), - "--deployment-behavior", "unspecified", + "--versioning-override-behavior", "unspecified", ) s.NoError(res.Err) diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index 58a67e996..479b956ff 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -570,10 +570,10 @@ func (s *SharedServerSuite) TestWorkflow_Describe_Deployment() { defer w.Stop() res := s.Execute( - "deployment", "update-current", + "worker-deployment", "set-current", "--address", s.Address(), - "--deployment-series-name", seriesName, - "--deployment-build-id", buildId, + "--series-name", seriesName, + "--build-id", buildId, ) s.NoError(res.Err) diff --git a/temporalcli/commandsgen/commands.yml b/temporalcli/commandsgen/commands.yml index 07e3dd8e4..0e34d6fe5 100644 --- a/temporalcli/commandsgen/commands.yml +++ b/temporalcli/commandsgen/commands.yml @@ -394,8 +394,8 @@ commands: description: Reason for terminating the batch job. required: true - - name: temporal deployment - summary: Describe, list, and operate on Deployments + - name: temporal worker-deployment + summary: Describe, list, and operate on Worker Deployments description: | +---------------------------------------------------------------------+ | CAUTION: Worker Deployment is experimental. Deployment commands are | @@ -405,49 +405,50 @@ commands: Deployment commands perform operations on Worker Deployments: ``` - temporal deployment [command] [options] + temporal worker-deployment [command] [options] ``` For example: ``` - temporal deployment list + temporal worker-deployment list ``` option-sets: - client docs: description-header: >- Temporal Deployment commands enable operations on Worker Deployments, - such as describe, list, update-current, and get-current, simplifying + such as describe, list, set-current, and get-current, simplifying versioning and management of workers. keywords: - - deployment - - deployment describe - - deployment list - - deployment get-current - - deployment update-current + - worker-deployment + - worker-deployment describe + - worker-deployment list + - worker-deployment get-current + - worker-deployment set-current - - name: temporal deployment describe - summary: Show properties of a Deployment + - name: temporal worker-deployment describe + summary: Show properties of a Worker Deployment description: | +---------------------------------------------------------------------+ | CAUTION: Worker Deployment is experimental. Deployment commands are | | subject to change. | +---------------------------------------------------------------------+ - Describes properties of a Deployment, such as whether it is current, - some custom metadata, or a list of its task queues. + Describes properties of a Worker Deployment, such as whether it is + current, the non-empty list of its task queues, custom metadata if + present, and reachability status when requested. ``` - temporal deployment describe [options] + temporal worker-deployment describe [options] ``` For example, to also include reachability information: ``` - temporal deployment describe \ - --deployment-series-name YourDeploymentSeriesName \ - --deployment-build-id YourDeploymentBuildId \ + temporal worker-deployment describe \ + --series-name YourDeploymentSeriesName \ + --build-id YourDeploymentBuildId \ --report-reachability ``` option-sets: @@ -456,91 +457,92 @@ commands: - name: report-reachability type: bool description: | - Flag to include reachability information of a Deployment. + Flag to include reachability information of a Worker Deployment. - - name: temporal deployment get-current - summary: Show the current Deployment + - name: temporal worker-deployment get-current + summary: Show the current Worker Deployment description: | +---------------------------------------------------------------------+ | CAUTION: Worker Deployment is experimental. Deployment commands are | | subject to change. | +---------------------------------------------------------------------+ - Gets the current Deployment for a Deployment Series Name. Whether a - Deployment is current or not can affect which Workers will execute - Tasks of an existing or new Workflow. - + Gets the current Worker Deployment for a Deployment Series Name. + When a Deployment is current, Workers of that Deployment will receive + tasks from new Workflows and from existing AutoUpgrade Workflows that + are running on this Deployment Series. ``` - temporal deployment get-current [options] + temporal worker-deployment get-current [options] ``` For example: ``` - temporal deployment get-current \ - --deployment-series-name YourDeploymentSeriesName + temporal worker-deployment get-current \ + --series-name YourDeploymentSeriesName ``` options: - - name: deployment-series-name + - name: series-name type: string - description: Series Name for the current Deployment. + description: Series Name for the current Worker Deployment. required: true - - name: temporal deployment list - summary: Enumerate Deployments in the client's namespace + - name: temporal worker-deployment list + summary: Enumerate Worker Deployments in the client's namespace description: | +---------------------------------------------------------------------+ | CAUTION: Worker Deployment is experimental. Deployment commands are | | subject to change. | +---------------------------------------------------------------------+ - List existing Deployments in the client's namespace, optionally + List existing Worker Deployments in the client's namespace, optionally filtering them by Deployment Series Name. ``` - temporal deployment list [options] + temporal worker-deployment list [options] ``` For example, adding an optional filter: ``` - temporal deployment list \ - --deployment-series-name YourDeploymentSeriesName + temporal worker-deployment list \ + --series-name YourDeploymentSeriesName ``` options: - - name: deployment-series-name + - name: series-name type: string - description: Series Name to filter Deployments. + description: Series Name to filter Worker Deployments. - - name: temporal deployment update-current - summary: Change the current Deployment + - name: temporal worker-deployment set-current + summary: Change the current Worker Deployment description: | +---------------------------------------------------------------------+ | CAUTION: Worker deployment is experimental. Deployment commands are | | subject to change. | +---------------------------------------------------------------------+ - Sets the current Deployment for a given Deployment Series. Whether a - Deployment is current or not can affect which Workers will execute - Tasks of an existing or new Workflow. + Sets the current Deployment for a given Deployment Series. + When a Deployment is current, Workers of that Deployment will receive + tasks from new Workflows and from existing AutoUpgrade Workflows that + are running on this Deployment Series. ``` - temporal deployment update-current [options] + temporal worker-deployment set-current [options] ``` For example: ``` - temporal deployment update-current \ - --deployment-series-name YourDeploymentSeriesName \ - --deployment-build-id YourDeploymentBuildId + temporal worker-deployment set-current \ + --series-name YourDeploymentSeriesName \ + --build-id YourDeploymentBuildId ``` option-sets: - deployment-reference options: - - name: deployment-metadata + - name: metadata type: string[] description: | Set deployment metadata using `KEY="VALUE"` pairs. @@ -2653,94 +2655,66 @@ commands: type: int description: Maximum number of Workflow Executions to display. - - name: temporal workflow modify-options + - name: temporal workflow update-options summary: Change Workflow Execution Options description: | Modify properties of Workflow Executions: ``` - temporal workflow modify-options [command] [options] - ``` - - For example, properties that control Worker Versioning: - + temporal workflow update-options [options] ``` - temporal workflow modify-options versioning-override \ - --workflow-id YourWorkflowId \ - --deployment-behavior auto_upgrade - ``` - option-sets: - - single-workflow-or-batch - docs: - description-header: >- - Temporal Workflow Modify Options enables - changes to properties of a Workflow Execution, such as - versioning-override. - keywords: - - workflow - - workflow modify-options - - workflow modify-options versioning-override - - name: temporal workflow modify-options versioning-override - summary: Overrides the Deployment options of a Workflow Execution - description: | - +---------------------------------------------------------------------+ - | CAUTION: Worker versioning is experimental. Versioning commands are | - | subject to change. | - +---------------------------------------------------------------------+ - - Overrides the Deployment configuration of a Workflow Execution, which - controls Worker Versioning. - - ``` - temporal workflow modify-options versioning-override [options] - ``` + It can override the Worker Deployment configuration of a + Workflow Execution, which controls Worker Versioning. For example, to force Workers in the current Deployment execute the next Workflow Task: ``` - temporal workflow modify-options versioning-override \ + temporal workflow update-options \ --workflow-id YourWorkflowId \ - --deployment-behavior auto_upgrade + --versioning-override-behavior auto_upgrade ``` - or to pin the workflow execution to a Deployment: + or to pin the workflow execution to a Worker Deployment: ``` - temporal workflow modify-options versioning-override \ + temporal workflow update-options \ --workflow-id YourWorkflowId \ - --deployment-behavior pinned \ - --deployment-series-name YourDeploymentSeriesName \ - --deployment-build-id YourDeploymentBuildId + --versioning-override-behavior pinned \ + --versioning-override-series-name YourDeploymentSeriesName \ + --versioning-override-build-id YourDeploymentBuildId ``` To remove any previous overrides, set the behavior to unspecified: ``` - temporal workflow modify-options versioning-override \ + temporal workflow update-options \ --workflow-id YourWorkflowId \ - --deployment-behavior unspecified + --versioning-override-behavior unspecified ``` To see the current override use `temporal workflow describe` + + option-sets: + - single-workflow-or-batch options: - - name: deployment-behavior + - name: versioning-override-behavior type: string-enum description: | - Flag to describe the versioning behavior of a Workflow. + Flag to override the versioning behavior of a Workflow. required: true enum-values: - unspecified - pinned - auto_upgrade - - name: deployment-series-name + - name: versioning-override-series-name type: string - description: Series Name for a Deployment (Only for pinned). - - name: deployment-build-id + description: Override Series Name for a Worker Deployment (Only for pinned). + - name: versioning-override-build-id type: string - description: Build ID for a Deployment (Only for pinned). + description: Override Build ID for a Worker Deployment (Only for pinned). - name: temporal workflow query summary: Retrieve Workflow Execution state @@ -3349,13 +3323,13 @@ option-sets: - name: deployment-reference options: - - name: deployment-series-name + - name: series-name type: string - description: Series Name for a Deployment. + description: Series Name for a Worker Deployment. required: true - - name: deployment-build-id + - name: build-id type: string - description: Build ID for a Deployment. + description: Build ID for a Worker Deployment. required: true - name: single-workflow-or-batch From c3faf206fdaa8045e3349615fbdee6701fb5f82a Mon Sep 17 00:00:00 2001 From: Antonio Lain Date: Tue, 14 Jan 2025 20:33:51 -0800 Subject: [PATCH 4/4] Adding top level temporal worker --- go.mod | 2 +- go.sum | 4 +- temporalcli/commands.deployment.go | 8 +-- temporalcli/commands.deployment_test.go | 22 ++++---- temporalcli/commands.gen.go | 50 ++++++++++++------ temporalcli/commands.workflow_test.go | 4 +- temporalcli/commands.workflow_view_test.go | 2 +- temporalcli/commandsgen/commands.yml | 61 ++++++++++++++-------- 8 files changed, 95 insertions(+), 58 deletions(-) diff --git a/go.mod b/go.mod index 304c7d09f..3943adcdb 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/temporalio/ui-server/v2 v2.32.0 go.temporal.io/api v1.43.0 - go.temporal.io/sdk v1.31.1-0.20241212214416-ccb28ef56de8 + go.temporal.io/sdk v1.32.1 go.temporal.io/server v1.26.2 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.35.1 diff --git a/go.sum b/go.sum index a82669f81..37cf426bd 100644 --- a/go.sum +++ b/go.sum @@ -359,8 +359,8 @@ go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeX go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg= go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis= -go.temporal.io/sdk v1.31.1-0.20241212214416-ccb28ef56de8 h1:In+R+QZqd4sm9XUmEPpaTz6xe0n2NTPoEhtgsjOFXUk= -go.temporal.io/sdk v1.31.1-0.20241212214416-ccb28ef56de8/go.mod h1:8U8H7rF9u4Hyb4Ry9yiEls5716DHPNvVITPNkgWUwE8= +go.temporal.io/sdk v1.32.1 h1:slA8prhdFr4lxpsTcRusWVitD/cGjELfKUh0mBj73SU= +go.temporal.io/sdk v1.32.1/go.mod h1:8U8H7rF9u4Hyb4Ry9yiEls5716DHPNvVITPNkgWUwE8= go.temporal.io/server v1.26.2 h1:vDW11lxslYPlGDbQklWi/tqbkVZ2ExtRO1jNjvZmUUI= go.temporal.io/server v1.26.2/go.mod h1:tgY+4z/PuIdqs6ouV1bT90RWSWfEioWkzmrNrLYLUrk= go.temporal.io/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig= diff --git a/temporalcli/commands.deployment.go b/temporalcli/commands.deployment.go index f1bf1c0bc..45a44ec04 100644 --- a/temporalcli/commands.deployment.go +++ b/temporalcli/commands.deployment.go @@ -213,7 +213,7 @@ func printDeploymentSetCurrentResponse(cctx *CommandContext, response client.Dep } func (c *TemporalWorkerDeploymentDescribeCommand) run(cctx *CommandContext, args []string) error { - cl, err := c.Parent.ClientOptions.dialClient(cctx) + cl, err := c.Parent.Parent.ClientOptions.dialClient(cctx) if err != nil { return err } @@ -256,7 +256,7 @@ func (c *TemporalWorkerDeploymentDescribeCommand) run(cctx *CommandContext, args } func (c *TemporalWorkerDeploymentGetCurrentCommand) run(cctx *CommandContext, args []string) error { - cl, err := c.Parent.ClientOptions.dialClient(cctx) + cl, err := c.Parent.Parent.ClientOptions.dialClient(cctx) if err != nil { return err } @@ -278,7 +278,7 @@ func (c *TemporalWorkerDeploymentGetCurrentCommand) run(cctx *CommandContext, ar } func (c *TemporalWorkerDeploymentListCommand) run(cctx *CommandContext, args []string) error { - cl, err := c.Parent.dialClient(cctx) + cl, err := c.Parent.Parent.dialClient(cctx) if err != nil { return err } @@ -343,7 +343,7 @@ func (c *TemporalWorkerDeploymentListCommand) run(cctx *CommandContext, args []s } func (c *TemporalWorkerDeploymentSetCurrentCommand) run(cctx *CommandContext, args []string) error { - cl, err := c.Parent.dialClient(cctx) + cl, err := c.Parent.Parent.dialClient(cctx) if err != nil { return err } diff --git a/temporalcli/commands.deployment_test.go b/temporalcli/commands.deployment_test.go index db200b501..87dba9902 100644 --- a/temporalcli/commands.deployment_test.go +++ b/temporalcli/commands.deployment_test.go @@ -46,7 +46,7 @@ func (s *SharedServerSuite) TestDeployment_Set_Current() { buildId := uuid.NewString() res := s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId, @@ -55,7 +55,7 @@ func (s *SharedServerSuite) TestDeployment_Set_Current() { s.NoError(res.Err) res = s.Execute( - "worker-deployment", "get-current", + "worker", "deployment", "get-current", "--address", s.Address(), "--series-name", seriesName, ) @@ -68,7 +68,7 @@ func (s *SharedServerSuite) TestDeployment_Set_Current() { // json res = s.Execute( - "worker-deployment", "get-current", + "worker", "deployment", "get-current", "--address", s.Address(), "--series-name", seriesName, "--output", "json", @@ -91,7 +91,7 @@ func (s *SharedServerSuite) TestDeployment_List() { buildId2 := uuid.NewString() res := s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId1, @@ -99,7 +99,7 @@ func (s *SharedServerSuite) TestDeployment_List() { s.NoError(res.Err) res = s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId2, @@ -107,7 +107,7 @@ func (s *SharedServerSuite) TestDeployment_List() { s.NoError(res.Err) res = s.Execute( - "worker-deployment", "list", + "worker", "deployment", "list", "--address", s.Address(), "--series-name", seriesName, ) @@ -118,7 +118,7 @@ func (s *SharedServerSuite) TestDeployment_List() { // json res = s.Execute( - "worker-deployment", "list", + "worker", "deployment", "list", "--address", s.Address(), "--series-name", seriesName, "--output", "json", @@ -143,7 +143,7 @@ func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { buildId2 := uuid.NewString() res := s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId1, @@ -151,7 +151,7 @@ func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { s.NoError(res.Err) res = s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId2, @@ -159,7 +159,7 @@ func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { s.NoError(res.Err) res = s.Execute( - "worker-deployment", "describe", + "worker", "deployment", "describe", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId1, @@ -174,7 +174,7 @@ func (s *SharedServerSuite) TestDeployment_Describe_Reachability() { // json res = s.Execute( - "worker-deployment", "describe", + "worker", "deployment", "describe", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId2, diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index 27eb3caf1..a97c12e72 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -308,7 +308,7 @@ func NewTemporalCommand(cctx *CommandContext) *TemporalCommand { s.Command.AddCommand(&NewTemporalScheduleCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalServerCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalTaskQueueCommand(cctx, &s).Command) - s.Command.AddCommand(&NewTemporalWorkerDeploymentCommand(cctx, &s).Command) + s.Command.AddCommand(&NewTemporalWorkerCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkflowCommand(cctx, &s).Command) s.Command.PersistentFlags().StringVar(&s.Env, "env", "default", "Active environment name (`ENV`).") cctx.BindFlagEnvVar(s.Command.PersistentFlags().Lookup("env"), "TEMPORAL_ENV") @@ -2339,28 +2339,48 @@ func NewTemporalTaskQueueVersioningReplaceRedirectRuleCommand(cctx *CommandConte return &s } -type TemporalWorkerDeploymentCommand struct { +type TemporalWorkerCommand struct { Parent *TemporalCommand Command cobra.Command ClientOptions } -func NewTemporalWorkerDeploymentCommand(cctx *CommandContext, parent *TemporalCommand) *TemporalWorkerDeploymentCommand { +func NewTemporalWorkerCommand(cctx *CommandContext, parent *TemporalCommand) *TemporalWorkerCommand { + var s TemporalWorkerCommand + s.Parent = parent + s.Command.Use = "worker" + s.Command.Short = "Read or update Worker state" + if hasHighlighting { + s.Command.Long = "Modify or read state associated with a Worker, for example,\nusing Worker Deployments commands:\n\n\x1b[1mtemporal worker deployment\x1b[0m" + } else { + s.Command.Long = "Modify or read state associated with a Worker, for example,\nusing Worker Deployments commands:\n\n```\ntemporal worker deployment\n```" + } + s.Command.Args = cobra.NoArgs + s.Command.AddCommand(&NewTemporalWorkerDeploymentCommand(cctx, &s).Command) + s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags()) + return &s +} + +type TemporalWorkerDeploymentCommand struct { + Parent *TemporalWorkerCommand + Command cobra.Command +} + +func NewTemporalWorkerDeploymentCommand(cctx *CommandContext, parent *TemporalWorkerCommand) *TemporalWorkerDeploymentCommand { var s TemporalWorkerDeploymentCommand s.Parent = parent - s.Command.Use = "worker-deployment" + s.Command.Use = "deployment" s.Command.Short = "Describe, list, and operate on Worker Deployments" if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n\x1b[1mtemporal worker-deployment [command] [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker-deployment list\x1b[0m" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n\x1b[1mtemporal worker deployment [command] [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker deployment list\x1b[0m" } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n```\ntemporal worker-deployment [command] [options]\n```\n\nFor example:\n\n```\ntemporal worker-deployment list\n```" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDeployment commands perform operations on Worker Deployments:\n\n```\ntemporal worker deployment [command] [options]\n```\n\nFor example:\n\n```\ntemporal worker deployment list\n```" } s.Command.Args = cobra.NoArgs s.Command.AddCommand(&NewTemporalWorkerDeploymentDescribeCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkerDeploymentGetCurrentCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkerDeploymentListCommand(cctx, &s).Command) s.Command.AddCommand(&NewTemporalWorkerDeploymentSetCurrentCommand(cctx, &s).Command) - s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags()) return &s } @@ -2378,9 +2398,9 @@ func NewTemporalWorkerDeploymentDescribeCommand(cctx *CommandContext, parent *Te s.Command.Use = "describe [flags]" s.Command.Short = "Show properties of a Worker Deployment" if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Worker Deployment, such as whether it is\ncurrent, the non-empty list of its task queues, custom metadata if\npresent, and reachability status when requested.\n\n\x1b[1mtemporal worker-deployment describe [options]\x1b[0m\n\nFor example, to also include reachability information:\n\n\x1b[1mtemporal worker-deployment describe \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId \\\n --report-reachability\x1b[0m" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Worker Deployment, such as whether it is\ncurrent, the non-empty list of its task queues, custom metadata if\npresent, and reachability status when requested.\n\n\x1b[1mtemporal worker deployment describe [options]\x1b[0m\n\nFor example, to also include reachability information:\n\n\x1b[1mtemporal worker deployment describe \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId \\\n --report-reachability\x1b[0m" } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Worker Deployment, such as whether it is\ncurrent, the non-empty list of its task queues, custom metadata if\npresent, and reachability status when requested.\n\n```\ntemporal worker-deployment describe [options]\n```\n\nFor example, to also include reachability information:\n\n```\ntemporal worker-deployment describe \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId \\\n --report-reachability\n```" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nDescribes properties of a Worker Deployment, such as whether it is\ncurrent, the non-empty list of its task queues, custom metadata if\npresent, and reachability status when requested.\n\n```\ntemporal worker deployment describe [options]\n```\n\nFor example, to also include reachability information:\n\n```\ntemporal worker deployment describe \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId \\\n --report-reachability\n```" } s.Command.Args = cobra.NoArgs s.Command.Flags().BoolVar(&s.ReportReachability, "report-reachability", false, "Flag to include reachability information of a Worker Deployment.") @@ -2406,9 +2426,9 @@ func NewTemporalWorkerDeploymentGetCurrentCommand(cctx *CommandContext, parent * s.Command.Use = "get-current [flags]" s.Command.Short = "Show the current Worker Deployment" if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Worker Deployment for a Deployment Series Name.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n\x1b[1mtemporal worker-deployment get-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker-deployment get-current \\\n --series-name YourDeploymentSeriesName\x1b[0m" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Worker Deployment for a Deployment Series Name.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n\x1b[1mtemporal worker deployment get-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker deployment get-current \\\n --series-name YourDeploymentSeriesName\x1b[0m" } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Worker Deployment for a Deployment Series Name.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n```\ntemporal worker-deployment get-current [options]\n```\n\nFor example:\n\n```\ntemporal worker-deployment get-current \\\n --series-name YourDeploymentSeriesName\n```" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nGets the current Worker Deployment for a Deployment Series Name.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n```\ntemporal worker deployment get-current [options]\n```\n\nFor example:\n\n```\ntemporal worker deployment get-current \\\n --series-name YourDeploymentSeriesName\n```" } s.Command.Args = cobra.NoArgs s.Command.Flags().StringVar(&s.SeriesName, "series-name", "", "Series Name for the current Worker Deployment. Required.") @@ -2434,9 +2454,9 @@ func NewTemporalWorkerDeploymentListCommand(cctx *CommandContext, parent *Tempor s.Command.Use = "list [flags]" s.Command.Short = "Enumerate Worker Deployments in the client's namespace" if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Worker Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n\x1b[1mtemporal worker-deployment list [options]\x1b[0m\n\nFor example, adding an optional filter:\n\n\x1b[1mtemporal worker-deployment list \\\n --series-name YourDeploymentSeriesName\x1b[0m" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Worker Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n\x1b[1mtemporal worker deployment list [options]\x1b[0m\n\nFor example, adding an optional filter:\n\n\x1b[1mtemporal worker deployment list \\\n --series-name YourDeploymentSeriesName\x1b[0m" } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Worker Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n```\ntemporal worker-deployment list [options]\n```\n\nFor example, adding an optional filter:\n\n```\ntemporal worker-deployment list \\\n --series-name YourDeploymentSeriesName\n```" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker Deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nList existing Worker Deployments in the client's namespace, optionally\nfiltering them by Deployment Series Name.\n\n\n```\ntemporal worker deployment list [options]\n```\n\nFor example, adding an optional filter:\n\n```\ntemporal worker deployment list \\\n --series-name YourDeploymentSeriesName\n```" } s.Command.Args = cobra.NoArgs s.Command.Flags().StringVar(&s.SeriesName, "series-name", "", "Series Name to filter Worker Deployments.") @@ -2462,9 +2482,9 @@ func NewTemporalWorkerDeploymentSetCurrentCommand(cctx *CommandContext, parent * s.Command.Use = "set-current [flags]" s.Command.Short = "Change the current Worker Deployment" if hasHighlighting { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n\x1b[1mtemporal worker-deployment set-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker-deployment set-current \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId\x1b[0m" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n\x1b[1mtemporal worker deployment set-current [options]\x1b[0m\n\nFor example:\n\n\x1b[1mtemporal worker deployment set-current \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId\x1b[0m" } else { - s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n```\ntemporal worker-deployment set-current [options]\n```\n\nFor example:\n\n```\ntemporal worker-deployment set-current \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId\n```" + s.Command.Long = "+---------------------------------------------------------------------+\n| CAUTION: Worker deployment is experimental. Deployment commands are |\n| subject to change. |\n+---------------------------------------------------------------------+\n\nSets the current Deployment for a given Deployment Series.\nWhen a Deployment is current, Workers of that Deployment will receive\ntasks from new Workflows and from existing AutoUpgrade Workflows that\nare running on this Deployment Series.\n\n```\ntemporal worker deployment set-current [options]\n```\n\nFor example:\n\n```\ntemporal worker deployment set-current \\\n --series-name YourDeploymentSeriesName \\\n --build-id YourDeploymentBuildId\n```" } s.Command.Args = cobra.NoArgs s.Command.Flags().StringArrayVar(&s.Metadata, "metadata", nil, "Set deployment metadata using `KEY=\"VALUE\"` pairs. Keys must be identifiers, and values must be JSON values. For example: 'YourKey={\"your\": \"value\"}'. Can be passed multiple times.") diff --git a/temporalcli/commands.workflow_test.go b/temporalcli/commands.workflow_test.go index e9d4d878a..af873bb71 100644 --- a/temporalcli/commands.workflow_test.go +++ b/temporalcli/commands.workflow_test.go @@ -444,7 +444,7 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Overrid defer w.Stop() res := s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId1, @@ -535,7 +535,7 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() { defer w.Stop() res := s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId1, diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index 479b956ff..b1397b300 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -570,7 +570,7 @@ func (s *SharedServerSuite) TestWorkflow_Describe_Deployment() { defer w.Stop() res := s.Execute( - "worker-deployment", "set-current", + "worker", "deployment", "set-current", "--address", s.Address(), "--series-name", seriesName, "--build-id", buildId, diff --git a/temporalcli/commandsgen/commands.yml b/temporalcli/commandsgen/commands.yml index 0e34d6fe5..afc556050 100644 --- a/temporalcli/commandsgen/commands.yml +++ b/temporalcli/commandsgen/commands.yml @@ -394,7 +394,26 @@ commands: description: Reason for terminating the batch job. required: true - - name: temporal worker-deployment + - name: temporal worker + summary: Read or update Worker state + description: | + Modify or read state associated with a Worker, for example, + using Worker Deployments commands: + + ``` + temporal worker deployment + ``` + option-sets: + - client + docs: + description-header: >- + Learn how to read or modify state associated with a Worker, + such as Worker Deployments. + keywords: + - worker + - worker deployment + + - name: temporal worker deployment summary: Describe, list, and operate on Worker Deployments description: | +---------------------------------------------------------------------+ @@ -405,29 +424,27 @@ commands: Deployment commands perform operations on Worker Deployments: ``` - temporal worker-deployment [command] [options] + temporal worker deployment [command] [options] ``` For example: ``` - temporal worker-deployment list + temporal worker deployment list ``` - option-sets: - - client docs: description-header: >- Temporal Deployment commands enable operations on Worker Deployments, such as describe, list, set-current, and get-current, simplifying versioning and management of workers. keywords: - - worker-deployment - - worker-deployment describe - - worker-deployment list - - worker-deployment get-current - - worker-deployment set-current + - worker deployment + - worker deployment describe + - worker deployment list + - worker deployment get-current + - worker deployment set-current - - name: temporal worker-deployment describe + - name: temporal worker deployment describe summary: Show properties of a Worker Deployment description: | +---------------------------------------------------------------------+ @@ -440,13 +457,13 @@ commands: present, and reachability status when requested. ``` - temporal worker-deployment describe [options] + temporal worker deployment describe [options] ``` For example, to also include reachability information: ``` - temporal worker-deployment describe \ + temporal worker deployment describe \ --series-name YourDeploymentSeriesName \ --build-id YourDeploymentBuildId \ --report-reachability @@ -459,7 +476,7 @@ commands: description: | Flag to include reachability information of a Worker Deployment. - - name: temporal worker-deployment get-current + - name: temporal worker deployment get-current summary: Show the current Worker Deployment description: | +---------------------------------------------------------------------+ @@ -473,13 +490,13 @@ commands: are running on this Deployment Series. ``` - temporal worker-deployment get-current [options] + temporal worker deployment get-current [options] ``` For example: ``` - temporal worker-deployment get-current \ + temporal worker deployment get-current \ --series-name YourDeploymentSeriesName ``` options: @@ -488,7 +505,7 @@ commands: description: Series Name for the current Worker Deployment. required: true - - name: temporal worker-deployment list + - name: temporal worker deployment list summary: Enumerate Worker Deployments in the client's namespace description: | +---------------------------------------------------------------------+ @@ -501,13 +518,13 @@ commands: ``` - temporal worker-deployment list [options] + temporal worker deployment list [options] ``` For example, adding an optional filter: ``` - temporal worker-deployment list \ + temporal worker deployment list \ --series-name YourDeploymentSeriesName ``` options: @@ -515,7 +532,7 @@ commands: type: string description: Series Name to filter Worker Deployments. - - name: temporal worker-deployment set-current + - name: temporal worker deployment set-current summary: Change the current Worker Deployment description: | +---------------------------------------------------------------------+ @@ -529,13 +546,13 @@ commands: are running on this Deployment Series. ``` - temporal worker-deployment set-current [options] + temporal worker deployment set-current [options] ``` For example: ``` - temporal worker-deployment set-current \ + temporal worker deployment set-current \ --series-name YourDeploymentSeriesName \ --build-id YourDeploymentBuildId ```