From 4ec235617c812126faee2c330ff1d316aa894654 Mon Sep 17 00:00:00 2001 From: Davide Bianchi Date: Wed, 24 Jul 2024 16:52:01 +0200 Subject: [PATCH] fix: sends environment query params when get the deploy status --- CHANGELOG.md | 4 ++++ internal/cmd/deploy/deploy.go | 5 +++-- internal/cmd/deploy/deploy_test.go | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9daf1a5d..ce7c19c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/internal/cmd/deploy/deploy.go b/internal/cmd/deploy/deploy.go index 2721a1d5..76ff7b8a 100644 --- a/internal/cmd/deploy/deploy.go +++ b/internal/cmd/deploy/deploy.go @@ -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) } @@ -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 { diff --git a/internal/cmd/deploy/deploy_test.go b/internal/cmd/deploy/deploy_test.go index ef9ff19b..e29385ba 100644 --- a/internal/cmd/deploy/deploy_test.go +++ b/internal/cmd/deploy/deploy_test.go @@ -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",