Skip to content

Commit

Permalink
feat(api,ui): workflow template json param type and funcs for template (
Browse files Browse the repository at this point in the history
#3860)

* feat(api,ui): workflow template json parameter

* feat(api): add interpolate funcs to workflow template

* fix(api): missing condition before executing the template

* refact(cdsctl): allow to set array flags

* docs(cdsctl,ui): add doc about workflow template bulk
  • Loading branch information
richardlt authored Jan 18, 2019
1 parent ef143f5 commit 075f55b
Show file tree
Hide file tree
Showing 69 changed files with 678 additions and 393 deletions.
8 changes: 3 additions & 5 deletions cli/cdsctl/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"path"
"reflect"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -60,7 +59,7 @@ cdsctl action show myAction`,
}

func actionShowRun(v cli.Values) (interface{}, error) {
action, err := client.ActionGet(v["action-name"])
action, err := client.ActionGet(v.GetString("action-name"))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -91,13 +90,13 @@ var actionDeleteCmd = cli.Command{
return true
},
Default: "false",
Kind: reflect.Bool,
Type: cli.FlagBool,
},
},
}

func actionDeleteRun(v cli.Values) error {
err := client.ActionDelete(v["action-name"])
err := client.ActionDelete(v.GetString("action-name"))
if v.GetBool("force") && sdk.ErrorIs(err, sdk.ErrNoAction) {
fmt.Println(err)
return nil
Expand Down Expand Up @@ -181,7 +180,6 @@ cdsctl action export myAction`,
},
Flags: []cli.Flag{
{
Kind: reflect.String,
Name: "format",
Usage: "Specify export format (json or yaml)",
Default: "yaml",
Expand Down
10 changes: 4 additions & 6 deletions cli/cdsctl/admin_broadcasts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io/ioutil"
"os"
"reflect"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -34,7 +33,6 @@ var adminBroadcastCreateCmd = cli.Command{
},
Flags: []cli.Flag{
{
Kind: reflect.String,
Name: "level",
ShortHand: "l",
Usage: "Level of broadcast: info or warning",
Expand Down Expand Up @@ -66,7 +64,7 @@ func adminBroadcastCreateRun(v cli.Values) error {

bc := &sdk.Broadcast{
Level: v.GetString("level"),
Title: v["title"],
Title: v.GetString("title"),
Content: string(content),
}
return client.BroadcastCreate(bc)
Expand All @@ -81,7 +79,7 @@ var adminBroadcastShowCmd = cli.Command{
}

func adminBroadcastShowRun(v cli.Values) (interface{}, error) {
bc, err := client.BroadcastGet(v["id"])
bc, err := client.BroadcastGet(v.GetString("id"))
if err != nil {
return nil, err
}
Expand All @@ -105,13 +103,13 @@ var adminBroadcastDeleteCmd = cli.Command{
return true
},
Default: "false",
Kind: reflect.Bool,
Type: cli.FlagBool,
},
},
}

func adminBroadcastDeleteRun(v cli.Values) error {
err := client.BroadcastDelete(v["id"])
err := client.BroadcastDelete(v.GetString("id"))
if v.GetBool("force") && sdk.ErrorIs(err, sdk.ErrNoBroadcast) {
fmt.Println(err)
return nil
Expand Down
2 changes: 0 additions & 2 deletions cli/cdsctl/admin_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/url"
"reflect"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -35,7 +34,6 @@ var adminHooksTaskListCmd = cli.Command{
Short: "List CDS Hooks Tasks",
Flags: []cli.Flag{
{
Kind: reflect.String,
Name: "sort",
Usage: "Sort task by nb_executions_total,nb_executions_todo",
Default: "",
Expand Down
6 changes: 0 additions & 6 deletions cli/cdsctl/admin_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"reflect"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -30,7 +29,6 @@ var adminServiceListCmd = cli.Command{
Short: "List CDS services",
Flags: []cli.Flag{
{
Kind: reflect.String,
Name: "type",
ShortHand: "t",
Usage: "Filter service by type: api, hatchery, hook, repository, vcs",
Expand All @@ -52,14 +50,12 @@ var adminServiceStatusCmd = cli.Command{
Short: "Status CDS services",
Flags: []cli.Flag{
{
Kind: reflect.String,
Name: "type",
ShortHand: "t",
Usage: "Filter service by type: api, hatchery, hook, repository, vcs",
Default: "",
},
{
Kind: reflect.String,
Name: "name",
Usage: "Filter service by name",
Default: "",
Expand All @@ -79,13 +75,11 @@ cdsctl admin services request --name hatcheryLocal --query /debug/pprof/goroutin
`,
Flags: []cli.Flag{
{
Kind: reflect.String,
Name: "name",
Usage: "service name",
Default: "",
},
{
Kind: reflect.String,
Name: "query",
Usage: "http query, example: '/debug/pprof/goroutine?debug=2'",
Default: "",
Expand Down
17 changes: 8 additions & 9 deletions cli/cdsctl/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"os"
"reflect"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -40,7 +39,7 @@ var applicationListCmd = cli.Command{
}

func applicationListRun(v cli.Values) (cli.ListResult, error) {
apps, err := client.ApplicationList(v[_ProjectKey])
apps, err := client.ApplicationList(v.GetString(_ProjectKey))
if err != nil {
return nil, err
}
Expand All @@ -57,7 +56,7 @@ var applicationShowCmd = cli.Command{
}

func applicationShowRun(v cli.Values) (interface{}, error) {
app, err := client.ApplicationGet(v[_ProjectKey], v[_ApplicationName])
app, err := client.ApplicationGet(v.GetString(_ProjectKey), v.GetString(_ApplicationName))
if err != nil {
return nil, err
}
Expand All @@ -77,8 +76,8 @@ var applicationCreateCmd = cli.Command{
}

func applicationCreateRun(v cli.Values) error {
a := &sdk.Application{Name: v[_ApplicationName]}
return client.ApplicationCreate(v[_ProjectKey], a)
a := &sdk.Application{Name: v.GetString(_ApplicationName)}
return client.ApplicationCreate(v.GetString(_ProjectKey), a)
}

var applicationDeleteCmd = cli.Command{
Expand All @@ -91,7 +90,7 @@ var applicationDeleteCmd = cli.Command{
}

func applicationDeleteRun(v cli.Values) error {
err := client.ApplicationDelete(v[_ProjectKey], v[_ApplicationName])
err := client.ApplicationDelete(v.GetString(_ProjectKey), v.GetString(_ApplicationName))
if err != nil && v.GetBool("force") && sdk.ErrorIs(err, sdk.ErrApplicationNotFound) {
fmt.Println(err.Error())
os.Exit(0)
Expand All @@ -110,7 +109,7 @@ var applicationImportCmd = cli.Command{
},
Flags: []cli.Flag{
{
Kind: reflect.Bool,
Type: cli.FlagBool,
Name: "force",
Usage: "Override application if exists",
Default: "false",
Expand Down Expand Up @@ -153,13 +152,13 @@ var applicationExportCmd = cli.Command{
},
Flags: []cli.Flag{
{
Kind: reflect.Bool,
Type: cli.FlagBool,
Name: "with-permissions",
Usage: "Export permissions",
Default: "false",
},
{
Kind: reflect.String,
Type: cli.FlagString,
Name: "format",
Usage: "Specify export format (json or yaml)",
Default: "yaml",
Expand Down
7 changes: 3 additions & 4 deletions cli/cdsctl/application_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"reflect"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -44,7 +43,7 @@ var applicationGroupImportCmd = cli.Command{
return true
},
Default: "false",
Kind: reflect.Bool,
Type: cli.FlagBool,
},
},
}
Expand Down Expand Up @@ -77,10 +76,10 @@ func applicationGroupImportRun(v cli.Values) error {
}
}

if _, err := client.ApplicationGroupsImport(v[_ProjectKey], v[_ApplicationName], reader, format, v.GetBool("force")); err != nil {
if _, err := client.ApplicationGroupsImport(v.GetString(_ProjectKey), v.GetString(_ApplicationName), reader, format, v.GetBool("force")); err != nil {
return err
}
fmt.Printf("Groups imported in application %s with success\n", v[_ApplicationName])
fmt.Printf("Groups imported in application %s with success\n", v.GetString(_ApplicationName))

return nil
}
12 changes: 6 additions & 6 deletions cli/cdsctl/application_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ var applicationKeyCreateCmd = cli.Command{
func applicationCreateKeyRun(v cli.Values) error {
key := &sdk.ApplicationKey{
Key: sdk.Key{
Name: v["key-name"],
Type: v["key-type"],
Name: v.GetString("key-name"),
Type: v.GetString("key-type"),
},
}
if err := client.ApplicationKeyCreate(v[_ProjectKey], v[_ApplicationName], key); err != nil {
if err := client.ApplicationKeyCreate(v.GetString(_ProjectKey), v.GetString(_ApplicationName), key); err != nil {
return err
}

fmt.Printf("Application key %s of type %s created with success in application %s\n", key.Name, key.Type, v[_ApplicationName])
fmt.Printf("Application key %s of type %s created with success in application %s\n", key.Name, key.Type, v.GetString(_ApplicationName))
fmt.Println(key.Public)
return nil
}
Expand All @@ -61,7 +61,7 @@ var applicationKeyListCmd = cli.Command{
}

func applicationListKeyRun(v cli.Values) (cli.ListResult, error) {
keys, err := client.ApplicationKeysList(v[_ProjectKey], v[_ApplicationName])
keys, err := client.ApplicationKeysList(v.GetString(_ProjectKey), v.GetString(_ApplicationName))
if err != nil {
return nil, err
}
Expand All @@ -81,5 +81,5 @@ var applicationKeyDeleteCmd = cli.Command{
}

func applicationDeleteKeyRun(v cli.Values) error {
return client.ApplicationKeysDelete(v[_ProjectKey], v[_ApplicationName], v["key-name"])
return client.ApplicationKeysDelete(v.GetString(_ProjectKey), v.GetString(_ApplicationName), v.GetString("key-name"))
}
24 changes: 12 additions & 12 deletions cli/cdsctl/application_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ var applicationVariableCreateCmd = cli.Command{

func applicationCreateVariableRun(v cli.Values) error {
variable := &sdk.Variable{
Name: v["variable-name"],
Type: v["variable-type"],
Value: v["variable-value"],
Name: v.GetString("variable-name"),
Type: v.GetString("variable-type"),
Value: v.GetString("variable-value"),
}
return client.ApplicationVariableCreate(v[_ProjectKey], v[_ApplicationName], variable)
return client.ApplicationVariableCreate(v.GetString(_ProjectKey), v.GetString(_ApplicationName), variable)
}

var applicationVariableListCmd = cli.Command{
Expand All @@ -55,7 +55,7 @@ var applicationVariableListCmd = cli.Command{
}

func applicationListVariableRun(v cli.Values) (cli.ListResult, error) {
variables, err := client.ApplicationVariablesList(v[_ProjectKey], v[_ApplicationName])
variables, err := client.ApplicationVariablesList(v.GetString(_ProjectKey), v.GetString(_ApplicationName))
if err != nil {
return nil, err
}
Expand All @@ -75,7 +75,7 @@ var applicationVariableDeleteCmd = cli.Command{
}

func applicationDeleteVariableRun(v cli.Values) error {
return client.ApplicationVariableDelete(v[_ProjectKey], v[_ApplicationName], v["variable-name"])
return client.ApplicationVariableDelete(v.GetString(_ProjectKey), v.GetString(_ApplicationName), v.GetString("variable-name"))
}

var applicationVariableShowCmd = cli.Command{
Expand All @@ -91,7 +91,7 @@ var applicationVariableShowCmd = cli.Command{
}

func applicationVariableShowRun(v cli.Values) (interface{}, error) {
return client.ApplicationVariableGet(v[_ProjectKey], v[_ApplicationName], v["variable-name"])
return client.ApplicationVariableGet(v.GetString(_ProjectKey), v.GetString(_ApplicationName), v.GetString("variable-name"))
}

var applicationVariableUpdateCmd = cli.Command{
Expand All @@ -110,12 +110,12 @@ var applicationVariableUpdateCmd = cli.Command{
}

func applicationUpdateVariableRun(v cli.Values) error {
variable, err := client.ApplicationVariableGet(v[_ProjectKey], v[_ApplicationName], v["variable-oldname"])
variable, err := client.ApplicationVariableGet(v.GetString(_ProjectKey), v.GetString(_ApplicationName), v.GetString("variable-oldname"))
if err != nil {
return err
}
variable.Name = v["variable-name"]
variable.Value = v["variable-value"]
variable.Type = v["variable-type"]
return client.ApplicationVariableUpdate(v[_ProjectKey], v[_ApplicationName], variable)
variable.Name = v.GetString("variable-name")
variable.Value = v.GetString("variable-value")
variable.Type = v.GetString("variable-type")
return client.ApplicationVariableUpdate(v.GetString(_ProjectKey), v.GetString(_ApplicationName), variable)
}
Loading

0 comments on commit 075f55b

Please sign in to comment.