Commit a607fe79 authored by Federico Gimenez's avatar Federico Gimenez

iinitialize message only when at least one manifest is kept

parent 93bce130
......@@ -59,7 +59,7 @@ func filterManifestsToKeep(manifests []Manifest) ([]Manifest, []Manifest) {
}
func summarizeKeptManifests(manifests []Manifest, kubeClient environment.KubeClient, namespace string) string {
message := "These resources were kept due to the resource policy:\n"
var message string
for _, m := range manifests {
// check if m is in fact present from k8s client's POV.
output, err := kubeClient.Get(namespace, bytes.NewBufferString(m.Content))
......@@ -68,6 +68,9 @@ func summarizeKeptManifests(manifests []Manifest, kubeClient environment.KubeCli
}
details := "[" + m.Head.Kind + "] " + m.Head.Metadata.Name + "\n"
if message == "" {
message = "These resources were kept due to the resource policy:\n"
}
message = message + details
}
return message
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment