Skip to content

Commit 0dea2ba

Browse files
committed
Use 'plaintext' instead of 'param' in functions config
1 parent 9298bf0 commit 0dea2ba

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

api/function.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"net/http"
11+
"strings"
1112
)
1213

1314
type FunctionService interface {
@@ -107,10 +108,16 @@ func NewUpdateFunctionRequestBody(name string, events *[]string, mode string, bo
107108
}
108109

109110
func NewCreateFunctionConfigRequest(name string, description string, paramType string, content string) CreateFunctionConfigRequest {
111+
convertParamType := func(pt string) string {
112+
if strings.ToLower(pt) == "plaintext" {
113+
return "param"
114+
}
115+
return pt
116+
}
110117
return CreateFunctionConfigRequest{
111118
Name: name,
112119
Description: description,
113-
ParamType: paramType,
120+
ParamType: convertParamType(paramType),
114121
Content: content,
115122
}
116123
}

commands/channels/functions.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ import (
1919
)
2020

2121
func NewConfigListCommand(pusher api.FunctionService) *cobra.Command {
22+
convertParamType := func(pt string) string {
23+
if strings.ToLower(pt) == "param" {
24+
return "plaintext"
25+
}
26+
return pt
27+
}
2228
cmd := &cobra.Command{
2329
Use: "list",
2430
Short: "List function configs for an Channels app",
@@ -36,7 +42,7 @@ func NewConfigListCommand(pusher api.FunctionService) *cobra.Command {
3642
table := newTable(cmd.OutOrStdout())
3743
table.SetHeader([]string{"Name", "Desciption", "Type"})
3844
for _, config := range configs {
39-
table.Append([]string{config.Name, config.Description, config.ParamType})
45+
table.Append([]string{config.Name, config.Description, convertParamType(config.ParamType)})
4046
}
4147
table.Render()
4248
}
@@ -78,7 +84,7 @@ func NewConfigCreateCommand(functionService api.FunctionService) (*cobra.Command
7884
if err != nil {
7985
return nil, err
8086
}
81-
cmd.PersistentFlags().StringVar(&commands.FunctionConfigParamType, "type", "", "Function config type, valid options: param|secret")
87+
cmd.PersistentFlags().StringVar(&commands.FunctionConfigParamType, "type", "", "Function config type, valid options: plaintext|secret")
8288
err = cmd.MarkPersistentFlagRequired("type")
8389
if err != nil {
8490
return nil, err

0 commit comments

Comments
 (0)