-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add support for .report root field in CRD plugin (#322) #343
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds support for the .report root field in custom resource definitions (CRDs), following the same pattern as the existing .spec and .status fields. This enables Kubernetes CRD plugins to extract and expose report-level properties as columns in Steampipe tables.
Key Changes:
- Added support for extracting and displaying report fields from custom resources
- Implemented column generation logic for report properties with prefix handling
- Added new
extractReportPropertyfunction to retrieve report field values
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec interface{}, versionSchemaStatus interface{}) []*plugin.Column { | ||
| func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec interface{}, versionSchemaStatus interface{},versionSchemaReport interface{}) []*plugin.Column { |
Copilot
AI
Dec 2, 2025
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.
Missing space after comma in function parameter list. Should be versionSchemaStatus interface{}, versionSchemaReport interface{} instead of versionSchemaStatus interface{},versionSchemaReport interface{}.
| func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec interface{}, versionSchemaStatus interface{},versionSchemaReport interface{}) []*plugin.Column { | |
| func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec interface{}, versionSchemaStatus interface{}, versionSchemaReport interface{}) []*plugin.Column { |
| } | ||
|
|
||
| // add the report columns | ||
| schemaReport := versionSchemaReport.(v1.JSONSchemaProps) |
Copilot
AI
Dec 2, 2025
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.
Potential panic due to type assertion without nil check. If versionSchemaReport is nil, this type assertion will panic. Consider adding a nil check similar to the existing pattern or handling the case where report schema might not be present in the CRD:
if versionSchemaReport != nil {
schemaReport := versionSchemaReport.(v1.JSONSchemaProps)
// ... rest of the report columns logic
}| Name: strcase.ToSnake(k), | ||
| Description: v.Description, | ||
| Transform: transform.FromP(extractReportProperty, k), | ||
| } |
Copilot
AI
Dec 2, 2025
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.
The report columns logic does not update the allColumns slice when a new column is added (flag == 0), unlike the spec columns logic at line 75. This could lead to duplicate column names if subsequent sections (like report) have properties that overlap with earlier sections. Consider adding:
if flag == 0 {
column := &plugin.Column{
Name: strcase.ToSnake(k),
Description: v.Description,
Transform: transform.FromP(extractReportProperty, k),
}
allColumns = append(allColumns, strcase.ToSnake(k)) // Add this line
setDynamicColumns(v, column)
columns = append(columns, column)
}| } | |
| } | |
| allColumns = append(allColumns, strcase.ToSnake(k)) |
Example query results
Results