go-tfe
go-tfe copied to clipboard
feat: add support for run task results callback
Description
This PR aims to address the missing support for Run Tasks Integration API. I have already raised an issue https://github.com/hashicorp/go-tfe/issues/862 about this. It introduces the following:
- RunTaskRequest struct which can be used to objectify the request you get from a TFC/E run task
- RunTasksCallback interface which can be used to update the run task with status and messages
- TaskResultsCallbackOptions defines the attributes required in order to perform the update
Testing plan
Unfortunately, it is not easy to test the Update function because you first need a running server which listens for incoming TFC/E requests. Then, you need a workspace run which is configured to use that run task endpoint.
However, I added the following unit tests and their output when run locally:
- TestTaskResultsCallbackRequestOptions_Validate
- TestTaskResultsCallbackRequestOptions_Marshal
- TestTaskResultsCallbackUpdate_Validate
- TestTaskResultsCallbackUpdate
External links
https://github.com/hashicorp/terraform-run-task-scaffolding-go this HashiCorp repo contains part of the code that can be found here.
@sebasslash thank you for your suggestions to improve the code. I added the unit tests and added screenshots from running the tests locally in the PR body as requested. Can you please review the PR once more?
Fixed code based on golangci-lint
suggestions
@Maed223 maybe you can rerun the CI?
@Maed223 https://github.com/hashicorp/go-tfe/actions/runs/9664123031/job/26672604714#step:2:1 I do not understand what actions to take to fix that issue
@sebasslash @Maed223 any thoughts on this?
Since this PR comes from a fork, I will rebase your changes onto a local branch so that your changes execute against CI.
@sebasslash can we please prioritise merging that PR? We need that code
Closing in favor of #929