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
add missing include field for listOptions #339
Conversation
oauth_client.go
Outdated
// A list of relations to include | ||
type OAuthClientIncludeOp string | ||
|
||
const OauthClientOauthTokens OAuthClientIncludeOp = "oauth_tokens" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides "OAuthToken" another relation listed for type OAuthClient struct
is "organization". However, I did not included a constant for "organization" because I did not see it listed in atlas's allowed_values_for_include
I will squash these commits after PR approval |
8aad609
to
e7999f0
Compare
I have two comments:
|
|
e7999f0
to
430d9d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last teeny bit, I'm sorry 😢
run_task.go
Outdated
} | ||
|
||
// RunTaskReadOptions represents the set of options for reading a run task | ||
type RunTaskReadOptions struct { | ||
// Optional: A list of relations to include with a run task. See available resources: | ||
// https://www.terraform.io/cloud-docs/api-docs/run-tasks#list-run-tasks | ||
Include []RunTaskIncludeOps `url:"include"` | ||
Include []RunTaskIncludeOpt `url:"include"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooo a missing omitempty
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, I don't apply the practices I preach. Making that change now!
430d9d1
to
d564592
Compare
revert two changes made on PR #339
revert two changes made on PR #339
revert two changes made on PR #339
revert two changes made on PR #339
Description
Add "include" field to listOptions structs for API that allow for include values.
These are the APIs and their include values listed in Atlas:
agent pool API: "workspaces"
oauth client API: "oauth_tokens"
policy check API: "run.workspace", "run"
run trigger API: "workspace", "sourceable"
organization API: "entitlement_set"
policy set versions API: "policy_set"
policy API: "policy_sets"
I did not implemented the changes for:
organizations API - because the relation for entitlement set was not part of
type Organization struct
.policy set version API - I did have the relation present but I did not have the listOptions or listing function present.
Policy API - Policies controller has the include value "policy_sets", but this value does not align with only relation listed under
type Policy struct
:Organization *Organization
jsonapi:"relation,organization"`` What am I missing here?All the other include fields were added. This is how the implementation was made:
Step 1 - Add
include
struct field to SomeResourceListOptionsStep 2 - Create constants for the allowed include values that are typed strings
Step 3 - Add a test to make sure what are getting the "included" data
Bonus Step:
Change the pre-existing typed string named
SomePrefixIncludeOps
toSomePrefixIncludeOp
, liketype OAuthClientIncludeOps string
becomestype OAuthClientIncludeOp string
. I should have made the suffix singular from the beginning, but it is not too late to make that correction.To reduce noise coming from this change, you can focus on the changes made to:
Testing plan
External links
Output from tests (HashiCorp employees only)