forked from ovh/cds
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow_delete.go
More file actions
43 lines (39 loc) · 888 Bytes
/
workflow_delete.go
File metadata and controls
43 lines (39 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"net/http"
"os"
"strconv"
"github.com/ovh/cds/cli"
"github.com/ovh/cds/sdk"
)
var workflowDeleteCmd = cli.Command{
Name: "delete",
Short: "Delete a CDS workflow",
Ctx: []cli.Arg{
{Name: _ProjectKey},
{Name: _WorkflowName},
},
Flags: []cli.Flag{
{
Name: "with-dependencies",
ShortHand: "d",
Usage: "delete and clean workflow dependencies",
Type: cli.FlagBool,
},
},
}
func workflowDeleteRun(v cli.Values) error {
mod := func(r *http.Request) {
q := r.URL.Query()
b := v.GetBool("with-dependencies")
q.Set("withDependencies", strconv.FormatBool(b))
r.URL.RawQuery = q.Encode()
}
err := client.WorkflowDelete(v.GetString(_ProjectKey), v.GetString(_WorkflowName), mod)
if err != nil && v.GetBool("force") && sdk.ErrorIs(err, sdk.ErrNotFound) {
fmt.Println(err.Error())
os.Exit(0)
}
return err
}