Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ require (
github.com/stretchr/testify v1.11.1
github.com/temporalio/cli/cliext v0.0.0
github.com/temporalio/ui-server/v2 v2.52.0
go.temporal.io/api v1.63.0
go.temporal.io/api v1.63.4
go.temporal.io/sdk v1.45.0
go.temporal.io/sdk/contrib/envconfig v1.0.2
go.temporal.io/server v1.32.0-158.0
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f
golang.org/x/mod v0.35.0
golang.org/x/term v0.43.0
golang.org/x/tools v0.44.0
go.temporal.io/server v1.32.0-160.0
golang.org/x/exp v0.0.0-20260611194520-c48552f49976
golang.org/x/mod v0.37.0
golang.org/x/term v0.45.0
golang.org/x/tools v0.47.0
google.golang.org/grpc v1.81.1
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -78,6 +78,7 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c // indirect
github.com/cactus/go-statsd-client/v5 v5.1.0 // indirect
github.com/caio/go-tdigest/v5 v5.0.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
Expand Down Expand Up @@ -129,7 +130,7 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.9.2 // indirect
github.com/jackc/pgx/v5 v5.10.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -169,7 +170,7 @@ require (
github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/temporalio/ringpop-go v0.0.0-20250130211428-b97329e994f7 // indirect
github.com/temporalio/sqlparser v0.0.0-20231115171017-f4060bcfa6cb // indirect
github.com/temporalio/sqlparser v0.0.0-20260722001706-17d16cfe1da5 // indirect
github.com/temporalio/tchannel-go v1.22.1-0.20260129151045-8706a1ab5f61 // indirect
github.com/tidwall/btree v1.8.1 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
Expand All @@ -182,17 +183,18 @@ require (
go.opentelemetry.io/contrib/detectors/gcp v1.43.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.68.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.43.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.43.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.57.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/log v0.20.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.temporal.io/auto-scaled-workers v0.0.0-20260622220320-9b1e3849116d // indirect
go.temporal.io/auto-scaled-workers v0.0.0-20260706201056-4320b34799ee // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/dig v1.19.0 // indirect
go.uber.org/fx v1.24.0 // indirect
Expand All @@ -201,12 +203,12 @@ require (
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/crypto v0.54.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/api v0.276.0 // indirect
google.golang.org/genproto v0.0.0-20260420184626-e10c466a9529 // indirect
Expand Down
74 changes: 40 additions & 34 deletions go.sum

Large diffs are not rendered by default.

31 changes: 3 additions & 28 deletions internal/temporalcli/commands.activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,35 +448,10 @@ func printActivityDescription(cctx *CommandContext, resp *workflowservice.Descri
if err := cctx.Printer.PrintStructured(d, printer.StructuredOptions{}); err != nil {
return err
}
return printActivityCallbacks(cctx, resp.GetCallbacks())
}

func printActivityCallbacks(cctx *CommandContext, callbacks []*activitypb.CallbackInfo) error {
if len(callbacks) == 0 {
return nil
if err := printLinks(cctx, info.GetLinks()); err != nil {
return err
}
rows := make([]struct {
State string
Attempt int32
RegistrationTime time.Time `cli:",cardOmitEmpty"`
NextAttemptScheduleTime time.Time `cli:",cardOmitEmpty"`
BlockedReason string `cli:",cardOmitEmpty"`
LastAttemptFailure string `cli:",cardOmitEmpty"`
}, len(callbacks))
for i, cb := range callbacks {
info := cb.GetInfo()
rows[i].State = info.GetState().String()
rows[i].Attempt = info.GetAttempt()
rows[i].RegistrationTime = timestampToTime(info.GetRegistrationTime())
rows[i].NextAttemptScheduleTime = timestampToTime(info.GetNextAttemptScheduleTime())
rows[i].BlockedReason = info.GetBlockedReason()
if f := info.GetLastAttemptFailure(); f != nil {
rows[i].LastAttemptFailure = cctx.MarshalFriendlyFailureBodyText(f, " ")
}
}
cctx.Printer.Println()
cctx.Printer.Println(color.MagentaString("Callbacks:"))
return cctx.Printer.PrintStructured(rows, printer.StructuredOptions{Table: &printer.TableOptions{}})
return printCallbacks(cctx, resp.GetCallbacks())
}

func (c *TemporalActivityListCommand) run(cctx *CommandContext, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/temporalcli/commands.batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *SharedServerSuite) TestBatchJob_Describe() {
var jsonOut map[string]any
s.NoError(json.Unmarshal(res.Stdout.Bytes(), &jsonOut))
s.Equal(jobId, jsonOut["jobId"])
s.Equal("BATCH_OPERATION_TYPE_TERMINATE", jsonOut["operationType"])
s.Equal("BATCH_OPERATION_TYPE_TERMINATE_WORKFLOW", jsonOut["operationType"])
s.Equal("REASON", jsonOut["reason"])
})
})
Expand Down
116 changes: 116 additions & 0 deletions internal/temporalcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ import (
"github.com/temporalio/cli/cliext"
"github.com/temporalio/cli/internal/printer"
"github.com/temporalio/ui-server/v2/server/version"
activitypb "go.temporal.io/api/activity/v1"
"go.temporal.io/api/common/v1"
commonpb "go.temporal.io/api/common/v1"
"go.temporal.io/api/enums/v1"
"go.temporal.io/api/failure/v1"
"go.temporal.io/api/temporalnexus"
"go.temporal.io/api/temporalproto"
workflowpb "go.temporal.io/api/workflow/v1"
"go.temporal.io/sdk/contrib/envconfig"
"go.temporal.io/sdk/converter"
"go.temporal.io/sdk/temporal"
Expand Down Expand Up @@ -606,6 +610,118 @@ func timestampToTime(t *timestamppb.Timestamp) time.Time {
return t.AsTime()
}

// nexusLinkStrings converts Temporal common links into their Nexus link URL
// string representations, skipping any link variant that has no Nexus
// equivalent. The conversion helpers live in go.temporal.io/api/temporalnexus
// (previously in the Go SDK's temporalnexus package).
func nexusLinkStrings(links []*commonpb.Link) []string {
var out []string
for _, link := range links {
if nexusLink, ok := temporalnexus.CommonLinkToNexusLink(link); ok {
out = append(out, nexusLink.GetUrl())
}
}
return out
}

// printLinks renders Temporal common links as a standalone Nexus links section.
// Nothing is printed when none of the links have a Nexus representation.
func printLinks(cctx *CommandContext, links []*commonpb.Link) error {
urls := nexusLinkStrings(links)
if len(urls) == 0 {
return nil
}
rows := make([]struct {
Link string
}, len(urls))
for i, url := range urls {
rows[i].Link = url
}
cctx.Printer.Println()
cctx.Printer.Println(color.MagentaString("Links: %v", len(urls)))
cctx.Printer.Println()
return cctx.Printer.PrintStructured(rows, printer.StructuredOptions{})
}

// callbackInfoForPrint is the subset of accessors shared by workflow.v1.CallbackInfo
// and callback.v1.CallbackInfo (the latter nested inside activity.v1.CallbackInfo).
// It lets the workflow and activity describe commands render callbacks through a
// single code path (printCallbacks).
type callbackInfoForPrint interface {
GetCallback() *commonpb.Callback
GetState() enums.CallbackState
GetAttempt() int32
GetRegistrationTime() *timestamppb.Timestamp
GetNextAttemptScheduleTime() *timestamppb.Timestamp
GetLastAttemptCompleteTime() *timestamppb.Timestamp
GetLastAttemptFailure() *failure.Failure
GetBlockedReason() string
}

type callbackForPrint interface {
*workflowpb.CallbackInfo | *activitypb.CallbackInfo
}

func normalizeCallbackForPrint[T callbackForPrint](cb T) (callbackInfoForPrint, string) {
switch cb := any(cb).(type) {
case *workflowpb.CallbackInfo:
trigger := "Unknown"
if cb.GetTrigger().GetWorkflowClosed() != nil {
trigger = "WorkflowClosed"
}
return cb, trigger
case *activitypb.CallbackInfo:
trigger := "Unknown"
if cb.GetTrigger().GetActivityClosed() != nil {
trigger = "ActivityClosed"
}
return cb.GetInfo(), trigger
default:
panic("unsupported callback type")
}
}

// printCallbacks renders the "Callbacks: N" section shared by the workflow and
// activity describe commands. Nothing is printed when there are no callbacks.
// This is only reached for text output; JSON output prints the raw describe
// response instead.
func printCallbacks[T callbackForPrint](cctx *CommandContext, callbacks []T) error {
if len(callbacks) == 0 {
return nil
}
rows := make([]struct {
URL string
Links []string `cli:",cardOmitEmpty"`
Trigger string
State enums.CallbackState
Attempt int32
RegistrationTime time.Time `cli:",cardOmitEmpty"`
NextAttemptScheduleTime time.Time `cli:",cardOmitEmpty"`
LastAttemptCompleteTime time.Time `cli:",cardOmitEmpty"`
BlockedReason string `cli:",cardOmitEmpty"`
LastAttemptFailure string `cli:",cardOmitEmpty"`
}, len(callbacks))
for i, cb := range callbacks {
ci, trigger := normalizeCallbackForPrint(cb)
rows[i].URL = ci.GetCallback().GetNexus().GetUrl()
rows[i].Links = nexusLinkStrings(ci.GetCallback().GetLinks())
rows[i].Trigger = trigger
rows[i].State = ci.GetState()
rows[i].Attempt = ci.GetAttempt()
rows[i].RegistrationTime = timestampToTime(ci.GetRegistrationTime())
rows[i].NextAttemptScheduleTime = timestampToTime(ci.GetNextAttemptScheduleTime())
rows[i].LastAttemptCompleteTime = timestampToTime(ci.GetLastAttemptCompleteTime())
rows[i].BlockedReason = ci.GetBlockedReason()
if f := ci.GetLastAttemptFailure(); f != nil {
rows[i].LastAttemptFailure = cctx.MarshalFriendlyFailureBodyText(f, " ")
}
}
cctx.Printer.Println()
cctx.Printer.Println(color.MagentaString("Callbacks: %v", len(callbacks)))
cctx.Printer.Println()
return cctx.Printer.PrintStructured(rows, printer.StructuredOptions{})
}

type nopWriter struct{}

func (nopWriter) Write(b []byte) (int, error) { return len(b), nil }
Expand Down
Loading