@@ -32,19 +32,17 @@ func (c *HTTPClient) GetDeployment(ctx context.Context, releaseID string, deploy
3232 return & resp , nil
3333}
3434
35- // UpdateDeploymentStatus updates the status of a deployment
36- func (c * HTTPClient ) UpdateDeploymentStatus (ctx context.Context , releaseID string , deployID string , status DeploymentStatus , reason string ) error {
37- path := fmt .Sprintf ("/release/%s/deploy/%s/status" , releaseID , deployID )
38-
39- payload := struct {
40- Status DeploymentStatus `json:"status"`
41- Reason string `json:"reason"`
42- }{
43- Status : status ,
44- Reason : reason ,
35+ // UpdateDeployment updates a deployment with new values
36+ func (c * HTTPClient ) UpdateDeployment (ctx context.Context , releaseID string , deployment * ReleaseDeployment ) (* ReleaseDeployment , error ) {
37+ path := fmt .Sprintf ("/release/%s/deploy/%s" , releaseID , deployment .ID )
38+
39+ var resp ReleaseDeployment
40+ err := c .do (ctx , http .MethodPut , path , deployment , & resp )
41+ if err != nil {
42+ return nil , err
4543 }
4644
47- return c . do ( ctx , http . MethodPut , path , payload , nil )
45+ return & resp , nil
4846}
4947
5048// ListDeployments retrieves all deployments for a release
@@ -60,6 +58,21 @@ func (c *HTTPClient) ListDeployments(ctx context.Context, releaseID string) ([]R
6058 return resp , nil
6159}
6260
61+ // IncrementDeploymentAttempts increments the attempts counter for a deployment by 1
62+ func (c * HTTPClient ) IncrementDeploymentAttempts (ctx context.Context , releaseID string , deployID string ) (* ReleaseDeployment , error ) {
63+ // First get the current deployment
64+ deployment , err := c .GetDeployment (ctx , releaseID , deployID )
65+ if err != nil {
66+ return nil , fmt .Errorf ("failed to get deployment: %w" , err )
67+ }
68+
69+ // Increment the attempts counter
70+ deployment .Attempts ++
71+
72+ // Update the deployment
73+ return c .UpdateDeployment (ctx , releaseID , deployment )
74+ }
75+
6376// GetLatestDeployment retrieves the most recent deployment for a release
6477func (c * HTTPClient ) GetLatestDeployment (ctx context.Context , releaseID string ) (* ReleaseDeployment , error ) {
6578 path := fmt .Sprintf ("/release/%s/deploy/latest" , releaseID )
0 commit comments