diff --git a/cliext/client.go b/cliext/client.go index 8512f34ba..48eaa7508 100644 --- a/cliext/client.go +++ b/cliext/client.go @@ -132,6 +132,11 @@ func (b *ClientOptionsBuilder) Build(ctx context.Context) (client.Options, error profile.APIKey = cfg.ApiKey } + // Set client authority on profile if provided + if cfg.ClientAuthority != "" { + profile.Authority = cfg.ClientAuthority + } + // Handle gRPC metadata from flags. if len(cfg.GrpcMeta) > 0 { grpcMetaFromArg, err := parseKeyValuePairs(cfg.GrpcMeta) diff --git a/cliext/config.oauth.go b/cliext/config.oauth.go index 9593bdde0..d98b9011a 100644 --- a/cliext/config.oauth.go +++ b/cliext/config.oauth.go @@ -141,11 +141,7 @@ func resolveConfigAndProfile(configFilePath, profileName string, envLookup envco configFilePath, _ = envLookup.LookupEnv("TEMPORAL_CONFIG_FILE") } if configFilePath == "" { - var err error - configFilePath, err = envconfig.DefaultConfigFilePath() - if err != nil { - return "", "", fmt.Errorf("failed to get default config path: %w", err) - } + configFilePath = envconfig.DefaultConfigFilePath() } // Resolve profile name. diff --git a/go.mod b/go.mod index 6921fd3ca..90fe02df5 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/temporalio/ui-server/v2 v2.49.1 go.temporal.io/api v1.62.13 go.temporal.io/sdk v1.44.1 - go.temporal.io/sdk/contrib/envconfig v1.0.0 + go.temporal.io/sdk/contrib/envconfig v1.0.2 go.temporal.io/server v1.32.0-157.0 golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f golang.org/x/mod v0.35.0 diff --git a/go.sum b/go.sum index 31903bc40..01c1676b9 100644 --- a/go.sum +++ b/go.sum @@ -475,8 +475,8 @@ go.temporal.io/auto-scaled-workers v0.0.0-20260407181057-edd947d743d2 h1:1hKeH3G go.temporal.io/auto-scaled-workers v0.0.0-20260407181057-edd947d743d2/go.mod h1:T8dnzVPeO+gaUTj9eDgm/lT2lZH4+JXNvrGaQGyVi50= go.temporal.io/sdk v1.44.1 h1:Mt2OZLZpqkzDIdg9YyQzO0Rb/HqCDnnqHlIAGAJ5gqM= go.temporal.io/sdk v1.44.1/go.mod h1:vkApR12F9/Y8OR+hkxe7WyXQFuCX6clhzqnAk6rzDAM= -go.temporal.io/sdk/contrib/envconfig v1.0.0 h1:1Q/swVgB4EW/p3k7rI9/4hpU4/DC57FSRbU90+UisXw= -go.temporal.io/sdk/contrib/envconfig v1.0.0/go.mod h1:Pj4N1lwUEvxap6quBm8GrVMSUMJhSZkVtxjt3AYnPPg= +go.temporal.io/sdk/contrib/envconfig v1.0.2 h1:MGHfsuPUtsf7X9M6WYn3zYJj/mWsuYHnA1uuiL0KEuE= +go.temporal.io/sdk/contrib/envconfig v1.0.2/go.mod h1:MuMiH7hksps2uXnmKuAWaP9P6WbkSDy62kl64t1VJVg= go.temporal.io/server v1.32.0-157.0 h1:nzFqNwx+5lXsT0/DSiFyR5vHMnDcT3PVAvmRDqCUn38= go.temporal.io/server v1.32.0-157.0/go.mod h1:a76wf30/s28JXh+3nDQtQi8KzOfRQEddpebvmr/oQL4= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= diff --git a/internal/temporalcli/commands.config.go b/internal/temporalcli/commands.config.go index e8a423dd0..aeba4760a 100644 --- a/internal/temporalcli/commands.config.go +++ b/internal/temporalcli/commands.config.go @@ -253,6 +253,7 @@ var envConfigPropsToFieldNames = map[string]string{ "address": "Address", "namespace": "Namespace", "api_key": "APIKey", + "authority": "Authority", "tls": "TLS", "tls.disabled": "Disabled", "tls.client_cert_path": "ClientCertPath", @@ -311,10 +312,8 @@ func writeEnvConfigFile(cctx *CommandContext, conf *envconfig.ClientConfig) erro if configFile == "" { configFile, _ = cctx.Options.EnvLookup.LookupEnv("TEMPORAL_CONFIG_FILE") if configFile == "" { - var err error - if configFile, err = envconfig.DefaultConfigFilePath(); err != nil { - return err - } + configFile = envconfig.DefaultConfigFilePath() + } } diff --git a/internal/temporalcli/commands.config_test.go b/internal/temporalcli/commands.config_test.go index 5cc89ec86..f6a08571d 100644 --- a/internal/temporalcli/commands.config_test.go +++ b/internal/temporalcli/commands.config_test.go @@ -25,6 +25,7 @@ func TestConfig_Get(t *testing.T) { address = "my-address" namespace = "my-namespace" api_key = "my-api-key" +authority = "my-authority" codec = { endpoint = "my-endpoint", auth = "my-auth" } grpc_meta = { some-heAder1 = "some-value1", some-header2 = "some-value2", some_heaDer3 = "some-value3" } some_future_key = "some future value not handled" @@ -74,6 +75,7 @@ disable_host_verification = true`)) "address": "my-address", "namespace": "my-namespace", "api_key": "my-api-key", + "authority": "my-authority", "codec.endpoint": "my-endpoint", "codec.auth": "my-auth", "grpc_meta.some-header1": "some-value1", @@ -117,6 +119,7 @@ disable_host_verification = true`)) h.JSONEq(`{ "address": "my-address", "api_key": "my-api-key", + "authority": "my-authority", "codec": { "auth": "my-auth", "endpoint": "my-endpoint" diff --git a/internal/temporalcli/commands.schedule.go b/internal/temporalcli/commands.schedule.go index 3a18271bd..865778981 100644 --- a/internal/temporalcli/commands.schedule.go +++ b/internal/temporalcli/commands.schedule.go @@ -1,6 +1,7 @@ package temporalcli import ( + "encoding/json" "errors" "fmt" "regexp" @@ -16,6 +17,7 @@ import ( commonpb "go.temporal.io/api/common/v1" enumspb "go.temporal.io/api/enums/v1" schedpb "go.temporal.io/api/schedule/v1" + "go.temporal.io/api/temporalproto" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" ) @@ -48,8 +50,8 @@ type printableSchedule struct { LastUpdateAt time.Time `cli:",cardOmitEmpty"` // describe only ActionCounts *actionCounts `cli:",cardOmitEmpty"` // describe only // SearchAttributes, Memo - SearchAttributes *commonpb.SearchAttributes `cli:",cardOmitEmpty"` - Memo *commonpb.Memo `cli:",cardOmitEmpty"` + SearchAttributes map[string]interface{} `cli:",cardOmitEmpty"` + Memo *commonpb.Memo `cli:",cardOmitEmpty"` } type actionCounts struct { @@ -69,7 +71,7 @@ func describeResultToPrintable(id string, desc *client.ScheduleDescription) *pri // ID, SearchAttributes, Memo out := &printableSchedule{ ScheduleId: id, - SearchAttributes: desc.SearchAttributes, + SearchAttributes: searchAttributesToMap(desc.SearchAttributes), Memo: desc.Memo, } // Schedule.Action @@ -114,7 +116,7 @@ func listEntryToPrintable(ent *client.ScheduleListEntry) *printableSchedule { Paused: ent.Paused, Notes: ent.Note, Action: struct{ Workflow string }{Workflow: ent.WorkflowType.Name}, - SearchAttributes: ent.SearchAttributes, + SearchAttributes: searchAttributesToMap(ent.SearchAttributes), Memo: ent.Memo, } specToPrintable(out, ent.Spec) @@ -640,3 +642,21 @@ func (c *TemporalScheduleListMatchingTimesCommand) run(cctx *CommandContext, arg Table: &printer.TableOptions{}, }) } + +func searchAttributesToMap(sa *commonpb.SearchAttributes) map[string]interface{} { + // Step 1 — handle nil + if sa == nil { + return nil + } + // Step 2 — marshal to JSON bytes using proto marshaler + b, err := temporalproto.CustomJSONMarshalOptions{}.Marshal(sa) + if err != nil { + return nil + } + // Step 3 — unmarshal bytes into plain map + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil + } + return m +}