go-tfe icon indicating copy to clipboard operation
go-tfe copied to clipboard

feat: add support for run task results callback

Open karvounis-form3 opened this issue 11 months ago • 6 comments

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

Screenshot 2024-06-19 at 8 27 28 AM

  • TestTaskResultsCallbackRequestOptions_Marshal

Screenshot 2024-06-19 at 8 28 01 AM

  • TestTaskResultsCallbackUpdate_Validate

Screenshot 2024-06-19 at 8 28 25 AM

  • TestTaskResultsCallbackUpdate

Screenshot 2024-06-19 at 8 28 52 AM

External links

https://github.com/hashicorp/terraform-run-task-scaffolding-go this HashiCorp repo contains part of the code that can be found here.

karvounis-form3 avatar Mar 12 '24 09:03 karvounis-form3

@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?

karvounis-form3 avatar Jun 19 '24 05:06 karvounis-form3

Fixed code based on golangci-lint suggestions

karvounis-form3 avatar Jun 25 '24 14:06 karvounis-form3

@Maed223 maybe you can rerun the CI?

karvounis-form3 avatar Jun 25 '24 14:06 karvounis-form3

@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

karvounis-form3 avatar Jun 26 '24 06:06 karvounis-form3

@sebasslash @Maed223 any thoughts on this?

karvounis-form3 avatar Jul 02 '24 08:07 karvounis-form3

Since this PR comes from a fork, I will rebase your changes onto a local branch so that your changes execute against CI.

sebasslash avatar Jul 02 '24 16:07 sebasslash

@sebasslash can we please prioritise merging that PR? We need that code

karvounis-form3 avatar Jul 03 '24 08:07 karvounis-form3

Closing in favor of #929

sebasslash avatar Jul 03 '24 16:07 sebasslash