8000 feat(cdsctl): Add a flag to resynchronize workflow from command line … · ovh/cds@6cc85a5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 6cc85a5

Browse files
bnjjjyesnault
authored andcommitted
feat(cdsctl): Add a flag to resynchronize workflow from command line #2469 (#3684)
close #2469 Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
1 parent d6426ec commit 6cc85a5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

cli/cdsctl/workflow_run.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,20 @@ var workflowRunManualCmd = cli.Command{
8383
Usage: "Open web browser on the workflow run",
8484
Kind: reflect.Bool,
8585
},
86+
{
87+
Name: "sync",
88+
ShortHand: "s",
89+
Usage: "Synchronise your pipelines with your last editions. Must be used with flag run-number",
90+
Kind: reflect.Bool,
91+
},
8692
},
8793
}
8894

8995
func workflowRunManualRun(v cli.Values) error {
96+
if v.GetBool("sync") && v.GetString("run-number") == "" {
97+
return fmt.Errorf("Could not use flag --sync without flag --run-number")
98+
}
99+
90100
manual := sdk.WorkflowNodeRunManual{}
91101
if strings.TrimSpace(v.GetString("data")) != "" {
92102
data := map[string]interface{}{}
@@ -133,6 +143,12 @@ func workflowRunManualRun(v cli.Values) error {
133143
}
134144
}
135145

146+
if v.GetBool("sync") {
147+
if _, err := client.WorkflowRunResync(v[_ProjectKey], v[_WorkflowName], runNumber); err != nil {
148+
return fmt.Errorf("Cannot resync your workflow run %d : %v", runNumber, err)
149+
}
150+
}
151+
136152
if v.GetString("node-name") != "" {
137153
if runNumber <= 0 {
138154
return fmt.Errorf("You can use flag node-name without flag run-number")

sdk/cdsclient/client_workflow.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ func (c *client) WorkflowRunGet(projectKey string, workflowName string, number i
4141
return &run, nil
4242
}
4343

44+
func (c *client) WorkflowRunResync(projectKey string, workflowName string, number int64) (*sdk.WorkflowRun, error) {
45+
url := fmt.Sprintf("/project/%s/workflows/%s/runs/%d/resync", projectKey, workflowName, number)
46+
var run sdk.WorkflowRun
47+
if _, err := c.PostJSON(context.Background(), url, nil, &run); err != nil {
48+
return nil, err
49+
}
50+
return &run, nil
51+
}
52+
4453
func (c *client) WorkflowRunSearch(projectKey string, offset, limit int64, filters ...Filter) ([]sdk.WorkflowRun, error) {
4554
if offset < 0 {
4655
offset = 0

sdk/cdsclient/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ type WorkflowClient interface {
273273
WorkflowGet(projectKey, name string) (*sdk.Workflow, error)
274274
WorkflowDelete(projectKey string, workflowName string) error
275275
WorkflowRunGet(projectKey string, workflowName string, number int64) (*sdk.WorkflowRun, error)
276+
WorkflowRunResync(projectKey string, workflowName string, number int64) (*sdk.WorkflowRun, error)
276277
WorkflowRunSearch(projectKey string, offset, limit int64, filter ...Filter) ([]sdk.WorkflowRun, error)
277278
WorkflowRunList(projectKey string, workflowName string, offset, limit int64) ([]sdk.WorkflowRun, error)
278279
WorkflowRunArtifacts(projectKey string, name string, number int64) ([]sdk.WorkflowNodeRunArtifact, error)

0 commit comments

Comments
 (0)
0