iinitialize message only when at least one manifest is kept

This commit is contained in:
Federico Gimenez 2017-11-30 08:49:48 +01:00
parent 93bce130fb
commit a607fe798d
1 changed files with 4 additions and 1 deletions

View File

@ -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