DeleteCSV will delete all operator's CSVs
( ctx context.Context, crudClient client.Client, )
| 219 | |
| 220 | // DeleteCSV will delete all operator's CSVs |
| 221 | func DeleteCSV( |
| 222 | ctx context.Context, |
| 223 | crudClient client.Client, |
| 224 | ) error { |
| 225 | ol := &unstructured.UnstructuredList{} |
| 226 | ol.SetGroupVersionKind(schema.GroupVersionKind{ |
| 227 | Group: "operators.coreos.com", |
| 228 | Version: "v1alpha1", |
| 229 | Kind: "ClusterServiceVersion", |
| 230 | }) |
| 231 | labelSelector := labels.SelectorFromSet(map[string]string{ |
| 232 | "operators.coreos.com/cloudnative-pg.openshift-operators": "", |
| 233 | }) |
| 234 | err := objects.List(ctx, crudClient, ol, client.MatchingLabelsSelector{Selector: labelSelector}) |
| 235 | if err != nil { |
| 236 | return err |
| 237 | } |
| 238 | for _, o := range ol.Items { |
| 239 | err = objects.Delete(ctx, crudClient, &o) |
| 240 | if err != nil { |
| 241 | if apierrors.IsNotFound(err) { |
| 242 | continue |
| 243 | } |
| 244 | return err |
| 245 | } |
| 246 | } |
| 247 | return err |
| 248 | } |
| 249 | |
| 250 | // UpgradeSubscription patch an unstructured subscription object with target channel |
| 251 | func UpgradeSubscription( |