Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] upgrade urfave/cli to v2 #6285

Merged
merged 16 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions tools/cli/admin_async_queue_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"github.com/uber/cadence/common/types"
)

func AdminGetAsyncWFConfig(c *cli.Context) error {

Check warning on line 34 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L34

Added line #L34 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

domainName := getRequiredOption(c, FlagDomain)
Expand All @@ -45,20 +45,20 @@

resp, err := adminClient.GetDomainAsyncWorkflowConfiguraton(ctx, req)
if err != nil {
return ErrorAndPrint("Failed to get async wf queue config", err)
return PrintableError("Failed to get async wf queue config", err)

Check warning on line 48 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L48

Added line #L48 was not covered by tests
}

if resp == nil || resp.Configuration == nil {
fmt.Printf("Async workflow queue config not found for domain %s\n", domainName)
return nil

Check warning on line 53 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L53

Added line #L53 was not covered by tests
}

fmt.Printf("Async workflow queue config for domain %s:\n", domainName)
prettyPrintJSONObject(resp.Configuration)
return nil

Check warning on line 58 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L58

Added line #L58 was not covered by tests
}

func AdminUpdateAsyncWFConfig(c *cli.Context) error {

Check warning on line 61 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L61

Added line #L61 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

domainName := getRequiredOption(c, FlagDomain)
Expand All @@ -67,7 +67,7 @@
var cfg types.AsyncWorkflowConfiguration
err := json.Unmarshal([]byte(asyncWFCfgJSON), &cfg)
if err != nil {
return ErrorAndPrint("Failed to parse async workflow config", err)
return PrintableError("Failed to parse async workflow config", err)

Check warning on line 70 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L70

Added line #L70 was not covered by tests
}

ctx, cancel := newContext(c)
Expand All @@ -80,9 +80,9 @@

_, err = adminClient.UpdateDomainAsyncWorkflowConfiguraton(ctx, req)
if err != nil {
return ErrorAndPrint("Failed to update async workflow queue config", err)
return PrintableError("Failed to update async workflow queue config", err)

Check warning on line 83 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L83

Added line #L83 was not covered by tests
}

fmt.Printf("Successfully updated async workflow queue config for domain %s\n", domainName)
return nil

Check warning on line 87 in tools/cli/admin_async_queue_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_async_queue_commands.go#L87

Added line #L87 was not covered by tests
}
14 changes: 7 additions & 7 deletions tools/cli/admin_cluster_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
func AdminAddSearchAttribute(c *cli.Context) error {
key := getRequiredOption(c, FlagSearchAttributesKey)
if err := visibility.ValidateSearchAttributeKey(key); err != nil {
return ErrorAndPrint("Invalid search-attribute key.", err)
return PrintableError("Invalid search-attribute key.", err)

Check warning on line 44 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L44

Added line #L44 was not covered by tests
}

valType := getRequiredIntOption(c, FlagSearchAttributesType)
if !isValueTypeValid(valType) {
return ErrorAndPrint("Unknown Search Attributes value type.", nil)
return PrintableError("Unknown Search Attributes value type.", nil)

Check warning on line 49 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L49

Added line #L49 was not covered by tests
}

// ask user for confirmation
Expand All @@ -66,28 +66,28 @@

err := adminClient.AddSearchAttribute(ctx, request)
if err != nil {
return ErrorAndPrint("Add search attribute failed.", err)
return PrintableError("Add search attribute failed.", err)

Check warning on line 69 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L69

Added line #L69 was not covered by tests
}
fmt.Println("Success. Note that for a multil-node Cadence cluster, DynamicConfig MUST be updated separately to whitelist the new attributes.")
return nil
}

// AdminDescribeCluster is used to dump information about the cluster
func AdminDescribeCluster(c *cli.Context) error {

Check warning on line 76 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L76

Added line #L76 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

ctx, cancel := newContext(c)
defer cancel()
response, err := adminClient.DescribeCluster(ctx)
if err != nil {
return ErrorAndPrint("Operation DescribeCluster failed.", err)
return PrintableError("Operation DescribeCluster failed.", err)

Check warning on line 83 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L83

Added line #L83 was not covered by tests
}

prettyPrintJSONObject(response)
return nil

Check warning on line 87 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L87

Added line #L87 was not covered by tests
}

func AdminRebalanceStart(c *cli.Context) error {

Check warning on line 90 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L90

Added line #L90 was not covered by tests
client := getCadenceClient(c)
tcCtx, cancel := newContext(c)
defer cancel()
Expand All @@ -99,13 +99,13 @@
}
input, err := json.Marshal(rbParams)
if err != nil {
return ErrorAndPrint("Failed to serialize params for failover workflow", err)
return PrintableError("Failed to serialize params for failover workflow", err)

Check warning on line 102 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L102

Added line #L102 was not covered by tests
}
memo, err := getWorkflowMemo(map[string]interface{}{
common.MemoKeyForOperator: getOperator(),
})
if err != nil {
return ErrorAndPrint("Failed to serialize memo", err)
return PrintableError("Failed to serialize memo", err)

Check warning on line 108 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L108

Added line #L108 was not covered by tests
}
request := &types.StartWorkflowExecutionRequest{
Domain: common.SystemLocalDomainName,
Expand All @@ -127,22 +127,22 @@

resp, err := client.StartWorkflowExecution(tcCtx, request)
if err != nil {
return ErrorAndPrint("Failed to start failover workflow", err)
return PrintableError("Failed to start failover workflow", err)

Check warning on line 130 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L130

Added line #L130 was not covered by tests
}
fmt.Println("Rebalance workflow started")
fmt.Println("wid: " + workflowID)
fmt.Println("rid: " + resp.GetRunID())
return nil

Check warning on line 135 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L135

Added line #L135 was not covered by tests
}

func AdminRebalanceList(c *cli.Context) error {
if err := c.Set(FlagWorkflowID, failovermanager.RebalanceWorkflowID); err != nil {
return err

Check warning on line 140 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L138-L140

Added lines #L138 - L140 were not covered by tests
}
if err := c.Set(FlagDomain, common.SystemLocalDomainName); err != nil {
return err

Check warning on line 143 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L142-L143

Added lines #L142 - L143 were not covered by tests
}
return ListWorkflow(c)

Check warning on line 145 in tools/cli/admin_cluster_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_cluster_commands.go#L145

Added line #L145 was not covered by tests
}

func intValTypeToString(valType int) string {
Expand Down
70 changes: 35 additions & 35 deletions tools/cli/admin_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)

// AdminShowWorkflow shows history
func AdminShowWorkflow(c *cli.Context) error {

Check warning on line 46 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L46

Added line #L46 was not covered by tests
tid := c.String(FlagTreeID)
bid := c.String(FlagBranchID)
sid := c.Int(FlagShardID)
Expand All @@ -63,7 +63,7 @@
BranchID: &bid,
})
if err != nil {
return ErrorAndPrint("encoding branch token err", err)
return PrintableError("encoding branch token err", err)

Check warning on line 66 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L66

Added line #L66 was not covered by tests
}
resp, err := histV2.ReadRawHistoryBranch(ctx, &persistence.ReadHistoryBranchRequest{
BranchToken: branchToken,
Expand All @@ -74,16 +74,16 @@
DomainName: domainName,
})
if err != nil {
return ErrorAndPrint("ReadHistoryBranch err", err)
return PrintableError("ReadHistoryBranch err", err)

Check warning on line 77 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L77

Added line #L77 was not covered by tests
}

history = resp.HistoryEventBlobs
} else {
return ErrorAndPrint("need to specify TreeID/BranchID/ShardID", nil)
return PrintableError("need to specify TreeID/BranchID/ShardID", nil)

Check warning on line 82 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L82

Added line #L82 was not covered by tests
}

if len(history) == 0 {
return ErrorAndPrint("no events", nil)
return PrintableError("no events", nil)

Check warning on line 86 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L86

Added line #L86 was not covered by tests
}
allEvents := &shared.History{}
totalSize := 0
Expand All @@ -92,14 +92,14 @@
fmt.Printf("======== batch %v, blob len: %v ======\n", idx+1, len(b.Data))
internalHistoryBatch, err := serializer.DeserializeBatchEvents(b)
if err != nil {
return ErrorAndPrint("DeserializeBatchEvents err", err)
return PrintableError("DeserializeBatchEvents err", err)

Check warning on line 95 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L95

Added line #L95 was not covered by tests
}
historyBatch := thrift.FromHistoryEventArray(internalHistoryBatch)
allEvents.Events = append(allEvents.Events, historyBatch...)
for _, e := range historyBatch {
jsonstr, err := json.Marshal(e)
if err != nil {
return ErrorAndPrint("json.Marshal err", err)
return PrintableError("json.Marshal err", err)

Check warning on line 102 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L102

Added line #L102 was not covered by tests
}
fmt.Println(string(jsonstr))
}
Expand All @@ -109,13 +109,13 @@
if outputFileName != "" {
data, err := json.Marshal(allEvents.Events)
if err != nil {
return ErrorAndPrint("Failed to serialize history data.", err)
return PrintableError("Failed to serialize history data.", err)

Check warning on line 112 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L112

Added line #L112 was not covered by tests
}
if err := ioutil.WriteFile(outputFileName, data, 0666); err != nil {
return ErrorAndPrint("Failed to export history data file.", err)
return PrintableError("Failed to export history data file.", err)

Check warning on line 115 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L115

Added line #L115 was not covered by tests
}
}
return nil

Check warning on line 118 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L118

Added line #L118 was not covered by tests
}

// AdminDescribeWorkflow describe a new workflow execution for admin
Expand All @@ -132,14 +132,14 @@
ms := persistence.WorkflowMutableState{}
err := json.Unmarshal([]byte(msStr), &ms)
if err != nil {
return ErrorAndPrint("json.Unmarshal err", err)
return PrintableError("json.Unmarshal err", err)

Check warning on line 135 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L135

Added line #L135 was not covered by tests
}
currentBranchToken := ms.ExecutionInfo.BranchToken
if ms.VersionHistories != nil {
// if VersionHistories is set, then all branch infos are stored in VersionHistories
currentVersionHistory, err := ms.VersionHistories.GetCurrentVersionHistory()
if err != nil {
return ErrorAndPrint("ms.VersionHistories.GetCurrentVersionHistory err", err)
return PrintableError("ms.VersionHistories.GetCurrentVersionHistory err", err)

Check warning on line 142 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L142

Added line #L142 was not covered by tests
}
currentBranchToken = currentVersionHistory.GetBranchToken()
}
Expand All @@ -148,7 +148,7 @@
thriftrwEncoder := codec.NewThriftRWEncoder()
err = thriftrwEncoder.Decode(currentBranchToken, &branchInfo)
if err != nil {
return ErrorAndPrint("thriftrwEncoder.Decode err", err)
return PrintableError("thriftrwEncoder.Decode err", err)

Check warning on line 151 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L151

Added line #L151 was not covered by tests
}
prettyPrintJSONObject(branchInfo)
if ms.ExecutionInfo.AutoResetPoints != nil {
Expand Down Expand Up @@ -184,14 +184,14 @@
},
)
if err != nil {
return nil, ErrorAndPrint("Get workflow mutableState failed", err)
return nil, PrintableError("Get workflow mutableState failed", err)
}
return resp, nil
}

// AdminMaintainCorruptWorkflow deletes workflow from DB if it's corrupt
func AdminMaintainCorruptWorkflow(c *cli.Context) error {
domainName := getRequiredOption(c, FlagDomain)

Check warning on line 194 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L194

Added line #L194 was not covered by tests
workflowID := c.String(FlagWorkflowID)
runID := c.String(FlagRunID)
skipErrors := c.Bool(FlagSkipErrorMode)
Expand All @@ -210,15 +210,15 @@
defer cancel()
_, err := adminClient.MaintainCorruptWorkflow(ctx, request)
if err != nil {
return ErrorAndPrint("Operation AdminMaintainCorruptWorkflow failed.", err)
return PrintableError("Operation AdminMaintainCorruptWorkflow failed.", err)

Check warning on line 213 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L213

Added line #L213 was not covered by tests
}

return err
}

// AdminDeleteWorkflow delete a workflow execution for admin
func AdminDeleteWorkflow(c *cli.Context) error {
domain := getRequiredOption(c, FlagDomain)

Check warning on line 221 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L220-L221

Added lines #L220 - L221 were not covered by tests
wid := getRequiredOption(c, FlagWorkflowID)
rid := c.String(FlagRunID)
remote := c.Bool(FlagRemote)
Expand All @@ -243,27 +243,27 @@
}
_, err := adminClient.DeleteWorkflow(ctx, request)
if err != nil {
return ErrorAndPrint("Operation AdminMaintainCorruptWorkflow failed.", err)
return PrintableError("Operation AdminMaintainCorruptWorkflow failed.", err)

Check warning on line 246 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L246

Added line #L246 was not covered by tests
}
return nil

Check warning on line 248 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L248

Added line #L248 was not covered by tests
}

resp, err := describeMutableState(c)
if err != nil {
return err

Check warning on line 253 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L251-L253

Added lines #L251 - L253 were not covered by tests
}
msStr := resp.GetMutableStateInDatabase()
ms := persistence.WorkflowMutableState{}
err = json.Unmarshal([]byte(msStr), &ms)

Check warning on line 257 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L257

Added line #L257 was not covered by tests
if err != nil {
return ErrorAndPrint("json.Unmarshal err", err)
return PrintableError("json.Unmarshal err", err)

Check warning on line 259 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L259

Added line #L259 was not covered by tests
}
domainID := ms.ExecutionInfo.DomainID

shardID := resp.GetShardID()
shardIDInt, err := strconv.Atoi(shardID)
if err != nil {
return ErrorAndPrint("strconv.Atoi(shardID) err", err)
return PrintableError("strconv.Atoi(shardID) err", err)

Check warning on line 266 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L266

Added line #L266 was not covered by tests
}
histV2 := initializeHistoryManager(c)
defer histV2.Close()
Expand All @@ -283,7 +283,7 @@
for _, branchToken := range branchTokens {
err = thriftrwEncoder.Decode(branchToken, &branchInfo)
if err != nil {
return ErrorAndPrint("thriftrwEncoder.Decode err", err)
return PrintableError("thriftrwEncoder.Decode err", err)

Check warning on line 286 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L286

Added line #L286 was not covered by tests
}
fmt.Println("deleting history events for ...")
prettyPrintJSONObject(branchInfo)
Expand All @@ -296,7 +296,7 @@
if skipError {
fmt.Println("failed to delete history, ", err)
} else {
return ErrorAndPrint("DeleteHistoryBranch err", err)
return PrintableError("DeleteHistoryBranch err", err)

Check warning on line 299 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L299

Added line #L299 was not covered by tests
}
}
}
Expand All @@ -313,7 +313,7 @@
if skipError {
fmt.Println("delete mutableState row failed, ", err)
} else {
return ErrorAndPrint("delete mutableState row failed", err)
return PrintableError("delete mutableState row failed", err)

Check warning on line 316 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L316

Added line #L316 was not covered by tests
}
}
fmt.Println("delete mutableState row successfully")
Expand All @@ -329,19 +329,19 @@
if skipError {
fmt.Println("delete current row failed, ", err)
} else {
return ErrorAndPrint("delete current row failed", err)
return PrintableError("delete current row failed", err)

Check warning on line 332 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L332

Added line #L332 was not covered by tests
}
}
fmt.Println("delete current row successfully")
return nil

Check warning on line 336 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L336

Added line #L336 was not covered by tests
}

// AdminGetDomainIDOrName map domain
func AdminGetDomainIDOrName(c *cli.Context) error {

Check warning on line 340 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L340

Added line #L340 was not covered by tests
domainID := c.String(FlagDomainID)
domainName := c.String(FlagDomain)
if len(domainID) == 0 && len(domainName) == 0 {
return ErrorAndPrint("Need either domainName or domainID", nil)
return PrintableError("Need either domainName or domainID", nil)

Check warning on line 344 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L344

Added line #L344 was not covered by tests
}

domainManager := initializeDomainManager(c)
Expand All @@ -351,34 +351,34 @@
if len(domainID) > 0 {
domain, err := domainManager.GetDomain(ctx, &persistence.GetDomainRequest{ID: domainID})
if err != nil {
return ErrorAndPrint("SelectDomain error", err)
return PrintableError("SelectDomain error", err)

Check warning on line 354 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L354

Added line #L354 was not covered by tests
}
fmt.Printf("domainName for domainID %v is %v \n", domainID, domain.Info.Name)
} else {
domain, err := domainManager.GetDomain(ctx, &persistence.GetDomainRequest{Name: domainName})
if err != nil {
return ErrorAndPrint("SelectDomain error", err)
return PrintableError("SelectDomain error", err)

Check warning on line 360 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L360

Added line #L360 was not covered by tests
}
fmt.Printf("domainID for domainName %v is %v \n", domain.Info.ID, domainID)
}
return nil

Check warning on line 364 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L364

Added line #L364 was not covered by tests
}

// AdminGetShardID get shardID
func AdminGetShardID(c *cli.Context) error {

Check warning on line 368 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L368

Added line #L368 was not covered by tests
wid := getRequiredOption(c, FlagWorkflowID)
numberOfShards := c.Int(FlagNumberOfShards)

if numberOfShards <= 0 {
return ErrorAndPrint("numberOfShards is required", nil)
return PrintableError("numberOfShards is required", nil)

Check warning on line 373 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L373

Added line #L373 was not covered by tests
}
shardID := common.WorkflowIDToHistoryShard(wid, numberOfShards)
fmt.Printf("ShardID for workflowID: %v is %v \n", wid, shardID)
return nil

Check warning on line 377 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L377

Added line #L377 was not covered by tests
}

// AdminRemoveTask describes history host
func AdminRemoveTask(c *cli.Context) error {

Check warning on line 381 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L381

Added line #L381 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

shardID := getRequiredIntOption(c, FlagShardID)
Expand All @@ -403,13 +403,13 @@

err := adminClient.RemoveTask(ctx, req)
if err != nil {
return ErrorAndPrint("Remove task has failed", err)
return PrintableError("Remove task has failed", err)

Check warning on line 406 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L406

Added line #L406 was not covered by tests
}
return nil

Check warning on line 408 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L408

Added line #L408 was not covered by tests
}

// AdminDescribeShard describes shard by shard id
func AdminDescribeShard(c *cli.Context) error {

Check warning on line 412 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L412

Added line #L412 was not covered by tests
sid := getRequiredIntOption(c, FlagShardID)

ctx, cancel := newContext(c)
Expand All @@ -419,15 +419,15 @@
getShardReq := &persistence.GetShardRequest{ShardID: sid}
shard, err := shardManager.GetShard(ctx, getShardReq)
if err != nil {
return ErrorAndPrint("Failed to describe shard.", err)
return PrintableError("Failed to describe shard.", err)

Check warning on line 422 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L422

Added line #L422 was not covered by tests
}

prettyPrintJSONObject(shard)
return nil

Check warning on line 426 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L426

Added line #L426 was not covered by tests
}

// AdminSetShardRangeID set shard rangeID by shard id
func AdminSetShardRangeID(c *cli.Context) error {

Check warning on line 430 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L430

Added line #L430 was not covered by tests
sid := getRequiredIntOption(c, FlagShardID)
rid := getRequiredInt64Option(c, FlagRangeID)

Expand All @@ -437,7 +437,7 @@

getShardResp, err := shardManager.GetShard(ctx, &persistence.GetShardRequest{ShardID: sid})
if err != nil {
return ErrorAndPrint("Failed to get shardInfo.", err)
return PrintableError("Failed to get shardInfo.", err)

Check warning on line 440 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L440

Added line #L440 was not covered by tests
}

previousRangeID := getShardResp.ShardInfo.RangeID
Expand All @@ -451,15 +451,15 @@
PreviousRangeID: previousRangeID,
ShardInfo: updatedShardInfo,
}); err != nil {
return ErrorAndPrint("Failed to reset shard rangeID.", err)
return PrintableError("Failed to reset shard rangeID.", err)

Check warning on line 454 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L454

Added line #L454 was not covered by tests
}

fmt.Printf("Successfully updated rangeID from %v to %v for shard %v.\n", previousRangeID, rid, sid)
return nil

Check warning on line 458 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L458

Added line #L458 was not covered by tests
}

// AdminCloseShard closes shard by shard id
func AdminCloseShard(c *cli.Context) error {

Check warning on line 462 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L462

Added line #L462 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)
sid := getRequiredIntOption(c, FlagShardID)

Expand All @@ -471,9 +471,9 @@

err := adminClient.CloseShard(ctx, req)
if err != nil {
return ErrorAndPrint("Close shard task has failed", err)
return PrintableError("Close shard task has failed", err)

Check warning on line 474 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L474

Added line #L474 was not covered by tests
}
return nil

Check warning on line 476 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L476

Added line #L476 was not covered by tests
}

type ShardRow struct {
Expand All @@ -482,7 +482,7 @@
}

// AdminDescribeShardDistribution describes shard distribution
func AdminDescribeShardDistribution(c *cli.Context) error {

Check warning on line 485 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L485

Added line #L485 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

ctx, cancel := newContext(c)
Expand All @@ -495,14 +495,14 @@

resp, err := adminClient.DescribeShardDistribution(ctx, req)
if err != nil {
return ErrorAndPrint("Shard list failed", err)
return PrintableError("Shard list failed", err)

Check warning on line 498 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L498

Added line #L498 was not covered by tests
}

fmt.Printf("Total Number of Shards: %d \n", resp.NumberOfShards)
fmt.Printf("Number of Shards Returned: %d \n", len(resp.Shards))

if len(resp.Shards) == 0 {
return nil

Check warning on line 505 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L505

Added line #L505 was not covered by tests
}

table := []ShardRow{}
Expand All @@ -510,8 +510,8 @@
outputPageSize := tableRenderSize
for shardID, identity := range resp.Shards {
if outputPageSize == 0 {
if err := Render(c, table, opts); err != nil {
return fmt.Errorf("error rendering: %w", err)

Check warning on line 514 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L513-L514

Added lines #L513 - L514 were not covered by tests
}
table = []ShardRow{}
if !showNextPage() {
Expand All @@ -523,11 +523,11 @@
outputPageSize--
}
// output the remaining rows
return Render(c, table, opts)

Check warning on line 526 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L526

Added line #L526 was not covered by tests
}

// AdminDescribeHistoryHost describes history host
func AdminDescribeHistoryHost(c *cli.Context) error {

Check warning on line 530 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L530

Added line #L530 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

wid := c.String(FlagWorkflowID)
Expand All @@ -536,7 +536,7 @@
printFully := c.Bool(FlagPrintFullyDetail)

if len(wid) == 0 && !c.IsSet(FlagShardID) && len(addr) == 0 {
return ErrorAndPrint("at least one of them is required to provide to lookup host: workflowID, shardID and host address", nil)
return PrintableError("at least one of them is required to provide to lookup host: workflowID, shardID and host address", nil)

Check warning on line 539 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L539

Added line #L539 was not covered by tests
}

ctx, cancel := newContext(c)
Expand All @@ -555,21 +555,21 @@

resp, err := adminClient.DescribeHistoryHost(ctx, req)
if err != nil {
return ErrorAndPrint("Describe history host failed", err)
return PrintableError("Describe history host failed", err)

Check warning on line 558 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L558

Added line #L558 was not covered by tests
}

if !printFully {
resp.ShardIDs = nil
}
prettyPrintJSONObject(resp)
return nil

Check warning on line 565 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L565

Added line #L565 was not covered by tests
}

// AdminRefreshWorkflowTasks refreshes all the tasks of a workflow
func AdminRefreshWorkflowTasks(c *cli.Context) error {

Check warning on line 569 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L569

Added line #L569 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

domain := getRequiredOption(c, FlagDomain)

Check warning on line 572 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L572

Added line #L572 was not covered by tests
wid := getRequiredOption(c, FlagWorkflowID)
rid := c.String(FlagRunID)

Expand All @@ -584,14 +584,14 @@
},
})
if err != nil {
return ErrorAndPrint("Refresh workflow task failed", err)
return PrintableError("Refresh workflow task failed", err)

Check warning on line 587 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L587

Added line #L587 was not covered by tests
}
fmt.Println("Refresh workflow task succeeded.")
return nil

Check warning on line 590 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L589-L590

Added lines #L589 - L590 were not covered by tests
}

// AdminResetQueue resets task processing queue states
func AdminResetQueue(c *cli.Context) error {

Check warning on line 594 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L594

Added line #L594 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

shardID := getRequiredIntOption(c, FlagShardID)
Expand All @@ -609,14 +609,14 @@

err := adminClient.ResetQueue(ctx, req)
if err != nil {
return ErrorAndPrint("Failed to reset queue", err)
return PrintableError("Failed to reset queue", err)

Check warning on line 612 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L612

Added line #L612 was not covered by tests
}
fmt.Println("Reset queue state succeeded")
return nil

Check warning on line 615 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L615

Added line #L615 was not covered by tests
}

// AdminDescribeQueue describes task processing queue states
func AdminDescribeQueue(c *cli.Context) error {

Check warning on line 619 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L619

Added line #L619 was not covered by tests
adminClient := cFactory.ServerAdminClient(c)

shardID := getRequiredIntOption(c, FlagShardID)
Expand All @@ -634,11 +634,11 @@

resp, err := adminClient.DescribeQueue(ctx, req)
if err != nil {
return ErrorAndPrint("Failed to describe queue", err)
return PrintableError("Failed to describe queue", err)

Check warning on line 637 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L637

Added line #L637 was not covered by tests
}

for _, state := range resp.ProcessingQueueStates {
fmt.Println(state)
}
return nil

Check warning on line 643 in tools/cli/admin_commands.go

View check run for this annotation

Codecov / codecov/patch

tools/cli/admin_commands.go#L643

Added line #L643 was not covered by tests
}
Loading
Loading