-
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?
Changes from all commits
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,7 @@ func tableKubernetesCustomResource(ctx context.Context) *plugin.Table { | |||||||
| activeVersion := ctx.Value(contextKey("ActiveVersion")).(string) | ||||||||
| versionSchemaSpec := ctx.Value(contextKey("VersionSchemaSpec")) | ||||||||
| versionSchemaStatus := ctx.Value(contextKey("VersionSchemaStatus")) | ||||||||
| versionSchemaReport := ctx.Value(contextKey("VersionSchemaReport")) | ||||||||
| tableName := ctx.Value(contextKey("TableName")).(string) | ||||||||
|
|
||||||||
| var description string | ||||||||
|
|
@@ -39,11 +40,11 @@ func tableKubernetesCustomResource(ctx context.Context) *plugin.Table { | |||||||
| List: &plugin.ListConfig{ | ||||||||
| Hydrate: listK8sCustomResources(ctx, crdName, resourceName, resourceNameSingular, groupName, activeVersion), | ||||||||
| }, | ||||||||
| Columns: k8sCRDResourceCommonColumns(getCustomResourcesDynamicColumns(ctx, versionSchemaSpec, versionSchemaStatus)), | ||||||||
| Columns: k8sCRDResourceCommonColumns(getCustomResourcesDynamicColumns(ctx, versionSchemaSpec, versionSchemaStatus, versionSchemaReport)), | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec interface{}, versionSchemaStatus interface{}) []*plugin.Column { | ||||||||
| func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec interface{}, versionSchemaStatus interface{},versionSchemaReport interface{}) []*plugin.Column { | ||||||||
| columns := []*plugin.Column{} | ||||||||
|
|
||||||||
| // default metadata columns | ||||||||
|
|
@@ -103,7 +104,32 @@ func getCustomResourcesDynamicColumns(ctx context.Context, versionSchemaSpec int | |||||||
| columns = append(columns, column) | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // add the report columns | ||||||||
| schemaReport := versionSchemaReport.(v1.JSONSchemaProps) | ||||||||
|
||||||||
| for k, v := range schemaReport.Properties { | ||||||||
| flag := 0 | ||||||||
| for _, reportColumn := range allColumns { | ||||||||
| if reportColumn == strcase.ToSnake(k) { | ||||||||
| flag = 1 | ||||||||
| column := &plugin.Column{ | ||||||||
| Name: "report_" + strcase.ToSnake(k), | ||||||||
| Description: v.Description, | ||||||||
| Transform: transform.FromP(extractReportProperty, k), | ||||||||
| } | ||||||||
| setDynamicColumns(v, column) | ||||||||
| columns = append(columns, column) | ||||||||
| } | ||||||||
| } | ||||||||
| if flag == 0 { | ||||||||
| column := &plugin.Column{ | ||||||||
| Name: strcase.ToSnake(k), | ||||||||
| Description: v.Description, | ||||||||
| Transform: transform.FromP(extractReportProperty, k), | ||||||||
| } | ||||||||
|
||||||||
| } | |
| } | |
| allColumns = append(allColumns, strcase.ToSnake(k)) |
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 ofversionSchemaStatus interface{},versionSchemaReport interface{}.