cli

package
v2.0.0-...-2470e90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 77 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	FlagAddress                    = "address"
	FlagAuth                       = "auth"
	FlagNamespaceID                = "namespace-id"
	FlagNamespace                  = "namespace"
	FlagNamespaceAlias             = []string{"n"}
	FlagWorkflowID                 = "workflow-id"
	FlagWorkflowIDAlias            = []string{"w"}
	FlagRunID                      = "run-id"
	FlagRunIDAlias                 = []string{"r"}
	FlagTaskQueue                  = "task-queue"
	FlagTaskQueueAlias             = []string{"t"}
	FlagTaskQueueType              = "task-queue-type"
	FlagWorkflowIDReusePolicy      = "id-reuse-policy"
	FlagCronSchedule               = "cron"
	FlagWorkflowExecutionTimeout   = "execution-timeout"
	FlagWorkflowRunTimeout         = "run-timeout"
	FlagWorkflowTaskTimeout        = "task-timeout"
	FlagContextTimeout             = "context-timeout"
	FlagInput                      = "input"
	FlagInputAlias                 = []string{"i"}
	FlagInputFile                  = "input-file"
	FlagExcludeFile                = "exclude-file"
	FlagInputSeparator             = "input-separator"
	FlagParallelism                = "input-parallelism"
	FlagSkipCurrentOpen            = "skip-current-open"
	FlagSkipBaseIsNotCurrent       = "skip-base-is-not-current"
	FlagDryRun                     = "dry-run"
	FlagNonDeterministic           = "non-deterministic"
	FlagResult                     = "result"
	FlagIdentity                   = "identity"
	FlagDetail                     = "detail"
	FlagReason                     = "reason"
	FlagPrintRaw                   = "raw"
	FlagDescription                = "description"
	FlagOwnerEmail                 = "email"
	FlagRetention                  = "retention"
	FlagHistoryArchivalState       = "history-archival-state"
	FlagHistoryArchivalURI         = "history-uri"
	FlagVisibilityArchivalState    = "visibility-archival-state"
	FlagVisibilityArchivalURI      = "visibility-uri"
	FlagName                       = "name"
	FlagOutputFilename             = "output-filename"
	FlagQueryRejectCondition       = "reject-condition"
	FlagActiveCluster              = "active-cluster"
	FlagCluster                    = "cluster"
	FlagNamespaceData              = "data"
	FlagIsGlobalNamespace          = "global"
	FlagPromoteNamespace           = "promote-global"
	FlagEventID                    = "event-id"
	FlagActivityID                 = "activity-id"
	FlagMaxFieldLength             = "max-field-length"
	FlagMemo                       = "memo"
	FlagMemoFile                   = "memo-file"
	FlagSearchAttribute            = "search-attribute"
	FlagResetReapplyType           = "reapply-type"
	FlagResetPointsOnly            = "reset-points"
	FlagQuery                      = "query"
	FlagQueryAlias                 = []string{"q"}
	FlagQueryUsage                 = "Filter results using SQL like query. See https://docs.temporal.io/docs/tctl/workflow/list#--query for details"
	FlagArchive                    = "archived"
	FlagRPS                        = "rps"
	FlagJobID                      = "job-id"
	FlagYes                        = "yes"
	FlagYesAlias                   = []string{"y"}
	FlagTLSCertPath                = "tls-cert-path"
	FlagTLSKeyPath                 = "tls-key-path"
	FlagTLSCaPath                  = "tls-ca-path"
	FlagTLSDisableHostVerification = "tls-disable-host-verification"
	FlagTLSServerName              = "tls-server-name"
	FlagConcurrency                = "concurrency"
	FlagDataConverterPlugin        = "data-converter-plugin"
	FlagCodecAuth                  = "codec-auth"
	FlagCodecEndpoint              = "codec-endpoint"
	FlagWebURL                     = "url"
	FlagHeadersProviderPlugin      = "headers-provider-plugin"
	FlagPort                       = "port"
	FlagFollowAlias                = []string{"f"}
	FlagType                       = "type"
	FlagWorkflowType               = "workflow-type"
	FlagScheduleID                 = "schedule-id"
	FlagScheduleIDAlias            = []string{"s"}
	FlagOverlapPolicy              = "overlap-policy"
	FlagCalendar                   = "calendar"
	FlagInterval                   = "interval"
	FlagStartTime                  = "start-time"
	FlagEndTime                    = "end-time"
	FlagJitter                     = "jitter"
	FlagTimeZone                   = "time-zone"
	FlagNotes                      = "notes"
	FlagRemainingActions           = "remaining-actions"
	FlagCatchupWindow              = "catchup-window"
	FlagPauseOnFailure             = "pause-on-failure"
	FlagPause                      = "pause"
	FlagUnpause                    = "unpause"
	FlagFold                       = "fold"
	FlagNoFold                     = "no-fold"
	FlagDepth                      = "depth"
	FlagOutputAlias                = []string{"o"}
	FlagClusterAddress             = "frontend-address"
	FlagClusterEnableConnection    = "enable-connection"
)

Flags used to specify cli command line arguments

Functions

func AddSearchAttributes

func AddSearchAttributes(c *cli.Context) error

AddSearchAttributes to add search attributes

func BackfillSchedule

func BackfillSchedule(c *cli.Context) error

func BatchCancel

func BatchCancel(c *cli.Context) error

BatchCancel cancel a list of workflows

func BatchSignal

func BatchSignal(c *cli.Context) error

BatchSignal send a signal to a list of workflows

func BatchTerminate

func BatchTerminate(c *cli.Context) error

BatchTerminate terminate a list of workflows

func CancelWorkflow

func CancelWorkflow(c *cli.Context) error

func ColorEvent

func ColorEvent(e *historypb.HistoryEvent) string

ColorEvent takes an event and return string with color Event with color mapping rules:

Failed - red
Timeout - yellow
Canceled - magenta
Completed - green
Started - blue
Others - default (white/black)

func CompleteActivity

func CompleteActivity(c *cli.Context) error

CompleteActivity completes an Activity

func CountWorkflow

func CountWorkflow(c *cli.Context) error

CountWorkflow count number of workflows

func CreateSchedule

func CreateSchedule(c *cli.Context) error

func CurrentEnv

func CurrentEnv(c *cli.Context) error
Example
tctl := NewCliApp()

tctl.Run([]string{"", "config", "use-env", testEnvName})
tctl.Run([]string{"", "config", "current-env"})
Output:

current-env: tctl-test-env
tctl-test-env

func DataConverter

func DataConverter(c *cli.Context) error

DataConverter provides a data converter over a websocket for Temporal web

func DeleteNamespace

func DeleteNamespace(c *cli.Context) error

DeleteNamespace deletes namespace.

func DeleteSchedule

func DeleteSchedule(c *cli.Context) error

func DeleteWorkflow

func DeleteWorkflow(c *cli.Context) error

DeleteWorkflow deletes a workflow execution.

func DescribeBatchJob

func DescribeBatchJob(c *cli.Context) error

DescribeBatchJob describe the status of the batch job

func DescribeCluster

func DescribeCluster(c *cli.Context) error

func DescribeNamespace

func DescribeNamespace(c *cli.Context) error

DescribeNamespace updates a namespace

func DescribeSchedule

func DescribeSchedule(c *cli.Context) error

func DescribeSystem

func DescribeSystem(c *cli.Context) error

func DescribeTaskQueue

func DescribeTaskQueue(c *cli.Context) error

DescribeTaskQueue show pollers info of a given taskqueue

func DescribeWorkflow

func DescribeWorkflow(c *cli.Context) error

DescribeWorkflow show information about the specified workflow execution

func EnvProperty

func EnvProperty(c *cli.Context) error
Example
// The MIT License
//
// Copyright (c) 2022 Temporal Technologies Inc.  All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package main

import (
	"log"
	"os"
	"path/filepath"

	"github.com/urfave/cli/v2"
)

func main() {
	tctl := NewCliApp()
	defer setupConfig(tctl)()

	tctl.Run([]string{"", "config", "set", "namespace", "tctl-test-namespace"})

	tctl.Run([]string{"", "config", "get", "namespace"})

}

func (s *cliAppSuite) TestSetConfigValue() {
	defer setupConfig(s.app)()

	err := s.app.Run([]string{"", "config", "set", "namespace", "tctl-test-namespace"})
	s.NoError(err)
	err = s.app.Run([]string{"", "config", "set", "address", "0.0.0.0:00000"})
	s.NoError(err)

	config := readConfig()
	s.Contains(config, "    tctl-test-env:")
	s.Contains(config, "        address: 0.0.0.0:00000")
	s.Contains(config, "        namespace: tctl-test-namespace")
}

func setupConfig(app *cli.App) func() {
	err := app.Run([]string{"", "config", "use-env", testEnvName})
	if err != nil {
		log.Fatal(err)
	}

	return func() {
		err = app.Run([]string{"", "config", "use-env", "local"})
		if err != nil {
			log.Fatal(err)
		}
		err = app.Run([]string{"", "config", "remove-env", testEnvName})
		if err != nil {
			log.Fatal(err)
		}
	}
}

func readConfig() string {
	path := getConfigPath()
	content, err := os.ReadFile(path)
	if err != nil {
		log.Fatal(err)
	}
	return string(content)
}

func getConfigPath() string {
	dpath, err := os.UserHomeDir()
	if err != nil {
		log.Fatal(err)
	}

	path := filepath.Join(dpath, ".config", "temporalio", "tctl.yaml")

	return path
}
Output:

current-env: tctl-test-env
Set 'namespace' to: tctl-test-namespace
tctl-test-namespace
current-env: local
Removed env tctl-test-env

func FailActivity

func FailActivity(c *cli.Context) error

FailActivity fails an activity

func HealthCheck

func HealthCheck(c *cli.Context) error

HealthCheck check frontend health.

func HistoryEventToString

func HistoryEventToString(e *historypb.HistoryEvent, printFully bool, maxFieldLength int) string

HistoryEventToString convert HistoryEvent to string

func ListBatchJobs

func ListBatchJobs(c *cli.Context) error

ListBatchJobs list the started batch jobs

func ListClusters

func ListClusters(c *cli.Context) error

func ListNamespaces

func ListNamespaces(c *cli.Context) error

ListNamespaces list all namespaces

func ListSchedules

func ListSchedules(c *cli.Context) error

func ListSearchAttributes

func ListSearchAttributes(c *cli.Context) error

ListSearchAttributes lists search attributes

func ListTaskQueuePartitions

func ListTaskQueuePartitions(c *cli.Context) error

ListTaskQueuePartitions gets all the taskqueue partition and host information.

func ListWorkflow

func ListWorkflow(c *cli.Context) error

ListWorkflow list workflow executions based on filters

func NewCliApp

func NewCliApp() *cli.App

NewCliApp instantiates a new instance of the CLI application.

func NewContextWithCLIHeaders

func NewContextWithCLIHeaders() (context.Context, context.CancelFunc)

NewContextWithCLIHeaders creates context with version headers for CLI.

func NewContextWithTimeoutAndCLIHeaders

func NewContextWithTimeoutAndCLIHeaders(timeout time.Duration) (context.Context, context.CancelFunc)

NewContextWithTimeoutAndCLIHeaders creates context with timeout and version headers for CLI.

func QueryWorkflow

func QueryWorkflow(c *cli.Context) error

QueryWorkflow query workflow execution

func QueryWorkflowUsingStackTrace

func QueryWorkflowUsingStackTrace(c *cli.Context) error

QueryWorkflowUsingStackTrace query workflow execution using __stack_trace as query type

func RegisterNamespace

func RegisterNamespace(c *cli.Context) error

RegisterNamespace register a namespace

func RemoveCluster

func RemoveCluster(c *cli.Context) error

func RemoveEnv

func RemoveEnv(c *cli.Context) error

func RemoveSearchAttributes

func RemoveSearchAttributes(c *cli.Context) error

RemoveSearchAttributes to add search attributes

func ResetInBatch

func ResetInBatch(c *cli.Context) error

ResetInBatch resets workflow in batch

func ResetWorkflow

func ResetWorkflow(c *cli.Context) error

ResetWorkflow reset workflow

func SetAlias

func SetAlias(c *cli.Context) error

func SetEnvProperty

func SetEnvProperty(c *cli.Context) error

func SetFactory

func SetFactory(factory ClientFactory)

SetFactory is used to set the ClientFactory global

func SetRequiredNamespaceDataKeys

func SetRequiredNamespaceDataKeys(keys []string)

SetRequiredNamespaceDataKeys will set requiredNamespaceDataKeys

func ShowEnv

func ShowEnv(c *cli.Context) error
Example
tctl := NewCliApp()

tctl.Run([]string{"", "config", "use-env", testEnvName})
tctl.Run([]string{"", "config", "set", "namespace", "tctl-test-namespace"})

tctl.Run([]string{"", "config", "show-env", testEnvName})
Output:

current-env: tctl-test-env
Set 'namespace' to: tctl-test-namespace
  namespace  tctl-test-namespace

func ShowHistory

func ShowHistory(c *cli.Context) error

ShowHistory shows the history of given workflow execution based on workflowID and runID.

func SignalWorkflow

func SignalWorkflow(c *cli.Context) error

func SplitKeyValuePairs

func SplitKeyValuePairs(kvs []string) (map[string]string, error)

SplitKeyValuePairs parses key=value pairs

func StartWorkflow

func StartWorkflow(c *cli.Context, printProgress bool) error

StartWorkflow starts a new workflow execution and optionally prints progress

func StopBatchJob

func StopBatchJob(c *cli.Context) error

StopBatchJob stops a batch job

func TerminateWorkflow

func TerminateWorkflow(c *cli.Context) error

func ToggleSchedule

func ToggleSchedule(c *cli.Context) error

func TraceWorkflow

func TraceWorkflow(c *cli.Context) error

func TriggerSchedule

func TriggerSchedule(c *cli.Context) error

func UpdateNamespace

func UpdateNamespace(c *cli.Context) error

UpdateNamespace updates a namespace

func UpdateSchedule

func UpdateSchedule(c *cli.Context) error

func UpsertCluster

func UpsertCluster(c *cli.Context) error

func UseEnv

func UseEnv(c *cli.Context) error

Types

type ClientFactory

type ClientFactory interface {
	FrontendClient(c *cli.Context) workflowservice.WorkflowServiceClient
	OperatorClient(c *cli.Context) operatorservice.OperatorServiceClient
	SDKClient(c *cli.Context, namespace string) sdkclient.Client
	HealthClient(c *cli.Context) healthpb.HealthClient
}

ClientFactory is used to construct rpc clients

func NewClientFactory

func NewClientFactory() ClientFactory

NewClientFactory creates a new ClientFactory

type HttpGetter

type HttpGetter interface {
	Get(url string) (resp *http.Response, err error)
}

HttpGetter defines http.Client.Get(...) as an interface so we can mock it

type PayloadRequest

type PayloadRequest struct {
	RequestID string `json:"requestId"`
	Payload   string `json:"payload"`
}

type PayloadResponse

type PayloadResponse struct {
	RequestID string `json:"requestId"`
	Content   string `json:"content"`
}

type SdkLogger

type SdkLogger struct {
	// contains filtered or unexported fields
}

func NewSdkLogger

func NewSdkLogger(logger log.Logger) *SdkLogger

func (*SdkLogger) Debug

func (l *SdkLogger) Debug(msg string, keyvals ...interface{})

func (*SdkLogger) Error

func (l *SdkLogger) Error(msg string, keyvals ...interface{})

func (*SdkLogger) Info

func (l *SdkLogger) Info(msg string, keyvals ...interface{})

func (*SdkLogger) Warn

func (l *SdkLogger) Warn(msg string, keyvals ...interface{})

func (*SdkLogger) With

func (l *SdkLogger) With(keyvals ...interface{}) sdklog.Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL