Skip to content

Commit

Permalink
fix: add nil pointer check for scope in table conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Choudhary <[email protected]>
  • Loading branch information
vishal-chdhry committed Feb 7, 2024
1 parent 795eb50 commit 6910c8a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/api/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ func addPolicyReportToTable(table *metav1beta1.Table, polrs ...v1alpha2.PolicyRe
}
row := make([]interface{}, 0, len(table.ColumnDefinitions))
row = append(row, polr.Name)
row = append(row, polr.Scope.Kind)
row = append(row, polr.Scope.Name)

if polr.Scope == nil {
row = append(row, "")
row = append(row, "")
} else {
row = append(row, polr.Scope.Kind)
row = append(row, polr.Scope.Name)
}

row = append(row, polr.Summary.Pass)
row = append(row, polr.Summary.Fail)
row = append(row, polr.Summary.Warn)
Expand Down Expand Up @@ -68,8 +75,15 @@ func addClusterPolicyReportToTable(table *metav1beta1.Table, cpolrs ...v1alpha2.
}
row := make([]interface{}, 0, len(table.ColumnDefinitions))
row = append(row, cpolr.Name)
row = append(row, cpolr.Scope.Kind)
row = append(row, cpolr.Scope.Name)

if cpolr.Scope == nil {
row = append(row, "")
row = append(row, "")
} else {
row = append(row, cpolr.Scope.Kind)
row = append(row, cpolr.Scope.Name)
}

row = append(row, cpolr.Summary.Pass)
row = append(row, cpolr.Summary.Fail)
row = append(row, cpolr.Summary.Warn)
Expand Down

0 comments on commit 6910c8a

Please sign in to comment.