Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sends environment query params when get the deploy status #214

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading