(ctx context.Context, depl *database.Deployment, branch string)
| 95 | } |
| 96 | |
| 97 | func (s *Service) UpdateDeployment(ctx context.Context, depl *database.Deployment, branch string) error { |
| 98 | // Update the deployment with the new branch (or existing branch) and set existing desired status to retrigger reconcile flow |
| 99 | var err error |
| 100 | if branch != depl.Branch { |
| 101 | _, err = s.DB.UpdateDeploymentSafe(ctx, depl.ID, &database.UpdateDeploymentSafeOptions{ |
| 102 | DesiredStatus: depl.DesiredStatus, |
| 103 | Branch: branch, |
| 104 | }) |
| 105 | } else { |
| 106 | _, err = s.DB.UpdateDeploymentDesiredStatus(ctx, depl.ID, depl.DesiredStatus) |
| 107 | } |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | // Trigger reconcile deployment job |
| 113 | err = s.triggerDeploymentReconcileJob(ctx, depl.ID) |
| 114 | if err != nil { |
| 115 | return err |
| 116 | } |
| 117 | |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | func (s *Service) TeardownDeployment(ctx context.Context, depl *database.Deployment) error { |
| 122 | // Update the desired deployment status to deleted |
no test coverage detected