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

Use the stages attribute for the Workspace Run Task resource #1459

Merged
merged 6 commits into from
Sep 5, 2024

Conversation

glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Sep 3, 2024

Fixes #1456

Description

Previously the schema for workspace run tasks was updated for the new stages
property however it wasn't actually used. This commit updates the Workspace
Run Task resource to aware of the stages attributes. In particular;

  • Attempts to detect if the remote service supports the stages property. Stages
    is available in HCP Terraform and TFE v202404-1 onwards.

  • Munges the Stages and Stage attribtue depending on the remote capability.

  • Emits a warning about the remove server capability.

  • Adds some automated tests. Unfortunately we can't test older TFE versions,
    to ensure the munging is correct, however manual testing was performed in
    a local development enivronment to confirm the behaviour.

  • Removes the default value for the Stage property in the Schema. This will
    not cause issues with existing state and allows the provider to determine
    if the attribute was passed in via configuration as opposed to defaulting.

Testing plan

Apart from CI

  1. Use a version of TFE
  2. Apply configuration which uses the stages property with multiple values

External links

Output from acceptance tests

Tests can be run in CI

@glennsarti glennsarti requested a review from a team as a code owner September 3, 2024 05:50
@glennsarti glennsarti changed the title Gs/fix ws run task stages Use the stages attribute for the Workspace Run Task resource Sep 3, 2024
@glennsarti glennsarti force-pushed the gs/fix-ws-run-task-stages branch 3 times, most recently from 994f63c to 3330197 Compare September 3, 2024 06:24
@glennsarti glennsarti requested a review from a team September 3, 2024 06:28
This commit adds a resolver interface which will be used within the codebase
to determine what the capabilities of the remote service are (e.g. Is is Enterprise,
if so what version). Note this is an interface, not a struct to make testing
easier.

Later commits will use this resolver.
Previously the schema for workspace run tasks was updated for the new stages
property however it wasn't actually used. This commit updates the Workspace
Run Task resource to aware of the stages attributes. In particular;

* Attempts to detect if the remote service supports the stages property. Stages
is available in HCP Terraform and TFE v202404-1 onwards.

* Munges the Stages and Stage attribtue depending on the remote capability.

* Emits a warning about the remove server capability.

* Adds some automated tests. Unfortunately we can't test older TFE versions,
to ensure the munging is correct, however manual testing was performed in
a local development enivronment to confirm the behaviour.

* Removes the default value for the Stage property in the Schema. This will
not cause issues with existing state and allows the provider to determine
if the attribute was passed in via configuration as opposed to defaulting.
Removing the pointer reference as it's not required.
Previously the test subject for the stagesSupport unit tests would reuse the
subject and resolver however this led to timing issues when parallel tests
were run. This commit changes the test to create new objects per test.
@glennsarti glennsarti force-pushed the gs/fix-ws-run-task-stages branch from 692eb6b to 83fd786 Compare September 4, 2024 23:46
@glennsarti glennsarti merged commit 9ff07e2 into main Sep 5, 2024
9 checks passed
@glennsarti glennsarti deleted the gs/fix-ws-run-task-stages branch September 5, 2024 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tfe_workspace_run_task apply fails when using stages argument and TFE v202408-1
3 participants