Skip to content

Commit

Permalink
chore(bd): Add support for display PATH in kubectl output (#367)
Browse files Browse the repository at this point in the history
add support for display PATH in `kubectl get bd` output
Cherry-picked PR: #366

Signed-off-by: chandan kumar <[email protected]>
  • Loading branch information
chandankumar4 authored Jan 30, 2020
1 parent c33cbb2 commit d617404
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/crds/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,34 @@ func (b *Builder) WithPrinterColumns(columnName, columnType, jsonPath string) *B
return b
}

// WithPriorityPrinterColumns is used to add printercolumns field to the CRD with priority field
func (b *Builder) WithPriorityPrinterColumns(columnName, columnType, jsonPath string, priority int32) *Builder {
if len(columnName) == 0 {
b.errs = append(b.errs,
errors.New("missing column name in additional printer columns"))
return b
}
if len(columnType) == 0 {
b.errs = append(b.errs,
errors.New("missing column type in additional printer columns"))
return b
}
if len(jsonPath) == 0 {
b.errs = append(b.errs,
errors.New("missing json path in additional printer columns"))
return b
}

printerColumn := apiext.CustomResourceColumnDefinition{
Name: columnName,
Type: columnType,
JSONPath: jsonPath,
Priority: priority,
}
b.crd.object.Spec.AdditionalPrinterColumns = append(b.crd.object.Spec.AdditionalPrinterColumns, printerColumn)
return b
}

// Build returns the CustomResourceDefinition from the builder
func (b *Builder) Build() (*apiext.CustomResourceDefinition, error) {
if len(b.errs) > 0 {
Expand Down
1 change: 1 addition & 0 deletions pkg/setup/build_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func buildBlockDeviceCRD() (*apiext.CustomResourceDefinition, error) {
WithPlural(apis.BlockDeviceResourcePlural).
WithShortNames([]string{apis.BlockDeviceResourceShort}).
WithPrinterColumns("NodeName", "string", ".spec.nodeAttributes.nodeName").
WithPriorityPrinterColumns("Path", "string", ".spec.path", 1).
WithPrinterColumns("Size", "string", ".spec.capacity.storage").
WithPrinterColumns("ClaimState", "string", ".status.claimState").
WithPrinterColumns("Status", "string", ".status.state").
Expand Down

0 comments on commit d617404

Please sign in to comment.