-
Notifications
You must be signed in to change notification settings - Fork 190
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 a configuration for additional_columns
at the Resource level
#378
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -317,6 +317,12 @@ type UpdateOperationConfig struct { | |||||
CustomMethodName string `json:"custom_method_name"` | ||||||
} | ||||||
|
||||||
type AdditionalColumnConfig struct { | ||||||
Name string `json:"name"` | ||||||
JSONPath string `json:"json_path"` | ||||||
Type string `json:"type"` | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Please include tiny comments for the struct and its fields. Those will be included in our generated GoDoc documentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
|
||||||
// PrintConfig informs instruct the code generator on how to sort kubebuilder | ||||||
// printcolumn marker coments. | ||||||
type PrintConfig struct { | ||||||
|
@@ -334,6 +340,10 @@ type PrintConfig struct { | |||||
AddSyncedColumn *bool `json:"add_synced_column"` | ||||||
// OrderBy is the field used to sort the list of PrinterColumn options. | ||||||
OrderBy string `json:"order_by"` | ||||||
|
||||||
// AdditionalColumns can be used to add arbitrary extra columns to a Resource's output | ||||||
// if present, should be a list of objects, each containing: name, json_path, and type | ||||||
AdditionalColumns []AdditionalColumnConfig `json:"additional_columns,omitempty"` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we make this a pointers array? if we do so
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
} | ||||||
|
||||||
// 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) { | |
crd.AddStatusField(memberNames, memberShapeRef) | ||
} | ||
|
||
// Now add the additional printer columns that have been defined explicitly | ||
// in additional_columns | ||
for _, additionalColumn := range m.cfg.GetAdditionalColumns(crdName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tiny suggestion: Shall we make this a private method? thinking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
printerColumn := &PrinterColumn{} | ||
printerColumn.Name = additionalColumn.Name | ||
printerColumn.JSONPath = additionalColumn.JSONPath | ||
printerColumn.Type = additionalColumn.Type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we should also set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
crd.additionalPrinterColumns = append(crd.additionalPrinterColumns, printerColumn) | ||
} | ||
|
||
crds = append(crds, crd) | ||
} | ||
sort.Slice(crds, func(i, j int) bool { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nil checks on slices are not super reliable in Go. The
len
built-in function is the most accurate one for this use case (it checks the nility first then size of the slice)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done