Use protojson in tctl for marshaling BotInstance resource (#55093)

* Use protojson in tctl for marshaling BotInstance resource

* Fix spelling
This commit is contained in:
Noah Stride
2025-05-27 08:37:36 +00:00
committed by GitHub
parent 057b52ff27
commit 565d610908
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -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")
}
+1 -1
View File
@@ -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
}