- Notifications
You must be signed in to change notification settings - Fork 203
feat: Adds users attribute to mongodbatlas_organization(s) singular and plural data source. #3468
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
Conversation
APIx bot: a message has been sent to Docs Slack channel |
Computed: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
"username": { |
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.
is this the same or similar to project ? in case we can have some common schema
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.
They differ in some fields. Also project uses tpf and org uses sdk v2. See #3451 (comment)
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.
ah, ok, if it's tpf and sdv2 then it's better not to reuse, thanks
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.
Also, I think I can extract some of this logic to a common utility when implementing CLOUDP-328757
@@ -17,6 +19,57 @@ func FlattenLinks(links []admin.Link) []map[string]string { | |||
return ret | |||
} | |||
| |||
func FlattenUsers(users []admin.OrgUserResponse) []map[string]any { |
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.
not sure about having funcs in the common packages if they're only being used in one resource. I would have them here if at least used twice
resource.TestCheckResourceAttrWith(datasourceName, "users.#", acc.IntGreatThan(0)), | ||
resource.TestCheckResourceAttrSet(datasourceName, "users.0.id"), | ||
resource.TestCheckResourceAttrSet(datasourceName, "users.0.username"), | ||
resource.TestCheckResourceAttrSet(datasourceName, "users.0.roles.0.org_roles.#"), |
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.
these only checks that the attribute exists, don't know if we could also assert some expected values
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.
You can use the new ExpectKnownValue
as seen in this docs.
We dont' have many examples yet, but these might help:
- ConfigStateChecks: []statecheck.StateCheck{acc.PluralResultCheck(dataSourcePluralName, "role_name", knownvalue.StringExact(roleName), pluralMapChecks("INSERT", databaseName1))},
- func PluralResultCheck(resourceAddress, resultAttributeID string, resultAttributeMatch knownvalue.Check, checks map[string]knownvalue.Check) statecheck.StateCheck {
- KnownValue
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.
@EspenAlbert does the ExpectKnownValue
work for SDKv2 based resources as well? asking because in SDKv2, there are no nulls but empty values like ""
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.
Followup: This was discussed offline with the team. Decided to use regex validation to check that certain attributes (username, last_auth) have the appropriate structure/format rather than exact value matching. The reasoning is that these values can be unpredictable or non-deterministic. See 1d75984
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.
Sorry, only saw this now. @maastha yes, it should also work for SDKv2
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.
Nice. Agree with Leo's comments
Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>
docs/data-sources/organization.md Outdated
* `lastName` - Last name, family name, or surname that belongs to the MongoDB Cloud user. | ||
* `mobileNumber` - Mobile phone number that belongs to the MongoDB Cloud user. | ||
| ||
~> **NOTE:** - Does not return pending users invited via the deprecated [Invite One MongoDB Cloud User to Join One Project](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createprojectinvitation) endpoint or pending invitations created using [`mongodbatlas_project_invitation`](../resources/project_invitation.md) resource. |
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.
can we update this message to be consistent with the one mentioned in the tech design doc?
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.
Done e0aa80a. Added a TODO for completion in the following tickets.
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.
the TODO can be easy to miss since it's inside docs, instead I'd say remove the TODO from this PR & create a JIRA ticket to go over all documentation related to this epic & mention the link in this note may need to be updated
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.
Thank you for the suggestion. JIRA ticket: CLOUDP-329711
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.
LGTM.
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.
LGTM, one comment related to the docs
Description
Adds users attribute to mongodbatlas_organization singular data source.
Adds users attribute to mongodbatlas_organizations plural data source.
Link to any related issue(s): CLOUDP-328752
Type of change:
Required Checklist:
Further comments