mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-08-19 04:06:29 +00:00
Omit empty results, make pretty output less verbose (#767)
* Pretty output: remove 2 leading line breaks and 1 trailing after container results Signed-off-by: Igor Beliakov <demtis.register@gmail.com> * validator: don't add empty results in ApplyAllSchemaChecksToAllResources Signed-off-by: Igor Beliakov <demtis.register@gmail.com> * Fix MockPod() fixture: - Since now result is considered non-empty only if Kind and Name are set, needed to adjust MockPod() to make it contain Name. Signed-off-by: Igor Beliakov <demtis.register@gmail.com> Co-authored-by: Robert Brennan <accounts@rbren.io>
This commit is contained in:
co-authored by
Robert Brennan
parent
6b64369698
commit
01dd7b7b68
@@ -188,7 +188,7 @@ func fillString(id string, l int) string {
|
||||
// GetPrettyOutput returns a human-readable string
|
||||
func (res AuditData) GetPrettyOutput(useColor bool) string {
|
||||
color.NoColor = !useColor
|
||||
str := titleColor.Sprint(fmt.Sprintf("\n\nPolaris audited %s %s at %s\n", res.SourceType, res.SourceName, res.AuditTime))
|
||||
str := titleColor.Sprint(fmt.Sprintf("Polaris audited %s %s at %s\n", res.SourceType, res.SourceName, res.AuditTime))
|
||||
str += color.CyanString(fmt.Sprintf(" Nodes: %d | Namespaces: %d | Controllers: %d\n", res.ClusterInfo.Nodes, res.ClusterInfo.Namespaces, res.ClusterInfo.Controllers))
|
||||
str += color.GreenString(fmt.Sprintf(" Final score: %d\n", res.Score))
|
||||
str += "\n"
|
||||
@@ -217,7 +217,7 @@ func (res Result) GetPrettyOutput() string {
|
||||
func (res PodResult) GetPrettyOutput() string {
|
||||
str := res.Results.GetPrettyOutput()
|
||||
for _, cont := range res.ContainerResults {
|
||||
str += cont.GetPrettyOutput() + "\n"
|
||||
str += cont.GetPrettyOutput()
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
@@ -173,7 +173,9 @@ func ApplyAllSchemaChecksToAllResources(conf *config.Configuration, resourceProv
|
||||
if err != nil {
|
||||
return results, err
|
||||
}
|
||||
results = append(results, result)
|
||||
if result.Kind != "" && result.Name != "" {
|
||||
results = append(results, result)
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ func MockContainer(name string) corev1.Container {
|
||||
func MockPod() corev1.Pod {
|
||||
c1 := MockContainer("test")
|
||||
p := corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test",
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
c1,
|
||||
|
||||
Reference in New Issue
Block a user