Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Unreleased

# Released
# v1.4.1

## Bug Fixes

* Added the `tf_policy_checked` and `tf_policy_override` values to `RunStatus`. A run
paused awaiting a tf-policy override decision reports `status: "tf_policy_override"`
on the wire; without this fix, `client.runs.read()` (and anything that parses a `Run`
through this status) raised a validation error instead of returning the run.
Discovered via live testing of the `hashicorp.terraform` Ansible collection's
tf-policy modules — no mocked unit fixture had exercised this status before.

# v1.4.0

## Enhancements
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "pytfe"
version = "1.4.0"
version = "1.4.1"
description = "Official Python SDK for HashiCorp Terraform Cloud / Terraform Enterprise (TFE) API v2"
readme = "README.md"
license = { text = "MPL-2.0" }
Expand Down
2 changes: 2 additions & 0 deletions src/pytfe/models/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class RunStatus(str, Enum):
Run_Pre_Plan_Running = "pre_plan_running"
Run_Queuing = "queuing"
Run_Queuing_Apply = "queuing_apply"
Run_Tf_Policy_Checked = "tf_policy_checked"
Run_Tf_Policy_Override = "tf_policy_override"


class RunIncludeOpt(str, Enum):
Expand Down
20 changes: 20 additions & 0 deletions tests/units/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,23 @@ def test_discard_run_success(self, runs_service):
assert call_args[0][0] == "POST"
assert call_args[0][1] == "/api/v2/runs/run-discard-123/actions/discard"
assert call_args[1]["json_body"]["comment"] == "Discarding run"


class TestRunStatusTfPolicy:
"""Regression test: atlas introduced ``tf_policy_checked`` and
``tf_policy_override`` run statuses alongside tf-policy (the analogues
of the pre-existing ``policy_checked``/``policy_override`` statuses for
the Sentinel/OPA flow). A run that pauses awaiting a tf-policy override
decision reports ``status: "tf_policy_override"`` on the wire - if the
enum doesn't know that value, parsing the run raises a validation error
instead of returning the status. Caught only by live testing against a
run that actually reached this status; no mocked fixture exercised it.
"""

def test_tf_policy_override_status_parses(self):
run = Run.model_validate({"id": "run-abc123", "status": "tf_policy_override"})
assert run.status == RunStatus.Run_Tf_Policy_Override

def test_tf_policy_checked_status_parses(self):
run = Run.model_validate({"id": "run-abc123", "status": "tf_policy_checked"})
assert run.status == RunStatus.Run_Tf_Policy_Checked
Loading