(rel *release.Release, toBeAdopted kube.ResourceList, resources kube.ResourceList)
| 504 | } |
| 505 | |
| 506 | func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.ResourceList, resources kube.ResourceList) (*release.Release, error) { |
| 507 | var err error |
| 508 | // pre-install hooks |
| 509 | if !i.DisableHooks { |
| 510 | if err := i.cfg.execHook(rel, release.HookPreInstall, i.WaitStrategy, i.WaitOptions, i.Timeout, i.ServerSideApply); err != nil { |
| 511 | return rel, fmt.Errorf("failed pre-install: %w", err) |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | // At this point, we can do the install. Note that before we were detecting whether to |
| 516 | // do an update, but it's not clear whether we WANT to do an update if the reuse is set |
| 517 | // to true, since that is basically an upgrade operation. |
| 518 | if len(toBeAdopted) == 0 && len(resources) > 0 { |
| 519 | _, err = i.cfg.KubeClient.Create( |
| 520 | resources, |
| 521 | kube.ClientCreateOptionServerSideApply(i.ServerSideApply, false)) |
| 522 | } else if len(resources) > 0 { |
| 523 | updateThreeWayMergeForUnstructured := i.TakeOwnership && !i.ServerSideApply // Use three-way merge when taking ownership (and not using server-side apply) |
| 524 | _, err = i.cfg.KubeClient.Update( |
| 525 | toBeAdopted, |
| 526 | resources, |
| 527 | kube.ClientUpdateOptionForceReplace(i.ForceReplace), |
| 528 | kube.ClientUpdateOptionServerSideApply(i.ServerSideApply, i.ForceConflicts), |
| 529 | kube.ClientUpdateOptionThreeWayMergeForUnstructured(updateThreeWayMergeForUnstructured), |
| 530 | kube.ClientUpdateOptionUpgradeClientSideFieldManager(true)) |
| 531 | } |
| 532 | if err != nil { |
| 533 | return rel, err |
| 534 | } |
| 535 | |
| 536 | var waiter kube.Waiter |
| 537 | if c, supportsOptions := i.cfg.KubeClient.(kube.InterfaceWaitOptions); supportsOptions { |
| 538 | waiter, err = c.GetWaiterWithOptions(i.WaitStrategy, i.WaitOptions...) |
| 539 | } else { |
| 540 | waiter, err = i.cfg.KubeClient.GetWaiter(i.WaitStrategy) |
| 541 | } |
| 542 | if err != nil { |
| 543 | return rel, fmt.Errorf("failed to get waiter: %w", err) |
| 544 | } |
| 545 | |
| 546 | if i.WaitForJobs { |
| 547 | err = waiter.WaitWithJobs(resources, i.Timeout) |
| 548 | } else { |
| 549 | err = waiter.Wait(resources, i.Timeout) |
| 550 | } |
| 551 | if err != nil { |
| 552 | return rel, err |
| 553 | } |
| 554 | |
| 555 | if !i.DisableHooks { |
| 556 | if err := i.cfg.execHook(rel, release.HookPostInstall, i.WaitStrategy, i.WaitOptions, i.Timeout, i.ServerSideApply); err != nil { |
| 557 | return rel, fmt.Errorf("failed post-install: %w", err) |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | if len(i.Description) > 0 { |
| 562 | rel.SetStatus(rcommon.StatusDeployed, i.Description) |
| 563 | } else { |
no test coverage detected