iinitialize message only when at least one manifest is kept

pull/3131/head
Federico Gimenez 7 years ago
parent 93bce130fb
commit a607fe798d

@ -59,7 +59,7 @@ func filterManifestsToKeep(manifests []Manifest) ([]Manifest, []Manifest) {
} }
func summarizeKeptManifests(manifests []Manifest, kubeClient environment.KubeClient, namespace string) string { 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 { for _, m := range manifests {
// check if m is in fact present from k8s client's POV. // check if m is in fact present from k8s client's POV.
output, err := kubeClient.Get(namespace, bytes.NewBufferString(m.Content)) 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" 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 message = message + details
} }
return message return message

Loading…
Cancel
Save