Skip to content

Commit

Permalink
add AGE column
Browse files Browse the repository at this point in the history
  • Loading branch information
cofyc committed Apr 13, 2020
1 parent da68386 commit 658dbe7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/to-crdgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package main
import (
"flag"
"fmt"
"os"

"github.com/pingcap/tidb-operator/pkg/to-crdgen/cmd"
"github.com/spf13/pflag"
"os"
)

func main() {
Expand Down
18 changes: 18 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ spec:
description: The desired replicas number of TiDB cluster
name: Desire
type: integer
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: pingcap.com
names:
kind: TidbCluster
Expand Down Expand Up @@ -7651,6 +7654,9 @@ spec:
name: Completed
priority: 1
type: date
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: pingcap.com
names:
kind: Backup
Expand Down Expand Up @@ -8492,6 +8498,9 @@ spec:
description: The time at which the restore was completed
name: Completed
type: date
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: pingcap.com
names:
kind: Restore
Expand Down Expand Up @@ -9344,6 +9353,9 @@ spec:
name: LastBackupTime
priority: 1
type: date
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: pingcap.com
names:
kind: BackupSchedule
Expand Down Expand Up @@ -10359,6 +10371,9 @@ spec:
name: Phase
priority: 1
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: pingcap.com
names:
kind: TidbInitializer
Expand Down Expand Up @@ -10461,6 +10476,9 @@ spec:
description: The minimal replicas of TiKV
name: TiKV-MinReplicas
type: integer
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: pingcap.com
names:
kind: TidbClusterAutoScaler
Expand Down
17 changes: 11 additions & 6 deletions pkg/util/crdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,24 @@ var (
Description: "The minimal replicas of TiDB",
JSONPath: ".spec.tidb.minReplicas",
}
ageColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
}
)

func init() {
tidbClusteradditionalPrinterColumns = append(tidbClusteradditionalPrinterColumns,
tidbClusterPDColumn, tidbClusterPDStorageColumn, tidbClusterPDReadyColumn, tidbClusterPDDesireColumn,
tidbClusterTiKVColumn, tidbClusterTiKVStorageColumn, tidbClusterTiKVReadyColumn, tidbClusterTiKVDesireColumn,
tidbClusterTiDBColumn, tidbClusterTiDBReadyColumn, tidbClusterTiDBDesireColumn)
backupAdditionalPrinterColumns = append(backupAdditionalPrinterColumns, backupPathColumn, backupBackupSizeColumn, backupCommitTSColumn, backupStartedColumn, backupCompletedColumn)
restoreAdditionalPrinterColumns = append(restoreAdditionalPrinterColumns, restoreStartedColumn, restoreCompletedColumn)
bksAdditionalPrinterColumns = append(bksAdditionalPrinterColumns, bksScheduleColumn, bksMaxBackups, bksLastBackup, bksLastBackupTime)
tidbInitializerPrinterColumns = append(tidbInitializerPrinterColumns, tidbInitializerPhase)
tidbClusterTiDBColumn, tidbClusterTiDBReadyColumn, tidbClusterTiDBDesireColumn, ageColumn)
backupAdditionalPrinterColumns = append(backupAdditionalPrinterColumns, backupPathColumn, backupBackupSizeColumn, backupCommitTSColumn, backupStartedColumn, backupCompletedColumn, ageColumn)
restoreAdditionalPrinterColumns = append(restoreAdditionalPrinterColumns, restoreStartedColumn, restoreCompletedColumn, ageColumn)
bksAdditionalPrinterColumns = append(bksAdditionalPrinterColumns, bksScheduleColumn, bksMaxBackups, bksLastBackup, bksLastBackupTime, ageColumn)
tidbInitializerPrinterColumns = append(tidbInitializerPrinterColumns, tidbInitializerPhase, ageColumn)
autoScalerPrinterColumns = append(autoScalerPrinterColumns, autoScalerTiDBMaxReplicasColumn, autoScalerTiDBMinReplicasColumn,
autoScalerTiKVMaxReplicasColumn, autoScalerTiKVMinReplicasColumn)
autoScalerTiKVMaxReplicasColumn, autoScalerTiKVMinReplicasColumn, ageColumn)
}

func NewCustomResourceDefinition(crdKind v1alpha1.CrdKind, group string, labels map[string]string, validation bool) *extensionsobj.CustomResourceDefinition {
Expand Down

0 comments on commit 658dbe7

Please sign in to comment.