only check existence for the possibly kept manifests

pull/3131/head
Federico Gimenez 7 years ago
parent e6d907ed28
commit 81eaf2f263

@ -38,12 +38,6 @@ func filterManifestsToKeep(manifests []Manifest, kubeClient environment.KubeClie
keep := []Manifest{} keep := []Manifest{}
for _, m := range manifests { 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))
if err != nil || strings.Contains(output, kube.MissingGetHeader) {
continue
}
if m.Head.Metadata == nil || m.Head.Metadata.Annotations == nil || len(m.Head.Metadata.Annotations) == 0 { if m.Head.Metadata == nil || m.Head.Metadata.Annotations == nil || len(m.Head.Metadata.Annotations) == 0 {
remaining = append(remaining, m) remaining = append(remaining, m)
continue continue
@ -67,6 +61,12 @@ func filterManifestsToKeep(manifests []Manifest, kubeClient environment.KubeClie
func summarizeKeptManifests(manifests []Manifest) string { func summarizeKeptManifests(manifests []Manifest) string {
message := "These resources were kept due to the resource policy:\n" message := "These resources were kept due to the resource policy:\n"
for _, m := range manifests { 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))
if err != nil || strings.Contains(output, kube.MissingGetHeader) {
continue
}
details := "[" + m.Head.Kind + "] " + m.Head.Metadata.Name + "\n" details := "[" + m.Head.Kind + "] " + m.Head.Metadata.Name + "\n"
message = message + details message = message + details
} }

Loading…
Cancel
Save