Skip to content

Commit 7ea959a

Browse files
committed
rule-engine: fix create and update commands
1 parent b862131 commit 7ea959a

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

internal/app/enaptercli/cmd_rule_engine_rule_create.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ func (c *cmdRuleEngineRuleCreate) do(ctx context.Context) error {
7979
}
8080

8181
body, err := json.Marshal(map[string]any{
82-
"rule": map[string]any{
83-
"slug": c.slug,
84-
"script": map[string]any{
85-
"code": base64.StdEncoding.EncodeToString(scriptBytes),
86-
"runtime_version": c.runtimeVersion,
87-
"exec_interval": c.execInterval.String(),
88-
},
82+
"slug": c.slug,
83+
"script": map[string]any{
84+
"code": base64.StdEncoding.EncodeToString(scriptBytes),
85+
"runtime_version": c.runtimeVersion,
86+
"exec_interval": c.execInterval.String(),
8987
},
90-
"disable_rule": c.disable,
88+
"disable": c.disable,
9189
})
9290
if err != nil {
9391
return fmt.Errorf("build request: %w", err)

internal/app/enaptercli/cmd_rule_engine_rule_update.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/http"
8-
"strings"
98

109
"github.com/urfave/cli/v2"
1110
)
@@ -47,21 +46,12 @@ func (c *cmdRuleEngineRuleUpdate) Flags() []cli.Flag {
4746
}
4847

4948
func (c *cmdRuleEngineRuleUpdate) do(cliCtx *cli.Context) error {
50-
payload := struct {
51-
Rule map[string]any `json:"rule"`
52-
UpdateMask string `json:"update_mask"`
53-
}{
54-
Rule: make(map[string]any),
55-
UpdateMask: "",
56-
}
49+
payload := make(map[string]any)
5750

5851
if cliCtx.IsSet("slug") {
59-
payload.Rule["slug"] = c.slug
60-
payload.UpdateMask += "slug,"
52+
payload["slug"] = c.slug
6153
}
6254

63-
payload.UpdateMask = strings.TrimSuffix(payload.UpdateMask, ",")
64-
6555
body, err := json.Marshal(payload)
6656
if err != nil {
6757
return fmt.Errorf("build request: %w", err)

0 commit comments

Comments
 (0)