Skip to content

Commit

Permalink
Merge branch 'main' into fastedge/api-change
Browse files Browse the repository at this point in the history
  • Loading branch information
qrdl committed Apr 3, 2024
2 parents d0b5c0a + c8ae41f commit 7bca0e6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/commands/fastedge/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func appPropertiesFlags(cmd *cobra.Command) {
cmd.Flags().String("file", "", "Wasm binary filename ('-' means stdin)")
cmd.Flags().String("plan", "", "Plan name")
cmd.Flags().Bool("disabled", false, "Set status to 'disabled'")
cmd.Flags().StringSlice("env", nil, "Environment, in name=value format")
cmd.Flags().StringArray("env", nil, "Environment, in name=value format")
cmd.Flags().StringSlice("rsp_headers", nil, "Response headers to add, in name=value format")
}

Expand Down Expand Up @@ -386,13 +386,13 @@ func parseAppProperties(cmd *cobra.Command) (sdk.App, error) {
app.Status = newPointer(1)
}

env, err := getMapParamP(cmd, "env")
env, err := getMapParamP("env", cmd.Flags().GetStringArray)
if err != nil {
return app, err
}
app.Env = &env

rspHeaders, err := getMapParamP(cmd, "rsp_headers")
rspHeaders, err := getMapParamP("rsp_headers", cmd.Flags().GetStringSlice)
if err != nil {
return app, err
}
Expand All @@ -401,9 +401,9 @@ func parseAppProperties(cmd *cobra.Command) (sdk.App, error) {
return app, nil
}

func getMapParamP(cmd *cobra.Command, name string) (map[string]string, error) {
func getMapParamP(name string, f func(name string) ([]string, error)) (map[string]string, error) {
ret := make(map[string]string)
slice, err := cmd.Flags().GetStringSlice(name)
slice, err := f(name)
if err != nil || slice == nil || len(slice) == 0 {
return ret, err
}
Expand Down

0 comments on commit 7bca0e6

Please sign in to comment.