Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enforce marshalling #209

Merged
merged 1 commit into from
Apr 15, 2021
Merged

Fix enforce marshalling #209

merged 1 commit into from
Apr 15, 2021

Conversation

omarismail
Copy link
Contributor

Description

A previous PR #197 sought to use jsonapi for all marshalling and unmarshalling of Resources. This went mostly well, but had a few breaking changes. It was discovered that some structs were not properly being marshaled. Those were fixed in #204 .

This PR changes a few the tag for EnforcementOptions that was altered in #197 back to using json tag. This is an interim step until the hashicorp/jsonapi package has the capability to handle nested structs.

It also alters the Enforce attribute to not use a slice of pointers because that is incompatabile with hashicorp/jsonapi, and just uses a slice of structs (which works with the jsonapi package).

Output from tests

$ go test -v -run TestPolicyCreateOptions_Marshal
=== RUN   TestPolicyCreateOptions_Marshal
--- PASS: TestPolicyCreateOptions_Marshal (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     0.139s
$ go test -v -run TestPolicyUpdateOptions_Marshal
=== RUN   TestPolicyUpdateOptions_Marshal
--- PASS: TestPolicyUpdateOptions_Marshal (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     0.137s

todo: print output from full test suite

@omarismail omarismail requested a review from a team April 15, 2021 18:10
defer policyCleanup1()
pTest2, policyCleanup2 := createUploadedPolicy(t, client, true, orgTest)
defer policyCleanup2()
wTest, wsCleanup := createWorkspace(t, client, orgTest)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drive by changes to fix dangling resources problem

Copy link
Member

@cam-stitt cam-stitt left a comment

Choose a reason for hiding this comment

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

Seams reasonable!

Copy link
Member

@chrisarcand chrisarcand left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for untangling all this!

@chrisarcand chrisarcand merged commit 158564a into master Apr 15, 2021
@chrisarcand chrisarcand deleted the omarismial/fix-enforce branch April 15, 2021 23:11
chrisarcand pushed a commit that referenced this pull request Apr 20, 2021
This commit is for a separate backported release of the following fix,
for the 0.13.x series of the client.

In #197 we changed the type of Policy.Enforce from []*Enforcement to []Enforcement. This had downstream impact on the terraform-provider, which relies on this client (as well as any other 3rd parties that use this client!)

This PR primarily reverts the type changes of Policy.Enforce back to being a []*Enforcement. It also updates the hashicorp/jsonapi package to reference the latest version.

It also includes a field tag change necessary from #209
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