Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AGE column for all CRDs #2168

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TidbMonitor is missed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no additionalPrinterColumns for TidbMonitor, so it will use the default (NAME and AGE)

$ kubectl get tidbmonitor
NAME    AGE
basic   23s

Maybe we can set it explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way, we can configure some useful columns for TidbMonitor CR. I've created an issue for this. #2169

name: Age
type: date
group: pingcap.com
names:
kind: TidbCluster
Expand Down Expand Up @@ -7748,6 +7751,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 @@ -8589,6 +8595,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 @@ -9441,6 +9450,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 @@ -10456,6 +10468,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 @@ -10558,6 +10573,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