Skip to content

Commit

Permalink
fix: sends environment query params when get the deploy status
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebianchi authored and JGiola committed Jul 24, 2024
1 parent 687215c commit 4ec2356
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `extensions get` command

### Fixed

- deploy status now sends the environment query params

## [0.13.0] - 2024-06-26

### Added
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func run(ctx context.Context, environmentName string, options *clioptions.CLIOpt
}
fmt.Printf("Deploying project %s in the environment '%s'\n", projectID, environmentName)

status, err := waitStatus(ctx, client, projectID, resp.ID)
status, err := waitStatus(ctx, client, projectID, resp.ID, environmentName)
if err != nil {
return fmt.Errorf("error retrieving the pipeline status: %w", err)
}
Expand Down Expand Up @@ -136,13 +136,14 @@ func triggerPipeline(ctx context.Context, client *client.APIClient, environmentN
// Declared here to override it during tests
var sleepDuration = (1 * time.Second) + (500 * time.Millisecond)

func waitStatus(ctx context.Context, client *client.APIClient, projectID string, deployID int) (string, error) {
func waitStatus(ctx context.Context, client *client.APIClient, projectID string, deployID int, environmentName string) (string, error) {
var outStatus *resources.PipelineStatus
for {
time.Sleep(sleepDuration)
resp, err := client.
Get().
APIPath(fmt.Sprintf(pipelineStatusEndpointTemplate, projectID, deployID)).
SetParam("environment", environmentName).
Do(ctx)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func testServer(t *testing.T) *httptest.Server {

require.NoError(t, err)
w.Write(data)
case r.Method == http.MethodGet && r.URL.Path == fmt.Sprintf(pipelineStatusEndpointTemplate, "correct", 1):
case r.Method == http.MethodGet && r.URL.Path == fmt.Sprintf(pipelineStatusEndpointTemplate, "correct", 1) && r.URL.Query().Get("environment") == "environmentName":
data, err := resources.EncodeResourceToJSON(&resources.PipelineStatus{
ID: 1,
Status: "succeeded",
Expand Down

0 comments on commit 4ec2356

Please sign in to comment.