tctx
tctx
makes it fast and easy to switch between Temporal clusters when running tctl
commands.
Installation
Build from source using go install:
go install github.com/jlegrone/tctx@latest
Usage
Add a context
$ tctx add -c localhost --namespace default --address localhost:7233
Context "localhost" modified.
Active namespace is "default".
tctl
command
Execute a $ tctx exec -- tctl cluster health
temporal.api.workflowservice.v1.WorkflowService: SERVING
List contexts
$ tctx list
NAME ADDRESS NAMESPACE STATUS
localhost localhost:7233 default active
production temporal-production.example.com:443 myapp
staging temporal-staging.example.com:443 myapp
Switch contexts
$ tctx use -c production
Context "production" modified.
Active namespace is "myapp".
Tips
How it works
tctx
sets standard Temporal CLI environment variables before executing a subcommand with tctx exec
.
Any CLI tool (not just tctl
) can be used in conjunction with tctx
if it leverages these environment variables.
To view all environment variables set for the current context, run
tctx exec -- printenv | grep TEMPORAL_CLI
By default tctx exec
uses the active context. The active context is set by the last tctx use
or tctx add
command.
You can override the active context by adding a context flag
tctx exec -c <context> -- <command>
Define an alias
Typing tctx exec -- tctl
is a lot of effort. It's possible to define an alias to make this easier.
alias tctl="tctx exec -- tctl"