Skip to content

Commit

Permalink
Merge pull request #69 from aserto-dev/fix-dl-stream
Browse files Browse the repository at this point in the history
use protojson & default instance_label to policy_name
  • Loading branch information
carabasdaniel authored Aug 14, 2024
2 parents eac8bb1 + 6dc826c commit 20f231b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/handlers/decision_logs/stream.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package decision_logs //nolint // prefer standardizing name over removing _

import (
"fmt"
"os"
"os/signal"
"time"
Expand All @@ -14,11 +15,15 @@ import (

type StreamCmd struct {
PolicyName string `arg:"" help:"Name of policy to open stream for"`
InstanceLabel string `arg:"" help:"Label of policy to open stream for"`
Since string `optional:"" help:"time to start streaming events from in RFC3339 format"`
InstanceLabel string `arg:"" help:"Label of policy to open stream for" optional:""`
Since string `flag:"" help:"time to start streaming events from in RFC3339 format" optional:""`
}

func (cmd StreamCmd) Run(c *cc.CommonCtx) error {
if cmd.InstanceLabel == "" && cmd.PolicyName != "" {
cmd.InstanceLabel = cmd.PolicyName
}

cli, err := c.DecisionLogsClient(c.Context)
if err != nil {
return err
Expand Down Expand Up @@ -54,11 +59,7 @@ func (cmd StreamCmd) Run(c *cc.CommonCtx) error {
return
}

errRcv = jsonx.OutputJSON(c.StdOut(), resp.Decision)
if err != nil {
errCh <- errRcv
return
}
fmt.Fprintln(c.StdOut(), jsonx.MarshalOpts(true).Format(resp.Decision))
}
}()

Expand Down

0 comments on commit 20f231b

Please sign in to comment.