mirror of
https://github.com/gravitational/teleport.git
synced 2026-09-24 16:17:11 +08:00
Use protojson in tctl for marshaling BotInstance resource (#55093)
* Use protojson in tctl for marshaling BotInstance resource * Fix spelling
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user