Skip to content

Commit 20f231b

Browse files
Merge pull request #69 from aserto-dev/fix-dl-stream
use protojson & default instance_label to policy_name
2 parents eac8bb1 + 6dc826c commit 20f231b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/handlers/decision_logs/stream.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package decision_logs //nolint // prefer standardizing name over removing _
22

33
import (
4+
"fmt"
45
"os"
56
"os/signal"
67
"time"
@@ -14,11 +15,15 @@ import (
1415

1516
type StreamCmd struct {
1617
PolicyName string `arg:"" help:"Name of policy to open stream for"`
17-
InstanceLabel string `arg:"" help:"Label of policy to open stream for"`
18-
Since string `optional:"" help:"time to start streaming events from in RFC3339 format"`
18+
InstanceLabel string `arg:"" help:"Label of policy to open stream for" optional:""`
19+
Since string `flag:"" help:"time to start streaming events from in RFC3339 format" optional:""`
1920
}
2021

2122
func (cmd StreamCmd) Run(c *cc.CommonCtx) error {
23+
if cmd.InstanceLabel == "" && cmd.PolicyName != "" {
24+
cmd.InstanceLabel = cmd.PolicyName
25+
}
26+
2227
cli, err := c.DecisionLogsClient(c.Context)
2328
if err != nil {
2429
return err
@@ -54,11 +59,7 @@ func (cmd StreamCmd) Run(c *cc.CommonCtx) error {
5459
return
5560
}
5661

57-
errRcv = jsonx.OutputJSON(c.StdOut(), resp.Decision)
58-
if err != nil {
59-
errCh <- errRcv
60-
return
61-
}
62+
fmt.Fprintln(c.StdOut(), jsonx.MarshalOpts(true).Format(resp.Decision))
6263
}
6364
}()
6465

0 commit comments

Comments
 (0)