Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

# v1.91.1

## Enhancements

* Updates endpoint for deleting stack from `POST` to `DELETE` and removing `/delete` from endpoint by
* Updates endpoint for force deleting stack from `POST` to `DELETE` and removing `/force-delete` from endpoint and adding `?force=true` by

Comment on lines +5 to +16
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These enhancements aren't customer-impacting, correct? If not I don't think they need to show in the changelog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't user be able to delete the stack? The post wont work anymore.

## Deprecations

* The beta `StackDeployments`, `StackPlan`, `StackPlanOperation`, and `StackSource` resources have been removed, by @sahar-azizighannad [#1205](https://github.com/hashicorp/go-tfe/pull/1205)
## Bug Fixes

* Fixes timestamp attribute mapping for deployment runs to use correct API field names (`created-at`/`updated-at` instead of `started-at`/`completed-at`) by @shwetamurali [#1199](https://github.com/hashicorp/go-tfe/pull/1199)
Expand Down
4 changes: 2 additions & 2 deletions stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (s stacks) Update(ctx context.Context, stackID string, options StackUpdateO

// Delete deletes a stack.
func (s stacks) Delete(ctx context.Context, stackID string) error {
req, err := s.client.NewRequest("POST", fmt.Sprintf("stacks/%s/delete", url.PathEscape(stackID)), nil)
req, err := s.client.NewRequest("DELETE", fmt.Sprintf("stacks/%s", url.PathEscape(stackID)), nil)
if err != nil {
return err
}
Expand All @@ -314,7 +314,7 @@ func (s stacks) Delete(ctx context.Context, stackID string) error {

// ForceDelete deletes a stack that still has deployments.
func (s stacks) ForceDelete(ctx context.Context, stackID string) error {
req, err := s.client.NewRequest("POST", fmt.Sprintf("stacks/%s/force-delete", url.PathEscape(stackID)), nil)
req, err := s.client.NewRequest("DELETE", fmt.Sprintf("stacks/%s?force=true", url.PathEscape(stackID)), nil)
if err != nil {
return err
}
Expand Down
38 changes: 0 additions & 38 deletions stack_deployments.go

This file was deleted.

35 changes: 0 additions & 35 deletions stack_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,37 +340,6 @@ func pollStackDeployments(t *testing.T, ctx context.Context, client *Client, sta
return
}

func pollStackDeploymentStatus(t *testing.T, ctx context.Context, client *Client, stackID, deploymentName, status string) {
// pollStackDeployments will poll the given stack until it has deployments or the deadline is reached.
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(5*time.Minute))
defer cancel()

deadline, _ := ctx.Deadline()
t.Logf("Polling stack %q for deployments with deadline of %s", stackID, deadline)

ticker := time.NewTicker(2 * time.Second)
defer ticker.Stop()

for finished := false; !finished; {
t.Log("...")
select {
case <-ctx.Done():
t.Fatalf("Stack deployment %s/%s did not have status %q at deadline", stackID, deploymentName, status)
case <-ticker.C:
var err error
deployment, err := client.StackDeployments.Read(ctx, stackID, deploymentName)
if err != nil {
t.Fatalf("Failed to read stack deployment %s/%s: %s", stackID, deploymentName, err)
}

t.Logf("Stack deployment %s/%s had status %q", stackID, deploymentName, deployment.Status)
if deployment.Status == status {
finished = true
}
}
}
}

func pollStackConfigurationStatus(t *testing.T, ctx context.Context, client *Client, stackConfigID, status string) (stackConfig *StackConfiguration) {
// pollStackDeployments will poll the given stack until it has deployments or the deadline is reached.
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(5*time.Minute))
Expand Down Expand Up @@ -440,9 +409,5 @@ func TestStackConverged(t *testing.T) {
require.ElementsMatch(t, deployments, stack.DeploymentNames)
require.NotNil(t, stack.LatestStackConfiguration)

for _, deployment := range deployments {
pollStackDeploymentStatus(t, ctx, client, stack.ID, deployment, "paused")
}

Comment on lines -456 to -459
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? Is this only needed for testing beta code? Seems like we would still need the ability to poll stack deployment status for this test even after the refactor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not support this endpoint on GA. Unless I move it back instead of deprecating which I can.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I think I get it, we are still able to test if the stack converged even without checking the stack deployment statuses. Makes sense.

pollStackConfigurationStatus(t, ctx, client, stack.LatestStackConfiguration.ID, "converged")
}
Loading