From 125e8dad459c44079982798b1fdd0ac37bacc087 Mon Sep 17 00:00:00 2001 From: Gustavo Caso Date: Mon, 13 Nov 2023 17:28:31 +0100 Subject: [PATCH] remove inderection for security agent status --- pkg/status/render/render.go | 22 +++---------------- pkg/status/render/templates/compliance.tmpl | 8 +++---- .../render/templates/runtimesecurity.tmpl | 4 ++-- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/pkg/status/render/render.go b/pkg/status/render/render.go index d15778fe6c6cbf..7805edb2fa768e 100644 --- a/pkg/status/render/render.go +++ b/pkg/status/render/render.go @@ -141,9 +141,7 @@ func FormatSecurityAgentStatus(data []byte) (string, error) { if renderError != "" || err != nil { return renderError, err } - runnerStats := stats["runnerStats"] - complianceChecks := stats["complianceChecks"] - complianceStatus := stats["complianceStatus"] + title := fmt.Sprintf("Datadog Security Agent (v%s)", stats["version"]) stats["title"] = title @@ -152,10 +150,10 @@ func FormatSecurityAgentStatus(data []byte) (string, error) { if err := renderStatusTemplate(b, "/header.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderRuntimeSecurityStats(b, stats["runtimeSecurityStatus"]); err != nil { + if err := renderStatusTemplate(b, "/runtimesecurity.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderComplianceChecksStats(b, runnerStats, complianceChecks, complianceStatus); err != nil { + if err := renderStatusTemplate(b, "/compliance.tmpl", stats); err != nil { errs = append(errs, err) } if err := renderErrors(b, errs); err != nil { @@ -219,20 +217,6 @@ func FormatCheckStats(data []byte) (string, error) { return b.String(), nil } -func renderComplianceChecksStats(w io.Writer, runnerStats interface{}, complianceChecks, complianceStatus interface{}) error { - checkStats := make(map[string]interface{}) - checkStats["RunnerStats"] = runnerStats - checkStats["ComplianceStatus"] = complianceStatus - checkStats["ComplianceChecks"] = complianceChecks - return renderStatusTemplate(w, "/compliance.tmpl", checkStats) -} - -func renderRuntimeSecurityStats(w io.Writer, runtimeSecurityStatus interface{}) error { - status := make(map[string]interface{}) - status["RuntimeSecurityStatus"] = runtimeSecurityStatus - return renderStatusTemplate(w, "/runtimesecurity.tmpl", status) -} - //go:embed templates var templatesFS embed.FS diff --git a/pkg/status/render/templates/compliance.tmpl b/pkg/status/render/templates/compliance.tmpl index 44e6b3165d5828..29656b7100fc96 100644 --- a/pkg/status/render/templates/compliance.tmpl +++ b/pkg/status/render/templates/compliance.tmpl @@ -1,10 +1,10 @@ ========== Compliance ========== -{{ if not .ComplianceStatus}} +{{ if not .complianceStatus}} Not enabled {{- else}} - {{- with .ComplianceStatus}} + {{- with .complianceStatus}} {{ if .endpoints }} {{- range $endpoint := .endpoints }} {{ $endpoint }} @@ -14,8 +14,8 @@ Compliance Checks ====== - {{ $runnerStats := .RunnerStats }} - {{- range $Check := .ComplianceChecks }} + {{ $runnerStats := .runnerStats }} + {{- range $Check := .complianceChecks }} {{ $Check.Name }} {{printDashes $Check.Name "-"}} Framework: {{ $Check.Framework }} ({{ $Check.Version }}) diff --git a/pkg/status/render/templates/runtimesecurity.tmpl b/pkg/status/render/templates/runtimesecurity.tmpl index e98d80cf0884cc..05789370a46c99 100644 --- a/pkg/status/render/templates/runtimesecurity.tmpl +++ b/pkg/status/render/templates/runtimesecurity.tmpl @@ -2,10 +2,10 @@ Runtime Security ================ -{{- if not .RuntimeSecurityStatus}} +{{- if not .runtimeSecurityStatus}} Not enabled {{- else}} - {{- with .RuntimeSecurityStatus}} + {{- with .runtimeSecurityStatus}} {{ if .endpoints }} {{- range $endpoint := .endpoints }} {{ $endpoint }}