Skip to content

Commit

Permalink
Add Analysis section to describe views for relevant resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravkghildiyal committed May 5, 2024
1 parent 31498de commit b4a17ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gwctl/pkg/printer/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ func (bp *BackendsPrinter) PrintDescribeView(resourceModel *resourcediscovery.Re
pairs = append(pairs, &DescriberKV{Key: "ReferenceGrants", Value: names})
}

// Analysis
if len(backendNode.Errors) != 0 {
pairs = append(pairs, &DescriberKV{Key: "Analysis", Value: convertErrorsToString(backendNode.Errors)})
}

// Events
pairs = append(pairs, &DescriberKV{Key: "Events", Value: convertEventsSliceToTable(backendNode.Events, bp.Clock)})

Expand Down
8 changes: 8 additions & 0 deletions gwctl/pkg/printer/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ func convertPolicyRefsToTable(policyRefs []common.ObjRef) *Table {
return table
}

func convertErrorsToString(errors []error) []string {
var result []string
for _, err := range errors {
result = append(result, err.Error())
}
return result
}

type NodeResource interface {
ClientObject() client.Object
}
Expand Down
5 changes: 5 additions & 0 deletions gwctl/pkg/printer/gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func (gp *GatewaysPrinter) PrintDescribeView(resourceModel *resourcediscovery.Re
pairs = append(pairs, &DescriberKV{Key: "EffectivePolicies", Value: gatewayNode.EffectivePolicies})
}

// Analysis
if len(gatewayNode.Errors) != 0 {
pairs = append(pairs, &DescriberKV{Key: "Analysis", Value: convertErrorsToString(gatewayNode.Errors)})
}

// Events
pairs = append(pairs, &DescriberKV{Key: "Events", Value: convertEventsSliceToTable(gatewayNode.Events, gp.Clock)})

Expand Down

0 comments on commit b4a17ba

Please sign in to comment.