Skip to content

Conversation

rageshganeshkumar
Copy link
Contributor

@rageshganeshkumar rageshganeshkumar commented Jul 29, 2025

Description

This pull request modifies the PolicySetVersion struct in policy_set_version.go to improve the representation of IngressAttributes. The change updates its JSON:API tag to correctly indicate it as a relation rather than an attribute.

Changes to PolicySetVersion struct:

  • Updated the IngressAttributes field to use the jsonapi:"relation,ingress-attributes" tag instead of jsonapi:"attr,ingress-attributes", ensuring it is treated as a relationship in the JSON:API specification.

Testing plan

Try reading a policy set version

policySetVersion, err := client.PolicySetVersions.Read(ctx, policySetVersionID)

Before Change

ragesh.ganeshkumar@ragesh gotfe-samples % go run read_policy.go
2025/07/29 14:31:11 Error reading policy set version: jsonapi: Can't unmarshal map[commit-sha:6c12753ef1621f2ec0bd85f970733067a3e96b9d commit-url:https://github.com/rageshganeshkumar/sleepy-space/commit/6c12753ef1621f2ec0bd85f970733067a3e96b9d identifier:rageshganeshkumar/sleepy-space] (map) to struct field `IngressAttributes`, which is a pointer to `IngressAttributes (struct)`
exit status 1

After Change

ragesh.ganeshkumar@ragesh gotfe-samples % go run read_policy.go
Policy Set Version ID: polsetver-Jvhes6ZWnJdUam5s
Status: ready
Source: github
Created At: 2025-07-29 08:52:07.005 +0000 UTC

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

N/A

Changes to Security Controls

N/A

Copy link

hashicorp-cla-app bot commented Jul 29, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@rageshganeshkumar rageshganeshkumar marked this pull request as ready for review July 29, 2025 10:44
@rageshganeshkumar rageshganeshkumar requested a review from a team as a code owner July 29, 2025 10:44
@brandonc
Copy link
Collaborator

According to the docs example and the platform code itself, ingress-attributes is an attribute. I don't think I can merge this without merging an API change as well

@rageshganeshkumar
Copy link
Contributor Author

According to the docs example and the platform code itself, ingress-attributes is an attribute. I don't think I can merge this without merging an API change as well

Does this something like this work?

IngressAttributes struct {
		CommitSHA  string `jsonapi:"attr,commit-sha"`
		CommitURL  string `jsonapi:"attr,commit-url"`
		Identifier string `jsonapi:"attr,identifier"`
	} `jsonapi:"attr,ingress-attributes"`
	

This is currently a broken code that needs a fix

@brandonc brandonc force-pushed the rageshg/fix-policy-set-version branch from 5671084 to 7a1dfd2 Compare August 12, 2025 17:27
@brandonc
Copy link
Collaborator

$ OAUTH_CLIENT_GITHUB_TOKEN=$GITHUB_TOKEN GITHUB_POLICY_SET_IDENTIFIER=brandonc/test-policy-set TFE_ADMIN_PROVISION_LICENSES_TOKEN="xxx" go test . -v -run "TestPolicySetVersionsIngressAttributes"
=== RUN   TestPolicySetVersionsIngressAttributes
=== RUN   TestPolicySetVersionsIngressAttributes/with_vcs
=== RUN   TestPolicySetVersionsIngressAttributes/without_vcs
--- PASS: TestPolicySetVersionsIngressAttributes (6.29s)
    --- PASS: TestPolicySetVersionsIngressAttributes/with_vcs (4.44s)
    --- PASS: TestPolicySetVersionsIngressAttributes/without_vcs (0.72s)
PASS
ok      github.com/hashicorp/go-tfe     6.744s

Copy link
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.

👍

@brandonc brandonc merged commit 4318b5e into main Aug 12, 2025
8 checks passed
@brandonc brandonc deleted the rageshg/fix-policy-set-version branch August 12, 2025 20:12
Copy link

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

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.

3 participants