File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,19 @@ type PrefixConfig struct {
7474 StatusField string `json:"status_field,omitempty"`
7575}
7676
77+ // GetAdditionalColumns extracts AdditionalColumns defined for a given Resource
78+ func (c * Config ) GetAdditionalColumns (resourceName string ) []AdditionalColumnConfig {
79+ if c == nil {
80+ return []AdditionalColumnConfig {}
81+ }
82+
83+ resourceConfig , ok := c .Resources [resourceName ]
84+ if ! ok || resourceConfig .Print == nil || resourceConfig .Print .AdditionalColumns == nil {
85+ return []AdditionalColumnConfig {}
86+ }
87+ return resourceConfig .Print .AdditionalColumns
88+ }
89+
7790// GetCustomListFieldMembers finds all of the custom list fields that need to
7891// be generated as defined in the generator config.
7992func (c * Config ) GetCustomListFieldMembers () []string {
Original file line number Diff line number Diff line change @@ -317,6 +317,12 @@ type UpdateOperationConfig struct {
317317 CustomMethodName string `json:"custom_method_name"`
318318}
319319
320+ type AdditionalColumnConfig struct {
321+ Name string `json:"name"`
322+ JSONPath string `json:"json_path"`
323+ Type string `json:"type"`
324+ }
325+
320326// PrintConfig informs instruct the code generator on how to sort kubebuilder
321327// printcolumn marker coments.
322328type PrintConfig struct {
@@ -334,6 +340,9 @@ type PrintConfig struct {
334340 AddSyncedColumn * bool `json:"add_synced_column"`
335341 // OrderBy is the field used to sort the list of PrinterColumn options.
336342 OrderBy string `json:"order_by"`
343+
344+ // TODO(jlajco) connect this with CRD.additionalPrinterColumns
345+ AdditionalColumns []AdditionalColumnConfig `json:"additional_columns,omitempty"`
337346}
338347
339348// ReconcileConfig describes options for controlling the reconciliation
Original file line number Diff line number Diff line change @@ -284,6 +284,16 @@ func (m *Model) GetCRDs() ([]*CRD, error) {
284284 crd .AddStatusField (memberNames , memberShapeRef )
285285 }
286286
287+ // Now add the additional printer columns that have been defined explicitly
288+ // in additional_columns
289+ for _ , additionalColumn := range m .cfg .GetAdditionalColumns (crdName ) {
290+ printerColumn := & PrinterColumn {}
291+ printerColumn .Name = additionalColumn .Name
292+ printerColumn .JSONPath = additionalColumn .JSONPath
293+ printerColumn .Type = additionalColumn .Type
294+ crd .additionalPrinterColumns = append (crd .additionalPrinterColumns , printerColumn )
295+ }
296+
287297 crds = append (crds , crd )
288298 }
289299 sort .Slice (crds , func (i , j int ) bool {
You can’t perform that action at this time.
0 commit comments