From 565d6109085c8a9ccfeda642307c93eab2cb32f7 Mon Sep 17 00:00:00 2001 From: Noah Stride Date: Tue, 27 May 2025 09:37:36 +0100 Subject: [PATCH] Use protojson in tctl for marshaling BotInstance resource (#55093) * Use protojson in tctl for marshaling BotInstance resource * Fix spelling --- tool/tctl/common/bots_command.go | 10 +++++++++- tool/tctl/common/collection.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tool/tctl/common/bots_command.go b/tool/tctl/common/bots_command.go index 58bd3a18e6a..12cc6f88887 100644 --- a/tool/tctl/common/bots_command.go +++ b/tool/tctl/common/bots_command.go @@ -581,7 +581,15 @@ func (c *BotsCommand) ListBotInstances(ctx context.Context, client *authclient.C } if c.format == teleport.JSON { - err := utils.WriteJSONArray(c.stdout, instances) + // Wrap resource type so the correct protojson marshaling is used for + // timestamp fields. + wrappedInstances := make([]types.Resource, 0, len(instances)) + for _, instance := range instances { + wrappedInstances = append( + wrappedInstances, types.ProtoResource153ToLegacy(instance), + ) + } + err := utils.WriteJSONArray(c.stdout, wrappedInstances) if err != nil { return trace.Wrap(err, "failed to marshal bot instances") } diff --git a/tool/tctl/common/collection.go b/tool/tctl/common/collection.go index b5129476258..070102c320d 100644 --- a/tool/tctl/common/collection.go +++ b/tool/tctl/common/collection.go @@ -1766,7 +1766,7 @@ type botInstanceCollection struct { func (c *botInstanceCollection) resources() []types.Resource { r := make([]types.Resource, 0, len(c.items)) for _, resource := range c.items { - r = append(r, types.Resource153ToLegacy(resource)) + r = append(r, types.ProtoResource153ToLegacy(resource)) } return r }