Skip to content

Commit cac5654

Browse files
authored
Add a new config to override kubebuilder:printcolumn priority (#86)
Issue aws-controllers-k8s/community#821 Description of changes: This patch introduces a new config field called "Standard" under `PrintFieldConfig` to indicates whether the column is of priority 0 or 1. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent e8cba6c commit cac5654

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

pkg/generate/config/field.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ type PrintFieldConfig struct {
124124
// include the field in `kubectl get` response. This field is generally used
125125
// to override very long and redundant columns names.
126126
Name string `json:"name"`
127+
// Priority differentiates between fields/columns shown in standard view or wide
128+
// view (using the -o wide flag). Fields with priority 0 are shown in standard view.
129+
// Fields with priority greater than 0 are only shown in wide view. Default is 0
130+
Priority int `json:"priority"`
127131
}
128132

129133
// FieldConfig contains instructions to the code generator about how

pkg/model/printer_column.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type PrinterColumn struct {
2424
CRD *CRD
2525
Name string
2626
Type string
27+
Priority int
2728
JSONPath string
2829
}
2930

@@ -140,6 +141,7 @@ func (r *CRD) addPrintableColumn(
140141
CRD: r,
141142
Name: name,
142143
Type: printColumnType,
144+
Priority: field.FieldConfig.Print.Priority,
143145
JSONPath: jsonPath,
144146
}
145147
r.additionalPrinterColumns = append(r.additionalPrinterColumns, column)

templates/apis/crd.go.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type {{ .CRD.Kind }}Status struct {
4848
// +kubebuilder:object:root=true
4949
// +kubebuilder:subresource:status
5050
{{- range $column := .CRD.AdditionalPrinterColumns }}
51-
// +kubebuilder:printcolumn:name="{{$column.Name}}",type={{$column.Type}},JSONPath=`{{$column.JSONPath}}`
51+
// +kubebuilder:printcolumn:name="{{$column.Name}}",type={{$column.Type}},priority={{$column.Priority}},JSONPath=`{{$column.JSONPath}}`
5252
{{- end }}
5353
{{- if .CRD.ShortNames }}
5454
// +kubebuilder:resource:shortName={{ Join .CRD.ShortNames ";" }}

0 commit comments

Comments
 (0)