Skip to content

Conversation

jpadrianoGo
Copy link
Contributor

Description

This PR adds CanceledAt, RunEvents, TriggerReason fields to Run struct.

Testing plan

  1. Generate the required environment variables for go test, TFE_ADDRESS and TFE_TOKEN
  2. Run TFE_ADDRESS="https://example" TFE_TOKEN="example" go test ./... -v -run TestRunsCanceledAt. The new tests should pass.
  3. CanceledAt, RunEvents, TriggerReason is read for Run.
{
  "data": {
    "id": "run-***",
    "type": "runs",
    "attributes": {
      "actions": {
        "is-cancelable": false,
        "is-confirmable": false,
        "is-discardable": false,
        "is-force-cancelable": false
      },
      "allow-config-generation": false,
      "allow-empty-apply": false,
      "auto-apply": false,
      "canceled-at": "2025-07-21T08:42:10.617Z",
      "created-at": "2025-07-21T08:42:10.116Z",
      "has-changes": false,
      "is-destroy": false,
      "message": "Triggered via API",
      "plan-only": false,
      "refresh": true,
      "refresh-only": false,
      "replace-addrs": null,
      "save-plan": false,
      "source": "tfe-api",
      "status-timestamps": {
        "force-canceled-at": "2025-07-21T08:42:10+00:00"
      },
      "status": "canceled",
      "target-addrs": null,
      "trigger-reason": "manual",
      "terraform-version": "1.12.2",
      "updated-at": "2025-07-21T08:42:10.673Z",
      "permissions": {
        "can-apply": true,
        "can-cancel": true,
        "can-comment": true,
        "can-discard": true,
        "can-force-execute": true,
        "can-force-cancel": true,
        "can-override-policy-check": true
      },
      "variables": [],
      "force-cancel-available-at": "2025-07-21T08:43:10.617Z"
    },
    "relationships": {
      "workspace": {
        "data": {
          "id": "ws-***",
          "type": "workspaces"
        }
      },
      "apply": {
        "data": {
          "id": "apply-***",
          "type": "applies"
        },
        "links": {
          "related": "/api/v2/runs/run-***/apply"
        }
      },
      "canceled-by": {
        "data": {
          "id": "user-***",
          "type": "users"
        },
        "links": {
          "related": "/api/v2/runs/run-***/canceled-by"
        }
      },
      "configuration-version": {
        "data": {
          "id": "cv-***",
          "type": "configuration-versions"
        },
        "links": {
          "related": "/api/v2/runs/run-***/configuration-version"
        }
      },
      "created-by": {
        "data": {
          "id": "user-***",
          "type": "users"
        },
        "links": {
          "related": "/api/v2/runs/run-***/created-by"
        }
      },
      "plan": {
        "data": {
          "id": "plan-***",
          "type": "plans"
        },
        "links": {
          "related": "/api/v2/runs/run-***/plan"
        }
      },
      "run-events": {
        "data": [
          {
            "id": "re-***",
            "type": "run-events"
          },
          {
            "id": "re-***",
            "type": "run-events"
          },
          {
            "id": "re-***",
            "type": "run-events"
          }
        ],
        "links": {
          "related": "/api/v2/runs/run-***/run-events"
        }
      },
      "task-stages": {
        "data": [],
        "links": {
          "related": "/api/v2/runs/run-***/task-stages"
        }
      },
      "policy-checks": {
        "data": [],
        "links": {
          "related": "/api/v2/runs/run-***/policy-checks"
        }
      },
      "comments": {
        "data": [],
        "links": {
          "related": "/api/v2/runs/run-***/comments"
        }
      }
    },
    "links": {
      "self": "/api/v2/runs/run-***"
    }
  }
}

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example"go test ./... -v -run TestRunsCanceledAt 

=== RUN   TestRunsCanceledAt
=== RUN   TestRunsCanceledAt/when_the_run_is_not_canceled
=== RUN   TestRunsCanceledAt/when_the_run_is_canceled
--- PASS: TestRunsCanceledAt (10.00s)
    --- PASS: TestRunsCanceledAt/when_the_run_is_not_canceled (0.38s)
    --- PASS: TestRunsCanceledAt/when_the_run_is_canceled (0.91s)
PASS
ok      github.com/hashicorp/go-tfe     10.059s

$ TFE_ADDRESS="https://example" TFE_TOKEN="example"go test ./... -v -run TestRunsRunEvents 

go test -run TestRunsRunEvents -v
=== RUN   TestRunsRunEvents
--- PASS: TestRunsRunEvents (4.86s)
PASS
ok      github.com/hashicorp/go-tfe     4.908s

$ TFE_ADDRESS="https://example" TFE_TOKEN="example"go test ./... -v -run TestRunsTriggerReason
=== RUN   TestRunsTriggerReason
--- PASS: TestRunsTriggerReason (5.01s)
PASS
ok      github.com/hashicorp/go-tfe     5.104s

@jpadrianoGo jpadrianoGo requested a review from a team as a code owner July 21, 2025 00:30
@ctrombley
Copy link
Collaborator

Superseded by #1188.

@ctrombley ctrombley closed this Aug 20, 2025
@jpadrianoGo
Copy link
Contributor Author

Thank you @ctrombley

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.

2 participants