Skip to content

Adding changes to support tfpolicy_evaluations#1313

Open
subhro-acharjee-1 wants to merge 19 commits intomainfrom
subhro/TF-34065-adding-support-for-tfpolicy-evaluations-outcome
Open

Adding changes to support tfpolicy_evaluations#1313
subhro-acharjee-1 wants to merge 19 commits intomainfrom
subhro/TF-34065-adding-support-for-tfpolicy-evaluations-outcome

Conversation

@subhro-acharjee-1
Copy link
Copy Markdown
Contributor

@subhro-acharjee-1 subhro-acharjee-1 commented Apr 21, 2026

Description

API endpoints related to tf-policy results needs to be implemented in go-tfe, so that terraform can read the structured response, and then use the information for displaying in the console output.

Note: Concrete structure in policy set and tests in policy set to create/update/delete tfpolicy policy sets are intentionally omitted. The tfpolicy feature is currently in beta and its behavior/interface is subject to change. Tests will be added once the feature stabilizes.

Testing plan

  1. Create a local instance of atlas
  2. Create a admin token
  3. Create new workspace
  4. Create new tfpolicy policy sets
  5. Run the workspace
  6. After evaluation is finished, call run.Read with include options for TFPolicyEvaluations
  7. Use the tfPolicyEvaluation to call tfEvaluationOutcomes.List
  8. Verify the result.

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 TestFunctionsAffectedByChange

...

Rollback Plan

Changes to Security Controls

@datadog-terraform-cloud-hashicorp
Copy link
Copy Markdown

datadog-terraform-cloud-hashicorp Bot commented Apr 21, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5dd75d0 | Docs | Give us feedback!

subhro-acharjee-1 and others added 2 commits April 23, 2026 23:19
Co-authored-by: Copilot <copilot@github.com>
…65-adding-support-for-tfpolicy-evaluations-outcome
@subhro-acharjee-1 subhro-acharjee-1 marked this pull request as ready for review April 23, 2026 18:04
@subhro-acharjee-1 subhro-acharjee-1 requested a review from a team as a code owner April 23, 2026 18:04
Copy link
Copy Markdown

@shrishyamb shrishyamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments. In general please check the openapi spec for the Run, TFPolicyEvaluation and TFPolicySetOutcome API's for the updated fields.

Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
)

type TFPolicyEvaluationStatusTimestamps struct {
CanceledAt time.Time `jsonapi:"attr,canceled-at,rfc3339"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer spec for the status timestamp fields.

Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
Comment thread tfpolicy_evaluations.go Outdated
@shrishyamb shrishyamb self-requested a review May 4, 2026 07:22
Copy link
Copy Markdown
Collaborator

@ctrombley ctrombley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@subhro-acharjee-1, would you please address the comments I left here?

Comment thread tfpolicy_evaluations.go Outdated

type TFPolicyEvaluationResultCount struct {
AdvisoryFailed int `jsonapi:"attr,advisory-failed"`
MadatoryFailed int `jsonapi:"attr,mandatory-failed"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
MadatoryFailed int `jsonapi:"attr,mandatory-failed"`
MandatoryFailed int `jsonapi:"attr,mandatory-failed"`

Comment thread tfpolicy_evaluations.go Outdated

const (
TFPolicyEvaluationErrorTypeSetupError TFPolicyEvaluationErrorType = "setup_error"
TFPolicyEvaluationErrorTypeIncompaitbleAgentVersion TFPolicyEvaluationErrorType = "incompatible_agent_version"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
TFPolicyEvaluationErrorTypeIncompaitbleAgentVersion TFPolicyEvaluationErrorType = "incompatible_agent_version"
TFPolicyEvaluationErrorTypeIncompatbleAgentVersion TFPolicyEvaluationErrorType = "incompatible_agent_version"

Comment thread tfpolicy_evaluations.go Outdated
AwaitingOverrideAt time.Time `jsonapi:"attr,awaiting-override-at,rfc3339"`
PassedAt time.Time `jsonapi:"attr,passed-at,rfc3339"`
FailedAt time.Time `jsonapi:"attr,failed-at,rfc3339"`
OverridenAt time.Time `jsonapi:"attr,overridden-at,rfc3339"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
OverridenAt time.Time `jsonapi:"attr,overridden-at,rfc3339"`
OverriddenAt time.Time `jsonapi:"attr,overridden-at,rfc3339"`

Comment thread tfpolicy_evaluations.go Outdated
Comment on lines +99 to +114
type TFPolicyEvaluationOutcomeEnforcementLevel string

const (
TFPolicyEvaluationOutcomeEnforcementLevelAdvisory TFPolicyEvaluationOutcomeEnforcementLevel = "advisory"
TFPolicyEvaluationOutcomeEnforcementLevelMandatory TFPolicyEvaluationOutcomeEnforcementLevel = "mandatory"
TFPolicyEvaluationOutcomeEnforcementLevelMandatoryOverridable TFPolicyEvaluationOutcomeEnforcementLevel = "mandatory_overridable"
)

type TFPolicyEvaluationOutcomeStatus string

const (
TFPolicyEvaluationOutcomeStatusPassed TFPolicyEvaluationOutcomeStatus = "passed"
TFPolicyEvaluationOutcomeStatusFailed TFPolicyEvaluationOutcomeStatus = "failed"
TFPolicyEvaluationOutcomeStatusErrored TFPolicyEvaluationOutcomeStatus = "errored"
TFPolicyEvaluationOutcomeStatusUnknown TFPolicyEvaluationOutcomeStatus = "unknown"
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these in use anywhere? If not, can we remove them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFPolicyEvaluationOutcomeEnforcementLevel is getting used in Outcome struct so cant remove it but i am removing the TFPolicyEvaluationOutcomeStatus

Comment thread tfpolicy_evaluations.go
)

// NOTE: TFpolicy is still a beta feature and is subject to change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for consistency with other services in this repo:

Suggested change
// Compile-time proof of interface implementation.
var _ TFPolicyEvaluationOutcomes = (*tfPolicyEvaluationOutcomes)(nil)

Comment thread policy_set.go
Comment thread tfpolicy_evaluations.go Outdated
Comment on lines +185 to +187
if err := options.valid(); err != nil {
return nil, err
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing this check and the called valid() method if it's just a no-op.

Comment thread tfpolicy_evaluations.go Outdated
Comment on lines +204 to +206
func (s *TFPolicyEvaluationListOptions) valid() error {
return nil
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

shwetamurali and others added 9 commits May 6, 2026 11:32
…lan subscription (#1317)

* Update helper_test.go

* Update CHANGELOG.md

* print agent output upon failure

* fix test

* take out log

* Update CHANGELOG.md
* adds admin scim groups resouce and integration test

* fixed lint

* updated changelog entry

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* updated changelog entry

* addressed review comment

* updated test cases names

* updated integration test

* added nil receiver guard in valid() fn

* added page validation to pass lint

* removed redundant test cases

* use defaultPageSize const for pagination test

* updated test case name

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ons (#1322)

The no-code module workspace creation API accepts a terraform-version
attribute, but the Go client struct was missing the field, making it
impossible to specify a Terraform version at creation time.

Add the field with an accurate doc comment (the fallback is the
platform's latest available Terraform version, not an org-level
default) and a corresponding integration test subcase that verifies
the value roundtrips correctly through the API.
…-outcome' of github.com:hashicorp/go-tfe into subhro/TF-34065-adding-support-for-tfpolicy-evaluations-outcome
Co-authored-by: Chris Trombley <ctrombley@gmail.com>
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.

7 participants