|
|
@@ -7,9 +7,6 @@ import (
|
|
|
"os"
|
|
|
"strings"
|
|
|
|
|
|
- "gogs.dmsc.dev/arp/arp_cli/client"
|
|
|
- "gogs.dmsc.dev/arp/arp_cli/config"
|
|
|
-
|
|
|
"github.com/AlecAivazis/survey/v2"
|
|
|
"github.com/olekukonko/tablewriter"
|
|
|
"github.com/urfave/cli/v3"
|
|
|
@@ -319,7 +316,7 @@ type WorkflowNode struct {
|
|
|
// WorkflowTemplate CRUD operations
|
|
|
|
|
|
func workflowTemplateList(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -327,9 +324,6 @@ func workflowTemplateList(ctx context.Context, cmd *cli.Command) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
query := `query WorkflowTemplates { workflowTemplates { id name description definition isActive createdBy { id email } createdAt updatedAt } }`
|
|
|
|
|
|
resp, err := c.Query(query, nil)
|
|
|
@@ -379,7 +373,7 @@ func workflowTemplateList(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowTemplateGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -387,9 +381,6 @@ func workflowTemplateGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
id := cmd.String("id")
|
|
|
query := `query WorkflowTemplate($id: ID!) { workflowTemplate(id: $id) { id name description definition isActive createdBy { id email } createdAt updatedAt } }`
|
|
|
|
|
|
@@ -431,7 +422,7 @@ func workflowTemplateGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowTemplateCreate(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -466,9 +457,6 @@ func workflowTemplateCreate(ctx context.Context, cmd *cli.Command) error {
|
|
|
// Handle file input for definition
|
|
|
definition = ReadFileOrString(definition)
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
mutation := `mutation CreateWorkflowTemplate($input: NewWorkflowTemplate!) { createWorkflowTemplate(input: $input) { id name description definition isActive createdBy { id email } createdAt updatedAt } }`
|
|
|
|
|
|
input := map[string]interface{}{
|
|
|
@@ -502,7 +490,7 @@ func workflowTemplateCreate(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowTemplateUpdate(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -527,9 +515,6 @@ func workflowTemplateUpdate(ctx context.Context, cmd *cli.Command) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
input := make(map[string]interface{})
|
|
|
if name != "" {
|
|
|
input["name"] = name
|
|
|
@@ -570,7 +555,7 @@ func workflowTemplateUpdate(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowTemplateDelete(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -596,9 +581,6 @@ func workflowTemplateDelete(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
mutation := `mutation DeleteWorkflowTemplate($id: ID!) { deleteWorkflowTemplate(id: $id) }`
|
|
|
|
|
|
resp, err := c.Mutation(mutation, map[string]interface{}{"id": id})
|
|
|
@@ -625,7 +607,7 @@ func workflowTemplateDelete(ctx context.Context, cmd *cli.Command) error {
|
|
|
// WorkflowInstance operations
|
|
|
|
|
|
func workflowInstanceList(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -633,9 +615,6 @@ func workflowInstanceList(ctx context.Context, cmd *cli.Command) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
query := `query WorkflowInstances { workflowInstances { id template { id name } status context service { id name } createdAt updatedAt completedAt } }`
|
|
|
|
|
|
resp, err := c.Query(query, nil)
|
|
|
@@ -681,7 +660,7 @@ func workflowInstanceList(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowInstanceGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -689,9 +668,6 @@ func workflowInstanceGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
id := cmd.String("id")
|
|
|
query := `query WorkflowInstance($id: ID!) { workflowInstance(id: $id) { id template { id name description } status context service { id name } createdAt updatedAt completedAt } }`
|
|
|
|
|
|
@@ -739,7 +715,7 @@ func workflowInstanceGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowInstanceStart(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -751,9 +727,6 @@ func workflowInstanceStart(ctx context.Context, cmd *cli.Command) error {
|
|
|
serviceID := cmd.String("service")
|
|
|
contextJSON := cmd.String("context")
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
mutation := `mutation StartWorkflow($templateId: ID!, $input: StartWorkflowInput!) { startWorkflow(templateId: $templateId, input: $input) { id template { id name } status context service { id name } createdAt } }`
|
|
|
|
|
|
input := make(map[string]interface{})
|
|
|
@@ -791,7 +764,7 @@ func workflowInstanceStart(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowInstanceCancel(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -801,9 +774,6 @@ func workflowInstanceCancel(ctx context.Context, cmd *cli.Command) error {
|
|
|
|
|
|
id := cmd.String("id")
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
mutation := `mutation CancelWorkflow($id: ID!) { cancelWorkflow(id: $id) { id status completedAt } }`
|
|
|
|
|
|
resp, err := c.Mutation(mutation, map[string]interface{}{"id": id})
|
|
|
@@ -832,7 +802,7 @@ func workflowInstanceCancel(ctx context.Context, cmd *cli.Command) error {
|
|
|
// WorkflowNode operations
|
|
|
|
|
|
func workflowNodeList(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -840,9 +810,6 @@ func workflowNodeList(ctx context.Context, cmd *cli.Command) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
instanceID := cmd.String("instance")
|
|
|
query := `query WorkflowInstance($id: ID!) { workflowInstance(id: $id) { id status nodes: workflowNodes { id nodeKey nodeType status task { id title } retryCount createdAt startedAt completedAt } } }`
|
|
|
|
|
|
@@ -896,7 +863,7 @@ func workflowNodeList(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowNodeGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -904,9 +871,6 @@ func workflowNodeGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
id := cmd.String("id")
|
|
|
query := `query WorkflowNode($id: ID!) { workflowNode(id: $id) { id nodeKey nodeType status task { id title } inputData outputData retryCount createdAt updatedAt startedAt completedAt } }`
|
|
|
|
|
|
@@ -980,7 +944,7 @@ func workflowNodeGet(ctx context.Context, cmd *cli.Command) error {
|
|
|
}
|
|
|
|
|
|
func workflowNodeRetry(ctx context.Context, cmd *cli.Command) error {
|
|
|
- cfg, err := config.Load()
|
|
|
+ c, cfg, err := GetClient(ctx, cmd)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -990,9 +954,6 @@ func workflowNodeRetry(ctx context.Context, cmd *cli.Command) error {
|
|
|
|
|
|
id := cmd.String("id")
|
|
|
|
|
|
- c := client.New(cfg.ServerURL)
|
|
|
- c.SetToken(cfg.Token)
|
|
|
-
|
|
|
mutation := `mutation RetryWorkflowNode($nodeId: ID!) { retryWorkflowNode(nodeId: $nodeId) { id nodeKey status retryCount } }`
|
|
|
|
|
|
resp, err := c.Mutation(mutation, map[string]interface{}{"nodeId": id})
|