Skip to content

Commit

Permalink
remove inderection for security agent status
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Nov 17, 2023
1 parent f18ca9c commit 747e70e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
22 changes: 3 additions & 19 deletions pkg/status/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions pkg/status/render/templates/compliance.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
==========
Compliance
==========
{{ if not .ComplianceStatus}}
{{ if not .complianceStatus}}
Not enabled
{{- else}}
{{- with .ComplianceStatus}}
{{- with .complianceStatus}}
{{ if .endpoints }}
{{- range $endpoint := .endpoints }}
{{ $endpoint }}
Expand All @@ -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 }})
Expand Down
4 changes: 2 additions & 2 deletions pkg/status/render/templates/runtimesecurity.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 747e70e

Please sign in to comment.