UninstallFromTargets removes an entity from the specified apps and updates the metadata store's installed status.
(ctx context.Context, kind, installKey string, targetApps []string)
| 411 | // UninstallFromTargets removes an entity from the specified apps and updates |
| 412 | // the metadata store's installed status. |
| 413 | func (svc *Service) UninstallFromTargets(ctx context.Context, kind, installKey string, targetApps []string) error { |
| 414 | if len(targetApps) == 0 { |
| 415 | return fmt.Errorf("metadata: no target agents specified") |
| 416 | } |
| 417 | item, err := svc.store.GetItem(ctx, kind, installKey) |
| 418 | if err != nil { |
| 419 | return fmt.Errorf("metadata: item not found: %w", err) |
| 420 | } |
| 421 | |
| 422 | entityKind := entities.Kind(item.Kind) |
| 423 | entityName := item.Name |
| 424 | |
| 425 | var removed []string |
| 426 | var lastErr error |
| 427 | for _, app := range targetApps { |
| 428 | if _, _, err := entities.UninstallFromApp(entityName, entityKind, app); err != nil { |
| 429 | lastErr = fmt.Errorf("metadata: uninstall from %s: %w", app, err) |
| 430 | continue |
| 431 | } |
| 432 | removed = append(removed, app) |
| 433 | } |
| 434 | if len(removed) == 0 { |
| 435 | return lastErr |
| 436 | } |
| 437 | for _, app := range removed { |
| 438 | if err := svc.store.MarkUninstalled(ctx, kind, installKey, app); err != nil { |
| 439 | lastErr = err |
| 440 | } |
| 441 | } |
| 442 | return lastErr |
| 443 | } |
| 444 | |
| 445 | // fetchResourceContent downloads the resource's source repo and reads its |
| 446 | // manifest content. Failures return an empty string so install still creates the |
no test coverage detected