Skip to content

Commit

Permalink
Use version and additional columns for crds (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Jul 11, 2018
1 parent f3ec9a1 commit f7976e7
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 41 deletions.
97 changes: 94 additions & 3 deletions apis/stash/v1alpha1/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,147 @@ var (
func (c Restic) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Plural: ResourcePluralRestic,
Singular: ResourceSingularRestic,
Kind: ResourceKindRestic,
ShortNames: []string{"rst"},
ResourceScope: string(apiextensions.NamespaceScoped),
Versions: []apiextensions.CustomResourceDefinitionVersion{
{
Name: SchemeGroupVersion.Version,
Served: true,
Storage: true,
},
},
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "stash"},
},
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Restic",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: EnableStatusSubresource,
AdditionalPrinterColumns: []apiextensions.CustomResourceColumnDefinition{
{
Name: "Selector",
Type: "string",
JSONPath: ".spec.selector",
},
{
Name: "Schedule",
Type: "string",
JSONPath: ".spec.schedule",
},
{
Name: "BackupType",
Type: "string",
JSONPath: ".spec.type",
Priority: 10,
},
{
Name: "Paused",
Type: "boolean",
JSONPath: ".spec.paused",
},
{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
},
},
})
}

func (c Recovery) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Plural: ResourcePluralRecovery,
Singular: ResourceSingularRecovery,
Kind: ResourceKindRecovery,
ShortNames: []string{"rec"},
ResourceScope: string(apiextensions.NamespaceScoped),
Versions: []apiextensions.CustomResourceDefinitionVersion{
{
Name: SchemeGroupVersion.Version,
Served: true,
Storage: true,
},
},
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "stash"},
},
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Recovery",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: EnableStatusSubresource,
AdditionalPrinterColumns: []apiextensions.CustomResourceColumnDefinition{
{
Name: "RepositoryNamespace",
Type: "string",
JSONPath: ".spec.repository.namespace",
},
{
Name: "RepositoryName",
Type: "string",
JSONPath: ".spec.repository.name",
},
{
Name: "Snapshot",
Type: "string",
JSONPath: ".spec.snapshot",
},
{
Name: "Phase",
Type: "string",
JSONPath: ".status.phase",
},
{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
},
},
})
}

func (c Repository) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Plural: ResourcePluralRepository,
Singular: ResourceSingularRepository,
Kind: ResourceKindRepository,
ShortNames: []string{"repo"},
ResourceScope: string(apiextensions.NamespaceScoped),
Versions: []apiextensions.CustomResourceDefinitionVersion{
{
Name: SchemeGroupVersion.Version,
Served: true,
Storage: true,
},
},
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "stash"},
},
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Repository",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: EnableStatusSubresource,
AdditionalPrinterColumns: []apiextensions.CustomResourceColumnDefinition{
{
Name: "BackupCount",
Type: "integer",
JSONPath: ".status.backupCount",
},
{
Name: "LastSuccessfulBackup",
Type: "date",
JSONPath: ".status.lastSuccessfulBackupTime",
Format: "date-time",
},
{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
},
},
})
}
56 changes: 56 additions & 0 deletions apis/stash/v1alpha1/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ metadata:
app: stash
name: restics.stash.appscode.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.selector
name: Selector
type: string
- JSONPath: .spec.schedule
name: Schedule
type: string
- JSONPath: .spec.type
name: BackupType
priority: 10
type: string
- JSONPath: .spec.paused
name: Paused
type: boolean
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: stash.appscode.com
names:
kind: Restic
Expand Down Expand Up @@ -1564,6 +1581,10 @@ spec:
- mountPath
type: array
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
Expand All @@ -1573,6 +1594,22 @@ metadata:
app: stash
name: recoveries.stash.appscode.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.repository.namespace
name: RepositoryNamespace
type: string
- JSONPath: .spec.repository.name
name: RepositoryName
type: string
- JSONPath: .spec.snapshot
name: Snapshot
type: string
- JSONPath: .status.phase
name: Phase
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: stash.appscode.com
names:
kind: Recovery
Expand Down Expand Up @@ -2996,6 +3033,10 @@ spec:
type: string
type: array
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
Expand All @@ -3005,6 +3046,17 @@ metadata:
app: stash
name: repositories.stash.appscode.com
spec:
additionalPrinterColumns:
- JSONPath: .status.backupCount
name: BackupCount
type: integer
- JSONPath: .status.lastSuccessfulBackupTime
format: date-time
name: LastSuccessfulBackup
type: date
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: stash.appscode.com
names:
kind: Repository
Expand Down Expand Up @@ -4424,3 +4476,7 @@ spec:
format: date-time
type: string
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
4 changes: 2 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 26 additions & 36 deletions vendor/github.com/appscode/kutil/apiextensions/v1beta1/cli-utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/appscode/kutil/openapi/render.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7976e7

Please sign in to comment.