Skip to content

Conversation

@jpadrianoGo
Copy link
Contributor

Description

This PR adds an new PolicySetVersion field, IngressAttributes struct with commit-sha,commit-url, and identifier fields. PolicySetVersion now includes IngressAttributes.

The change aims to be part of automating policy-set creation and testing. This aligns PolicySetVersions.Read return with curl's return.

curl
--header "Authorization: Bearer $TOKEN"
--request GET
https://app.terraform.io/api/v2/policy-set-versions/polsetver-cXciu9nQwmk9Cfrn

PolicySetVersions.Read(ctx context.Context, policySetVersionID string) (*PolicySetVersion, error)

{ "data": { "id": "polsetver-", "type": "policy-set-versions", "attributes": { "source": "github", "status": "ready", "status-timestamps": { "ready-at": "2024-11-10T00:14:59+00:00", "ingressing-at": "2024-11-10T00:14:54+00:00" }, "error": null, "error-message": null, "ingress-attributes": { "commit-sha": "", "commit-url": "", "identifier": "" }, "created-at": "2024-11-10T00:14:54.604Z", "updated-at": "2024-11-10T00:14:59.500Z" }, "relationships": { "policy-set": { "data": { "id": "polset-", "type": "policy-sets" } } }, "links": { "self": "/api/v2/policy-set-versions/polsetver-" } } }

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" GITHUB_POLICY_SET_IDENTIFIER="username/repository" OAUTH_CLIENT_GITHUB_TOKEN="githubtoken" go test ./... -v -run TestPolicySetVersionsIngressAttributes. The new tests should pass.
  3. IngressAttributes is read for PolicySetVersion.

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" GITHUB_POLICY_SET_IDENTIFIER="username/repository" OAUTH_CLIENT_GITHUB_TOKEN="githubtoken" go test ./... -v -run TestPolicySetVersionsIngressAttributes

=== RUN   TestPolicySetVersionsIngressAttributes
=== RUN   TestPolicySetVersionsIngressAttributes/with_vcs
=== RUN   TestPolicySetVersionsIngressAttributes/without_vcs
--- PASS: TestPolicySetVersionsIngressAttributes (12.48s)
    --- PASS: TestPolicySetVersionsIngressAttributes/with_vcs (4.52s)
    --- PASS: TestPolicySetVersionsIngressAttributes/without_vcs (1.87s)
PASS
ok      github.com/hashicorp/go-tfe     12.482s

@jpadrianoGo jpadrianoGo requested a review from a team as a code owner April 26, 2025 04:50
Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

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

👋 Thank you for making this change!

In order to test your branch against CI, we'll need to rebase your changes onto a local branch. There are a few things we'll need to address before doing so ⬇️

@jpadrianoGo
Copy link
Contributor Author

@sebasslash Thank you, I have applied the changes based from feedback.

@jpadrianoGo jpadrianoGo requested a review from sebasslash May 13, 2025 23:34
CHANGELOG.md Outdated
=======
* Adds `AgentPool` field to the OAuthClientUpdateOptions struct, which is used to associate a VCS Provider with an AgentPool for PrivateVCS support by @jpogran [#1075](https://github.com/hashicorp/go-tfe/pull/1075)
* Adds `IngressAttributes` field to `PolicySetVersion` by @jpadrianoGo [#1092](https://github.com/hashicorp/go-tfe/pull/1092)
>>>>>>> Updated changelog
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there are some leftover artifacts from rebasing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, updated Changelog

@jpadrianoGo jpadrianoGo requested a review from sebasslash May 14, 2025 21:40
@sebasslash
Copy link
Contributor

See #1108

@jpadrianoGo
Copy link
Contributor Author

Thank you @sebasslash

@sebasslash
Copy link
Contributor

#1108 has been merged, thanks for contributing JP!

@sebasslash sebasslash closed this May 15, 2025
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