Skip to content

Commit 75ff301

Browse files
authored
Merge pull request #1412 from ripienaar/kv_times
Render various timestamps using the standard renderer
2 parents 83d8536 + 42efca1 commit 75ff301

File tree

8 files changed

+12
-13
lines changed

8 files changed

+12
-13
lines changed

cli/auth_account_exports.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"os"
2020
"sort"
2121
"strings"
22-
"time"
2322

2423
"github.com/nats-io/natscli/internal/util"
2524

@@ -161,7 +160,7 @@ func (c *authAccountCommand) showExport(exp ab.Export) (string, error) {
161160

162161
if len(exp.Revocations().List()) > 0 {
163162
for _, rev := range exp.Revocations().List() {
164-
cols.AddRow(rev.At().Format(time.RFC3339), rev.PublicKey())
163+
cols.AddRow(f(rev.At()), rev.PublicKey())
165164
}
166165
} else {
167166
cols.Println()

cli/consumer_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,9 +1130,9 @@ func (c *consumerCmd) showInfo(config api.ConsumerConfig, state api.ConsumerInfo
11301130

11311131
var cols *columns.Writer
11321132
if c.showStateOnly {
1133-
cols = newColumns(fmt.Sprintf("State for Consumer %s > %s created %s", state.Stream, state.Name, state.Created.Local().Format(time.RFC3339)))
1133+
cols = newColumns(fmt.Sprintf("State for Consumer %s > %s created %s", state.Stream, state.Name, f(state.Created)))
11341134
} else {
1135-
cols = newColumns(fmt.Sprintf("Information for Consumer %s > %s created %s", state.Stream, state.Name, state.Created.Local().Format(time.RFC3339)))
1135+
cols = newColumns(fmt.Sprintf("Information for Consumer %s > %s created %s", state.Stream, state.Name, f(state.Created)))
11361136
}
11371137

11381138
if !c.showStateOnly {

cli/kv_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ func (c *kvCommand) getAction(_ *fisk.ParseContext) error {
704704
return nil
705705
}
706706

707-
fmt.Printf("%s > %s revision: %d created @ %s\n", res.Bucket(), res.Key(), res.Revision(), res.Created().Format(time.RFC822))
707+
fmt.Printf("%s > %s revision: %d created @ %s\n", res.Bucket(), res.Key(), res.Revision(), f(res.Created()))
708708
fmt.Println()
709709
pv := iu.Base64IfNotPrintable(res.Value())
710710
lpv := len(pv)
@@ -987,7 +987,7 @@ func (c *kvCommand) showStatus(store jetstream.KeyValue) error {
987987
if nfo == nil {
988988
cols.SetHeading(fmt.Sprintf("Information for Key-Value Store Bucket %s", status.Bucket()))
989989
} else {
990-
cols.SetHeading(fmt.Sprintf("Information for Key-Value Store Bucket %s created %s", status.Bucket(), nfo.Created.Local().Format(time.RFC3339)))
990+
cols.SetHeading(fmt.Sprintf("Information for Key-Value Store Bucket %s created %s", status.Bucket(), f(nfo.Created)))
991991
}
992992

993993
cols.AddSectionTitle("Configuration")

cli/object_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (c *objCommand) showBucketInfo(store jetstream.ObjectStore) error {
318318
if nfo == nil {
319319
cols.SetHeading(fmt.Sprintf("Information for Object Store Bucket %s", status.Bucket()))
320320
} else {
321-
cols.SetHeading(fmt.Sprintf("Information for Object Store Bucket %s created %s", status.Bucket(), nfo.Created.Local().Format(time.RFC3339)))
321+
cols.SetHeading(fmt.Sprintf("Information for Object Store Bucket %s created %s", status.Bucket(), f(nfo.Created)))
322322
}
323323

324324
cols.AddSectionTitle("Configuration")
@@ -466,7 +466,7 @@ func (c *objCommand) lsAction(_ *fisk.ParseContext) error {
466466
table.AddHeaders("Name", "Size", "Time")
467467

468468
for _, i := range contents {
469-
table.AddRow(i.Name, humanize.IBytes(i.Size), i.ModTime.Format(time.RFC3339))
469+
table.AddRow(i.Name, humanize.IBytes(i.Size), f(i.ModTime))
470470
}
471471

472472
fmt.Println(table.Render())

cli/service_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (c *serviceCmd) echoHandler(req micro.Request) {
8383
hdr.Add("ConnectedUrl", c.nc.ConnectedUrlRedacted())
8484
hdr.Add("Handler", strconv.Itoa(os.Getpid()))
8585
hdr.Add("Subject", req.Subject())
86-
hdr.Add("Timestamp", time.Now().Format(time.RFC3339))
86+
hdr.Add("Timestamp", f(time.Now()))
8787
if c.nc.ConnectedClusterName() != "" {
8888
hdr.Add("ConnectedCluster", c.nc.ConnectedClusterName())
8989
}

cli/stream_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ func (c *streamCmd) viewAction(_ *fisk.ParseContext) error {
11521152
default:
11531153
meta, err := jsm.ParseJSMsgMetadata(msg)
11541154
if err == nil {
1155-
fmt.Printf("[%d] Subject: %s Received: %s\n", meta.StreamSequence(), msg.Subject, meta.TimeStamp().Format(time.RFC3339))
1155+
fmt.Printf("[%d] Subject: %s Received: %s\n", meta.StreamSequence(), msg.Subject, f(meta.TimeStamp()))
11561156
} else {
11571157
fmt.Printf("Subject: %s Reply: %s\n", msg.Subject, msg.Reply)
11581158
}

cli/sub_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ func (c *subCmd) printMsg(msg *nats.Msg, reply *nats.Msg, ctr uint, startTime ti
961961
fmt.Printf("[#%d]%s Received on %q\n", ctr, timeStamp, msg.Subject)
962962
}
963963
} else if c.jetStream {
964-
fmt.Printf("[#%d] Received JetStream message: stream: %s seq %d / subject: %s / time: %v\n", ctr, info.Stream(), info.StreamSequence(), msg.Subject, info.TimeStamp().UTC().Format(time.RFC3339))
964+
fmt.Printf("[#%d] Received JetStream message: stream: %s seq %d / subject: %s / time: %v\n", ctr, info.Stream(), info.StreamSequence(), msg.Subject, f(info.TimeStamp()))
965965
} else {
966966
fmt.Printf("[#%d] Received JetStream message: consumer: %s > %s / subject: %s / delivered: %d / consumer seq: %d / stream seq: %d\n", ctr, info.Stream(), info.Consumer(), msg.Subject, info.Delivered(), info.ConsumerSequence(), info.StreamSequence())
967967
}
@@ -976,7 +976,7 @@ func (c *subCmd) printMsg(msg *nats.Msg, reply *nats.Msg, ctr uint, startTime ti
976976
if info == nil {
977977
fmt.Printf("[#%d]%s Matched reply on %q\n", ctr, timeStamp, reply.Subject)
978978
} else if c.jetStream {
979-
fmt.Printf("[#%d] Matched reply JetStream message: stream: %s seq %d / subject: %s / time: %v\n", ctr, info.Stream(), info.StreamSequence(), reply.Subject, info.TimeStamp().Format(time.RFC3339))
979+
fmt.Printf("[#%d] Matched reply JetStream message: stream: %s seq %d / subject: %s / time: %v\n", ctr, info.Stream(), info.StreamSequence(), reply.Subject, f(info.TimeStamp()))
980980
} else {
981981
fmt.Printf("[#%d] Matched reply JetStream message: consumer: %s > %s / subject: %s / delivered: %d / consumer seq: %d / stream seq: %d\n", ctr, info.Stream(), info.Consumer(), reply.Subject, info.Delivered(), info.ConsumerSequence(), info.StreamSequence())
982982
}

nats/tests/sub_command_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func TestSubscribe(t *testing.T) {
218218
}
219219

220220
output := string(runNatsCli(t, fmt.Sprintf("--server='%s' sub --stream TEST_STREAM --last --count=1", srv.ClientURL())))
221-
pattern := `\[#\d\] Received JetStream message: stream: TEST_STREAM seq (\d+) / subject: TEST_STREAM.1 / time: \d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ`
221+
pattern := `\[#\d\] Received JetStream message: stream: TEST_STREAM seq (\d+) / subject: TEST_STREAM.1 / time: \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d`
222222
matcher := regexp.MustCompile(pattern)
223223
outputSlice := strings.Split(output, "\n")
224224

0 commit comments

Comments
 (0)