From a52ab3a330a77a0b6fcea701d41f93964ea5b930 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 17:45:54 +0000 Subject: [PATCH] Show absolute timestamps instead of relative times in table output Table columns such as created_at and updated_at now print RFC3339 UTC timestamps, matching the format used elsewhere in the CLI, instead of relative times like "4 years ago". Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01LFArr2i5Bs3xWWh4SZhjKA --- internal/cmd/auditlog/auditlogs.go | 2 +- internal/cmd/backup/backup.go | 10 ++++---- internal/cmd/backup/policy.go | 8 +++--- internal/cmd/branch/branch.go | 8 +++--- internal/cmd/branch/query_patterns.go | 4 +-- internal/cmd/branch/resize.go | 4 +-- internal/cmd/branch/vtgate.go | 6 ++--- internal/cmd/database/database.go | 8 +++--- internal/cmd/database/ip_restriction.go | 4 +-- .../dedicatedreadreplica.go | 2 +- internal/cmd/insights/agent_runs.go | 2 +- internal/cmd/insights/agent_schedules.go | 2 +- internal/cmd/keyspace/keyspace.go | 4 +-- internal/cmd/keyspace/resize.go | 6 ++--- internal/cmd/keyspace/rollout_status.go | 4 +-- internal/cmd/maintenance/maintenance.go | 12 ++++----- internal/cmd/maintenance/windows.go | 8 +++--- internal/cmd/oidctrust/oidctrust.go | 2 +- internal/cmd/org/org.go | 4 +-- internal/cmd/pgbouncer/pgbouncer.go | 4 +-- internal/cmd/pgbouncer/resize.go | 4 +-- internal/cmd/pgbouncer/restart.go | 4 +-- internal/cmd/token/token.go | 16 ++++++------ .../cmd/trafficcontrol/traffic_control.go | 8 +++--- internal/cmd/webhook/webhook.go | 8 +++--- internal/cmd/workflow/list.go | 4 +-- internal/cmd/workflow/show.go | 4 +-- internal/printer/printer_test.go | 25 +++++++++++++++++++ 28 files changed, 101 insertions(+), 76 deletions(-) diff --git a/internal/cmd/auditlog/auditlogs.go b/internal/cmd/auditlog/auditlogs.go index f60ca39f8..d47f9be24 100644 --- a/internal/cmd/auditlog/auditlogs.go +++ b/internal/cmd/auditlog/auditlogs.go @@ -41,7 +41,7 @@ type AuditLog struct { Event string `header:"event" json:"type"` RemoteIP string `header:"remote_ip" json:"remote_ip"` Location string `header:"location" json:"location"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` orig *ps.AuditLog } diff --git a/internal/cmd/backup/backup.go b/internal/cmd/backup/backup.go index d1f894fbb..b3dbf5208 100644 --- a/internal/cmd/backup/backup.go +++ b/internal/cmd/backup/backup.go @@ -42,11 +42,11 @@ type Backup struct { State string `header:"state" json:"state"` Size int64 `header:"size" json:"size"` Protected bool `header:"protected" json:"protected"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` - StartedAt int64 `header:"started_at,timestamp(ms|utc|human)" json:"started_at"` - ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|human)" json:"expires_at"` - CompletedAt int64 `header:"completed_at,timestamp(ms|utc|human)" json:"completed_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` + StartedAt int64 `header:"started_at,timestamp(ms|utc|RFC3339)" json:"started_at"` + ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|RFC3339)" json:"expires_at"` + CompletedAt int64 `header:"completed_at,timestamp(ms|utc|RFC3339)" json:"completed_at"` orig *ps.Backup } diff --git a/internal/cmd/backup/policy.go b/internal/cmd/backup/policy.go index 41ad2076a..92f83cd3c 100644 --- a/internal/cmd/backup/policy.go +++ b/internal/cmd/backup/policy.go @@ -42,10 +42,10 @@ type BackupPolicy struct { ScheduleDay string `header:"schedule_day" json:"schedule_day"` ScheduleWeek string `header:"schedule_week" json:"schedule_week"` Required bool `header:"required" json:"required"` - LastRanAt *int64 `header:"last_ran_at,timestamp(ms|utc|human)" json:"last_ran_at"` - NextRunAt *int64 `header:"next_run_at,timestamp(ms|utc|human)" json:"next_run_at"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + LastRanAt *int64 `header:"last_ran_at,timestamp(ms|utc|RFC3339)" json:"last_ran_at"` + NextRunAt *int64 `header:"next_run_at,timestamp(ms|utc|RFC3339)" json:"next_run_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.BackupPolicy } diff --git a/internal/cmd/branch/branch.go b/internal/cmd/branch/branch.go index b35672a3b..28b844b58 100644 --- a/internal/cmd/branch/branch.go +++ b/internal/cmd/branch/branch.go @@ -96,8 +96,8 @@ type DatabaseBranch struct { Production bool `header:"production" json:"production"` SafeMigrations bool `header:"safe migrations" json:"safe_migrations"` Ready bool `header:"ready" json:"ready"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.DatabaseBranch } @@ -144,8 +144,8 @@ type PostgresBranch struct { Region string `header:"region" json:"region"` Production bool `header:"production" json:"production"` Ready bool `header:"ready" json:"ready"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.PostgresBranch } diff --git a/internal/cmd/branch/query_patterns.go b/internal/cmd/branch/query_patterns.go index c35b16b90..03bdd58c9 100644 --- a/internal/cmd/branch/query_patterns.go +++ b/internal/cmd/branch/query_patterns.go @@ -313,8 +313,8 @@ type queryPatternsReport struct { ID string `header:"id" json:"id"` State string `header:"state" json:"state"` Actor string `header:"actor" json:"actor"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - FinishedAt *int64 `header:"finished_at,timestamp(ms|utc|human)" json:"finished_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + FinishedAt *int64 `header:"finished_at,timestamp(ms|utc|RFC3339)" json:"finished_at"` orig *ps.QueryPatternsReport } diff --git a/internal/cmd/branch/resize.go b/internal/cmd/branch/resize.go index b7bf079c7..d80014dca 100644 --- a/internal/cmd/branch/resize.go +++ b/internal/cmd/branch/resize.go @@ -292,8 +292,8 @@ type postgresBranchResize struct { Replicas int `header:"replicas" json:"replicas"` Parameters string `header:"parameters" json:"parameters"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|human)" json:"completed_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|RFC3339)" json:"completed_at"` orig *ps.PostgresBranchClusterResizeRequest } diff --git a/internal/cmd/branch/vtgate.go b/internal/cmd/branch/vtgate.go index fa509ef14..09cf65029 100644 --- a/internal/cmd/branch/vtgate.go +++ b/internal/cmd/branch/vtgate.go @@ -54,9 +54,9 @@ type branchVTGateResize struct { VTGateMaxCount *int `header:"vtgate_max_count,n/a" json:"vtgate_max_count"` VTGateAutoscaling bool `header:"vtgate_autoscaling" json:"vtgate_autoscaling"` VTGateTargetCPUUtilization *int `header:"vtgate_target_cpu,n/a" json:"vtgate_target_cpu_utilization"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - StartedAt *int64 `header:"started_at,timestamp(ms|utc|human)" json:"started_at"` - CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|human)" json:"completed_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + StartedAt *int64 `header:"started_at,timestamp(ms|utc|RFC3339)" json:"started_at"` + CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|RFC3339)" json:"completed_at"` orig *ps.BranchResizeRequest } diff --git a/internal/cmd/database/database.go b/internal/cmd/database/database.go index 13ef14727..da2d0791b 100644 --- a/internal/cmd/database/database.go +++ b/internal/cmd/database/database.go @@ -48,8 +48,8 @@ type Databases []*databaseListItem type databaseListItem struct { Name string `header:"name" json:"name"` Kind string `header:"kind" json:"kind"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.Database } @@ -78,8 +78,8 @@ type Database struct { InsightsEnabled bool `header:"insights_enabled" json:"insights_enabled"` ProductionBranchWebConsole bool `header:"production_branch_web_console" json:"production_branch_web_console"` MultipleAdminsRequiredForDeletion bool `header:"multiple_admins_required_for_deletion" json:"multiple_admins_required_for_deletion"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.Database } diff --git a/internal/cmd/database/ip_restriction.go b/internal/cmd/database/ip_restriction.go index 07eb90594..4841c19b2 100644 --- a/internal/cmd/database/ip_restriction.go +++ b/internal/cmd/database/ip_restriction.go @@ -47,8 +47,8 @@ type IPRestrictionEntry struct { CIDRs string `header:"cidrs" json:"cidrs"` Description string `header:"description" json:"description"` Actor string `header:"actor" json:"actor"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.PostgresCIDR } diff --git a/internal/cmd/dedicatedreadreplica/dedicatedreadreplica.go b/internal/cmd/dedicatedreadreplica/dedicatedreadreplica.go index 3091bd189..ac1dfd883 100644 --- a/internal/cmd/dedicatedreadreplica/dedicatedreadreplica.go +++ b/internal/cmd/dedicatedreadreplica/dedicatedreadreplica.go @@ -65,7 +65,7 @@ type DedicatedReadReplica struct { Size string `header:"size" json:"size"` Replicas int `header:"replicas" json:"replicas"` Ready bool `header:"ready" json:"ready"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` orig *ps.PostgresDedicatedReadReplica } diff --git a/internal/cmd/insights/agent_runs.go b/internal/cmd/insights/agent_runs.go index e92cbd388..770136041 100644 --- a/internal/cmd/insights/agent_runs.go +++ b/internal/cmd/insights/agent_runs.go @@ -17,7 +17,7 @@ type AgentRunRow struct { State string `header:"state" json:"state"` Outcome string `header:"outcome" json:"outcome"` Title string `header:"title" json:"title"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` } // AgentRunsCmd lists a branch's Insights Agent runs. diff --git a/internal/cmd/insights/agent_schedules.go b/internal/cmd/insights/agent_schedules.go index 8eaa02404..c2b830280 100644 --- a/internal/cmd/insights/agent_schedules.go +++ b/internal/cmd/insights/agent_schedules.go @@ -20,7 +20,7 @@ type AgentScheduleRow struct { Day string `header:"day" json:"day"` Time string `header:"time" json:"schedule_time"` TimeZone string `header:"time_zone" json:"time_zone"` - NextRunAt *int64 `header:"next_run_at,timestamp(ms|utc|human)" json:"next_run_at"` + NextRunAt *int64 `header:"next_run_at,timestamp(ms|utc|RFC3339)" json:"next_run_at"` } // AgentSchedulesCmd lists a branch's Insights Agent schedules. diff --git a/internal/cmd/keyspace/keyspace.go b/internal/cmd/keyspace/keyspace.go index 7ca665af9..267cce1f8 100644 --- a/internal/cmd/keyspace/keyspace.go +++ b/internal/cmd/keyspace/keyspace.go @@ -48,8 +48,8 @@ type Keyspace struct { PendingResize bool `header:"pending_resize" json:"resize_pending"` ClusterSize string `header:"cluster_size" json:"cluster_name"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.Keyspace } diff --git a/internal/cmd/keyspace/resize.go b/internal/cmd/keyspace/resize.go index 365e4c3c4..9975ebf95 100644 --- a/internal/cmd/keyspace/resize.go +++ b/internal/cmd/keyspace/resize.go @@ -21,9 +21,9 @@ type KeyspaceResizeRequest struct { Replicas uint `header:"replicas" json:"replicas"` ExtraReplicas uint `header:"extra_replicas" json:"extra_replicas"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - StartedAt *int64 `header:"started_at,timestamp(ms|utc|human)" json:"started_at"` - CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|human)" json:"completed_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + StartedAt *int64 `header:"started_at,timestamp(ms|utc|RFC3339)" json:"started_at"` + CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|RFC3339)" json:"completed_at"` orig *ps.KeyspaceResizeRequest } diff --git a/internal/cmd/keyspace/rollout_status.go b/internal/cmd/keyspace/rollout_status.go index 4d4a4bf03..f6a4b0bda 100644 --- a/internal/cmd/keyspace/rollout_status.go +++ b/internal/cmd/keyspace/rollout_status.go @@ -65,8 +65,8 @@ type ShardRollout struct { Name string `header:"shard" json:"name"` State string `header:"state" json:"state"` - LastRolloutStartedAt *int64 `header:"started,timestamp(ms|utc|human)" json:"last_rollout_started_at"` - LastRolloutFinishedAt *int64 `header:"finished,timestamp(ms|utc|human)" json:"last_rollout_finished_at"` + LastRolloutStartedAt *int64 `header:"started,timestamp(ms|utc|RFC3339)" json:"last_rollout_started_at"` + LastRolloutFinishedAt *int64 `header:"finished,timestamp(ms|utc|RFC3339)" json:"last_rollout_finished_at"` orig *ps.ShardRollout } diff --git a/internal/cmd/maintenance/maintenance.go b/internal/cmd/maintenance/maintenance.go index b89f1d29a..c62530b0f 100644 --- a/internal/cmd/maintenance/maintenance.go +++ b/internal/cmd/maintenance/maintenance.go @@ -44,14 +44,14 @@ type MaintenanceSchedule struct { Week string `header:"week" json:"week"` HourUTC int `header:"hour_utc" json:"hour_utc"` DurationHours int `header:"duration_hours" json:"duration_hours"` - NextWindow int64 `header:"next_window,timestamp(ms|utc|human)" json:"next_window"` - LastWindow int64 `header:"last_window,timestamp(ms|utc|human)" json:"last_window"` + NextWindow int64 `header:"next_window,timestamp(ms|utc|RFC3339)" json:"next_window"` + LastWindow int64 `header:"last_window,timestamp(ms|utc|RFC3339)" json:"last_window"` PendingVitessVersion string `header:"pending_vitess" json:"pending_vitess"` PendingMySQLVersion string `header:"pending_mysql" json:"pending_mysql"` - ExpiresAt *int64 `header:"expires_at,timestamp(ms|utc|human)" json:"expires_at"` - DeadlineAt *int64 `header:"deadline_at,timestamp(ms|utc|human)" json:"deadline_at"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + ExpiresAt *int64 `header:"expires_at,timestamp(ms|utc|RFC3339)" json:"expires_at"` + DeadlineAt *int64 `header:"deadline_at,timestamp(ms|utc|RFC3339)" json:"deadline_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.MaintenanceSchedule } diff --git a/internal/cmd/maintenance/windows.go b/internal/cmd/maintenance/windows.go index 9d42cdd1f..cb9a0f303 100644 --- a/internal/cmd/maintenance/windows.go +++ b/internal/cmd/maintenance/windows.go @@ -65,10 +65,10 @@ func WindowsCmd(ch *cmdutil.Helper) *cobra.Command { // MaintenanceWindow is the human/JSON/CSV view of a maintenance window. type MaintenanceWindow struct { ID string `header:"id" json:"id"` - StartedAt *int64 `header:"started_at,timestamp(ms|utc|human)" json:"started_at"` - FinishedAt *int64 `header:"finished_at,timestamp(ms|utc|human)" json:"finished_at"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + StartedAt *int64 `header:"started_at,timestamp(ms|utc|RFC3339)" json:"started_at"` + FinishedAt *int64 `header:"finished_at,timestamp(ms|utc|RFC3339)" json:"finished_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.MaintenanceWindow } diff --git a/internal/cmd/oidctrust/oidctrust.go b/internal/cmd/oidctrust/oidctrust.go index bee83049d..2a5e5ba66 100644 --- a/internal/cmd/oidctrust/oidctrust.go +++ b/internal/cmd/oidctrust/oidctrust.go @@ -41,7 +41,7 @@ type OIDCTrust struct { MaxTTL int `header:"max ttl" json:"max_ttl_seconds"` Conditions string `header:"conditions" json:"conditions"` Accesses string `header:"accesses" json:"accesses"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` orig *ps.OIDCTrust } diff --git a/internal/cmd/org/org.go b/internal/cmd/org/org.go index c888844f1..01801cca5 100644 --- a/internal/cmd/org/org.go +++ b/internal/cmd/org/org.go @@ -30,8 +30,8 @@ func OrgCmd(ch *cmdutil.Helper) *cobra.Command { // organization returns a table-serializable database model. type organization struct { Name string `header:"name" json:"name"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` Current bool `header:"current" json:"current"` } diff --git a/internal/cmd/pgbouncer/pgbouncer.go b/internal/cmd/pgbouncer/pgbouncer.go index 2b521b2f5..430c8b1fd 100644 --- a/internal/cmd/pgbouncer/pgbouncer.go +++ b/internal/cmd/pgbouncer/pgbouncer.go @@ -47,8 +47,8 @@ type PgBouncer struct { Size string `header:"size" json:"size"` ReplicasPerCell int `header:"replicas_per_cell" json:"replicas_per_cell"` Actor string `header:"actor" json:"actor"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.PostgresBouncer } diff --git a/internal/cmd/pgbouncer/resize.go b/internal/cmd/pgbouncer/resize.go index 488c1a0a3..434fc7c85 100644 --- a/internal/cmd/pgbouncer/resize.go +++ b/internal/cmd/pgbouncer/resize.go @@ -332,8 +332,8 @@ type PgBouncerResize struct { Target string `header:"target" json:"target"` ReplicasPerCell int `header:"replicas_per_cell" json:"replicas_per_cell"` Actor string `header:"actor" json:"actor"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.PostgresBouncerResizeRequest } diff --git a/internal/cmd/pgbouncer/restart.go b/internal/cmd/pgbouncer/restart.go index 8887d175e..a599f1728 100644 --- a/internal/cmd/pgbouncer/restart.go +++ b/internal/cmd/pgbouncer/restart.go @@ -340,8 +340,8 @@ type PgBouncerRestart struct { State string `header:"state" json:"state"` Error string `header:"error" json:"error"` Actor string `header:"actor" json:"actor"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|human)" json:"completed_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|RFC3339)" json:"completed_at"` orig *ps.PostgresBouncerRestart } diff --git a/internal/cmd/token/token.go b/internal/cmd/token/token.go index 62156c7c9..ac61f0aee 100644 --- a/internal/cmd/token/token.go +++ b/internal/cmd/token/token.go @@ -55,11 +55,11 @@ type ServiceToken struct { ID string `header:"id" json:"id"` Name string `header:"name" json:"name"` CIDRs string `header:"cidrs"` - LastUsedAt int64 `header:"last_used_at,timestamp(ms|utc|human)" json:"last_used_at"` + LastUsedAt int64 `header:"last_used_at,timestamp(ms|utc|RFC3339)" json:"last_used_at"` LastUsedIP string `header:"last_used_ip" json:"last_used_ip"` LastUsedOrganization string `header:"last_used_organization" json:"last_used_organization"` - ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|human)" json:"expires_at"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|RFC3339)" json:"expires_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` orig *ps.ServiceToken } @@ -116,11 +116,11 @@ type ServiceTokenDetails struct { ID string `header:"id"` Name string `header:"name"` CIDRs string `header:"cidrs"` - LastUsedAt int64 `header:"last_used_at,timestamp(ms|utc|human)"` + LastUsedAt int64 `header:"last_used_at,timestamp(ms|utc|RFC3339)"` LastUsedIP string `header:"last_used_ip"` LastUsedOrganization string `header:"last_used_organization"` - ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|human)"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)"` + ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|RFC3339)"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)"` orig *ps.ServiceToken } @@ -169,8 +169,8 @@ type ServiceTokenWithSecret struct { Name string `header:"name" json:"name"` CIDRs string `header:"cidrs"` Token string `header:"token" json:"token"` - ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|human)" json:"expires_at"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + ExpiresAt int64 `header:"expires_at,timestamp(ms|utc|RFC3339)" json:"expires_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` orig *ps.ServiceToken } diff --git a/internal/cmd/trafficcontrol/traffic_control.go b/internal/cmd/trafficcontrol/traffic_control.go index 1d6d31682..6f1491e10 100644 --- a/internal/cmd/trafficcontrol/traffic_control.go +++ b/internal/cmd/trafficcontrol/traffic_control.go @@ -58,8 +58,8 @@ type TrafficBudget struct { Burst string `header:"burst" json:"burst"` Concurrency string `header:"concurrency" json:"concurrency"` WarningThreshold string `header:"warning_threshold" json:"warning_threshold"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.TrafficBudget } @@ -102,8 +102,8 @@ type TrafficRuleDisplay struct { Fingerprint string `header:"fingerprint" json:"fingerprint"` Keyspace string `header:"keyspace" json:"keyspace"` Tags string `header:"tags" json:"tags"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.TrafficRule } diff --git a/internal/cmd/webhook/webhook.go b/internal/cmd/webhook/webhook.go index d0a1b3005..19e6eca01 100644 --- a/internal/cmd/webhook/webhook.go +++ b/internal/cmd/webhook/webhook.go @@ -38,8 +38,8 @@ type Webhook struct { AuthorizationHeaderConfigured bool `header:"authorization header configured" json:"authorization_header_configured"` Events string `header:"events" json:"events"` Enabled bool `header:"enabled" json:"enabled"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.Webhook } @@ -78,8 +78,8 @@ type WebhookWithSecret struct { AuthorizationHeaderConfigured bool `header:"authorization header configured" json:"authorization_header_configured"` Events string `header:"events" json:"events"` Enabled bool `header:"enabled" json:"enabled"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|human)" json:"updated_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + UpdatedAt int64 `header:"updated_at,timestamp(ms|utc|RFC3339)" json:"updated_at"` orig *ps.Webhook } diff --git a/internal/cmd/workflow/list.go b/internal/cmd/workflow/list.go index b69761e08..70c59b922 100644 --- a/internal/cmd/workflow/list.go +++ b/internal/cmd/workflow/list.go @@ -57,8 +57,8 @@ type MinimalWorkflow struct { Number uint64 `header:"number"` Name string `header:"name"` State string `header:"state"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` - CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|human)" json:"completed_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` + CompletedAt *int64 `header:"completed_at,timestamp(ms|utc|RFC3339)" json:"completed_at"` Duration int64 `header:"duration,unixduration" json:"duration"` orig *ps.Workflow diff --git a/internal/cmd/workflow/show.go b/internal/cmd/workflow/show.go index 07636b5c8..7c758414b 100644 --- a/internal/cmd/workflow/show.go +++ b/internal/cmd/workflow/show.go @@ -70,14 +70,14 @@ type Workflow struct { SourceKeyspace string `header:"source keyspace"` TargetKeyspace string `header:"target keyspace"` - CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` CopyDuration int64 `header:"copy duration,unixduration"` Duration int64 `header:"total duration,unixduration" json:"duration"` TrafficServing string `header:"traffic serving"` - FinishedAt *int64 `header:"finished at,timestamp(ms|utc|human)" json:"finished_at"` + FinishedAt *int64 `header:"finished at,timestamp(ms|utc|RFC3339)" json:"finished_at"` orig *ps.Workflow } diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index e9d31d31c..372781d50 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -4,6 +4,7 @@ import ( "bytes" "strings" "testing" + "time" ) type nilCellRow struct { @@ -64,3 +65,27 @@ func TestPrintJSONDoesNotEscapeHTMLPlaceholders(t *testing.T) { t.Fatalf("expected no escaped angle brackets, got %s", got) } } + +type timestampRow struct { + Name string `header:"name" json:"name"` + CreatedAt int64 `header:"created_at,timestamp(ms|utc|RFC3339)" json:"created_at"` +} + +func TestPrintResourceShowsAbsoluteTimestamps(t *testing.T) { + format := Human + var out bytes.Buffer + p := NewPrinter(&format) + p.SetResourceOutput(&out) + + row := ×tampRow{Name: "main", CreatedAt: GetMilliseconds(time.Date(2022, time.March, 4, 15, 4, 5, 0, time.UTC))} + if err := p.PrintResource(row); err != nil { + t.Fatalf("print resource: %v", err) + } + + if !strings.Contains(out.String(), "2022-03-04T15:04:05Z") { + t.Fatalf("expected an RFC3339 timestamp, got %q", out.String()) + } + if strings.Contains(out.String(), "ago") { + t.Fatalf("expected no relative time, got %q", out.String()) + } +}