Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pull and validate cli #435

Merged
merged 8 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pkg/cli/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cli
import (
"context"
"fmt"
"strings"
"time"

"cloud.google.com/go/logging/apiv2/loggingpb"
Expand Down Expand Up @@ -200,8 +201,10 @@ func (c *TailCommand) Run(ctx context.Context, args []string) error {
continue
}

// Output tailed log.
c.Outf(string(js))
// Output tailed log, all spaces are stripped to reduce unit test flakiness
// as protojson.Marshal can produce inconsistent output. See issue
// https://github.com/golang/protobuf/issues/1121.
c.Outf(strings.Replace(string(js), " ", "", -1))
sqin2019 marked this conversation as resolved.
Show resolved Hide resolved

// Output validation result if validation is enabled.
if c.flagValidate {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cli/tail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func TestTailCommand(t *testing.T) {
Labels: map[string]string{"environment": "dev", "accessing_process_name": "foo_apn"},
}

validLogJSON, err := protojson.Marshal(validLog)
bs, err := protojson.Marshal(validLog)
sqin2019 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
t.Fatalf("failed to mashal log to JSON: %v", err)
}
validLogJSON := strings.Replace(string(bs), " ", "", -1)

cases := []struct {
name string
Expand Down