From 6dc826c422fef455510b0777340a6d2d54639ed8 Mon Sep 17 00:00:00 2001 From: Gert Drapers <1533850+gertd@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:25:03 -0700 Subject: [PATCH] use protojson & default instance_label to polcy_name --- pkg/handlers/decision_logs/stream.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/handlers/decision_logs/stream.go b/pkg/handlers/decision_logs/stream.go index 338faa2..f4fa935 100644 --- a/pkg/handlers/decision_logs/stream.go +++ b/pkg/handlers/decision_logs/stream.go @@ -1,6 +1,7 @@ package decision_logs //nolint // prefer standardizing name over removing _ import ( + "fmt" "os" "os/signal" "time" @@ -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 @@ -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)) } }()