in contrib/cmd/runkperf/commands/data/configmaps/configmap.go [324:354]
func deleteConfigmaps(clientset *kubernetes.Clientset, labelSelector string, namespace string) error {
// List all configmaps with the label selector
configMaps, err := listConfigmaps(clientset, labelSelector, namespace)
if err != nil {
return err
}
if len(configMaps.Items) == 0 {
return fmt.Errorf("no configmaps set found in namespace: %s", namespace)
}
// Delete each configmap in parallel with fixed group size
n, batch := len(configMaps.Items), 10
for i := 0; i < n; i = i + batch {
g := new(errgroup.Group)
for j := i; j < i+batch && j < n; j++ {
g.Go(func() error {
err := clientset.CoreV1().ConfigMaps(namespace).Delete(context.TODO(), configMaps.Items[j].Name, metav1.DeleteOptions{})
if err != nil && !errors.IsNotFound(err) {
// Ignore not found errors
return fmt.Errorf("failed to delete configmap %s: %v", configMaps.Items[j].Name, err)
}
return nil
})
}
if err := g.Wait(); err != nil {
return err
}
}
return nil
}